|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.faunos.util.net.StageletStack
public class StageletStack
A Handlet
filter that implements something like a call stack.
Constructor Summary | |
---|---|
protected |
StageletStack()
To be overridden by subclasses. |
|
StageletStack(Stagelet root)
Creates a new instance with the given root stage. |
Method Summary | |
---|---|
Stagelet |
current()
Returns the stagelet currently at the top of the stack. |
void |
discard()
Discards the instance. |
IoState |
init(HandletContext context)
Initializes the handlet. |
protected Object |
lock()
Returns the object synchronized on while stagelets are pushed on and popped off the stack. |
void |
push(Stagelet stage)
Pushes the given stage onto this stack. |
IoState |
read(ScatteringByteChannel in)
Reads from the specified channel and returns the possibly new state of the instance. |
IoState |
state()
Returns the state of the handlet. |
IoState |
write(GatheringByteChannel out)
Writes to the specified channel and returns the possibly new state of the instance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected StageletStack()
push(Stagelet)
before returning from
the constructor; otherwise the object will be in an invalid
state.
public StageletStack(Stagelet root)
Note there is a little chicken and egg problem, here. The root stagelet must be stack-aware. In particular, it must be aware of this instance. And of course, since the stack instance is yet to be created, root cannot be a properly constructed (configured) object prior to invocation. Which is why we also expose a protected constructor.
Method Detail |
---|
protected final Object lock()
public void push(Stagelet stage)
There is no direct mechanism for popping stagelets off the stack. Rather, when the topmost stagelet on the stack is IoState.DONE, it is automatically popped off the stack.
public final Stagelet current()
public IoState init(HandletContext context)
Handlet
init
in interface Handlet
context
- the context supplied by the instance's container (e.g.
serverpublic IoState state()
Handlet
state
in interface Handlet
public IoState read(ScatteringByteChannel in) throws IOException
Handlet
Handlet.state()
may
return a value other than PROCESSING
, if the asynchronous
task completes before the call to state()
.
The implementation must read from the channel in non-blocking manner. The behavior of this method is undefined if the state of the instance is not IoState.READING.
read
in interface Handlet
IOException
public IoState write(GatheringByteChannel out) throws IOException
Handlet
Handlet.state()
may
return a value other than PROCESSING
, if the asynchronous
task completes before the call to state()
.
The implementation must write to the channel in non-blocking manner. The behavior of this method is undefined if the state of the instance is not IoState.WRITING.
write
in interface Handlet
IOException
public void discard()
Handlet
discard
in interface Handlet
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |