|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.grizzly.http.algorithms.StreamAlgorithmBase
public abstract class StreamAlgorithmBase
Base class for StreamAlgorithm implementation.
| Nested Class Summary | |
|---|---|
static class |
StreamAlgorithmBase.DummyHandler
Empty handler used when Grizzly is bundled outside of GlassFish. |
| Field Summary | |
|---|---|
protected int |
contentLength
The actual length of the stream we are able to read. |
protected int |
curLimit
The ByteBuffer current limit value |
protected int |
curPosition
The ByteBuffer current position value |
protected Interceptor |
handler
An Interceptor implementation used to implement a
static resources cache. |
protected int |
headerLength
The position, within the ByteBuffer, when the HTTP
headers are completely reads. |
protected int |
lastStatePosition
In case we were'nt able to parse the request line, we will continue parsing from that position. |
protected ByteBuffer |
primaryByteBuffer
If a new ByteBuffer is created because the stream is
too small, cache the original byteBuffer and reuse it once the
transaction has completed. |
protected SocketChannel |
socketChannel
The SocketChannel associated with this algorithm. |
protected int |
state
If the stream wasn't read fully, keep the state of the http parsing. |
protected boolean |
useByteBufferView
If true, use a ByteBuffer view instead of
ByteBuffer |
protected boolean |
useDirectByteBuffer
Are we using direct ByteBuffer |
| Constructor Summary | |
|---|---|
StreamAlgorithmBase()
|
|
| Method Summary | |
|---|---|
ByteBuffer |
allocate(boolean useDirectByteBuffer,
boolean useByteBufferView,
int size)
Allocate a ByteBuffer |
int |
contentLength()
Return the stream content-length. |
protected String |
dump(ByteBuffer byteBuffer)
Dump the ByteBuffer content. |
int |
getPort()
Return the port |
int |
headerLength()
Return the stream header length. |
abstract boolean |
parse(ByteBuffer byteBuffer)
Manipulate the bytes stream and determine if the process can continue. |
ByteBuffer |
postParse(ByteBuffer byteBuffer)
After parsing the bytes, post process the ByteBuffer |
ByteBuffer |
preParse(ByteBuffer byteBuffer)
Before parsing the bytes, initialize and prepare the algorithm. |
void |
recycle()
Reset this object to its default state. |
ByteBuffer |
rollbackParseState(ByteBuffer byteBuffer)
Rollback the ByteBuffer to its previous state in case
an error as occured. |
void |
setChannel(SocketChannel socketChannel)
The SocketChannel used by this class. |
void |
setPort(int port)
Set the port |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.sun.grizzly.util.StreamAlgorithm |
|---|
getHandler |
| Field Detail |
|---|
protected int contentLength
protected int curLimit
ByteBuffer current limit value
protected int curPosition
ByteBuffer current position value
protected int headerLength
ByteBuffer, when the HTTP
headers are completely reads.
protected int lastStatePosition
protected int state
protected ByteBuffer primaryByteBuffer
ByteBuffer is created because the stream is
too small, cache the original byteBuffer and reuse it once the
transaction has completed.
protected boolean useByteBufferView
ByteBuffer view instead of
ByteBuffer
protected boolean useDirectByteBuffer
ByteBuffer
protected SocketChannel socketChannel
SocketChannel associated with this algorithm.
protected Interceptor handler
Interceptor implementation used to implement a
static resources cache.
| Constructor Detail |
|---|
public StreamAlgorithmBase()
| Method Detail |
|---|
public abstract boolean parse(ByteBuffer byteBuffer)
parse in interface StreamAlgorithm<SocketChannel>public int contentLength()
contentLength in interface StreamAlgorithm<SocketChannel>public int headerLength()
headerLength in interface StreamAlgorithm<SocketChannel>public ByteBuffer preParse(ByteBuffer byteBuffer)
preParse in interface StreamAlgorithm<SocketChannel>byteBuffer - the ByteBuffer used by this algorithm
ByteBuffer used by this algorithmpublic ByteBuffer postParse(ByteBuffer byteBuffer)
ByteBuffer
postParse in interface StreamAlgorithm<SocketChannel>byteBuffer - the ByteBuffer used by this algorithm
ByteBuffer used by this algorithmpublic void recycle()
recycle in interface StreamAlgorithm<SocketChannel>
public ByteBuffer allocate(boolean useDirectByteBuffer,
boolean useByteBufferView,
int size)
ByteBuffer
allocate in interface StreamAlgorithm<SocketChannel>useDirectByteBuffer - to create a direct ByteBufferuseByteBufferView - to create ByteBuffer viewsize - the size of the ByteBuffer
ByteBufferpublic ByteBuffer rollbackParseState(ByteBuffer byteBuffer)
ByteBuffer to its previous state in case
an error as occured.
rollbackParseState in interface StreamAlgorithm<SocketChannel>protected String dump(ByteBuffer byteBuffer)
public void setChannel(SocketChannel socketChannel)
SocketChannel used by this class.
setChannel in interface StreamAlgorithm<SocketChannel>public void setPort(int port)
setPort in interface StreamAlgorithm<SocketChannel>public int getPort()
getPort in interface StreamAlgorithm<SocketChannel>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||