|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.faunos.util.net.http.FileChannelStagelet
public class FileChannelStagelet
Serves the contents of an HTTP response from a FileChannel. Note, the instance will own the position of the given file channel after the init method is invoked. This class does not rewind the file channel to zero before writing: whatever it's value at init, that value will denote the beginning of the file.
Field Summary | |
---|---|
protected FileChannel |
content
|
Constructor Summary | |
---|---|
FileChannelStagelet(FileChannel content,
StageletStack stack,
boolean persistConnection,
boolean head)
Creates a new instance. |
Method Summary | |
---|---|
void |
discard()
Closes the content stream |
ResponseHeaderStage |
getHeaders()
Returns the HTTP response header stage. |
IoState |
init(HandletContext context)
Initializes the handlet. |
IoState |
read(ScatteringByteChannel in)
Not used. |
IoState |
state()
Returns the state of the handlet. |
IoState |
unwind(IoState preState)
Callback method invoked when the previous stage[let] returned DONE. |
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 |
Field Detail |
---|
protected FileChannel content
Constructor Detail |
---|
public FileChannelStagelet(FileChannel content, StageletStack stack, boolean persistConnection, boolean head)
content
- the channel from which the content will be served. If
null, then the response will be "Not Found" (404).stack
- the execution stack. Must not be nullpersistConnection
- if false, then the response headers shall
include "Connection: close".Method Detail |
---|
public ResponseHeaderStage getHeaders()
public IoState unwind(IoState preState)
Stagelet
Handlet.discard()
method on the super
interface.
unwind
in interface Stagelet
preState
- the state of the previous stage prior to its flipping to
DONE
Stagelet
on the execution
stack, then that stage's unwind()
method will also
be invoked with the same preState
argument.public void discard()
discard
in interface Handlet
public IoState init(HandletContext context)
Handlet
init
in interface Handlet
context
- the context supplied by the instance's container (e.g.
serverpublic IoState read(ScatteringByteChannel in) throws IOException
read
in interface Handlet
UnsupportedOperationException
IOException
public IoState state()
Handlet
state
in interface Handlet
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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |