|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.grizzly.filter.ReadFilter
public class ReadFilter
Simple ProtocolFilter implementation which read the available bytes and delegate the processing to the next ProtocolFilter in the ProtocolChain. If no bytes are available, no new ProtocolHandler will be a invoked and the connection (SelectionKey) will be cancelled. This filter can be used for both UDP (reveive) and TCP (read).
Field Summary | |
---|---|
protected boolean |
continousExecution
true if a pipelined execution is required. |
static String |
UDP_SOCKETADDRESS
|
Fields inherited from interface com.sun.grizzly.ProtocolFilter |
---|
SUCCESSFUL_READ |
Constructor Summary | |
---|---|
ReadFilter()
|
Method Summary | |
---|---|
boolean |
execute(Context ctx)
Read available bytes and delegate the processing of them to the next ProtocolFilter in the ProtocolChain. |
protected boolean |
execute(Context ctx,
ByteBuffer byteBuffer)
Read available bytes to the specific ByteBuffer and delegate
the processing of them to the next ProtocolFilter in the ProtocolChain. |
boolean |
isContinuousExecution()
Return true if the current Pipeline can
re-execute its ProtocolFilter after a successful execution. |
protected void |
log(String msg,
Throwable t)
Log a message/exception. |
boolean |
postExecute(Context ctx)
If no bytes were available, close the connection by cancelling the SelectionKey. |
void |
setContinuousExecution(boolean continousExecution)
Set to true if the current Pipeline can
re-execute its ProtocolFilter(s) after a successful execution. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String UDP_SOCKETADDRESS
protected boolean continousExecution
Constructor Detail |
---|
public ReadFilter()
Method Detail |
---|
public boolean execute(Context ctx) throws IOException
execute
in interface ProtocolFilter
ctx
- Context
IOException
protected boolean execute(Context ctx, ByteBuffer byteBuffer) throws IOException
ByteBuffer
and delegate
the processing of them to the next ProtocolFilter in the ProtocolChain.
IOException
public boolean postExecute(Context ctx) throws IOException
postExecute
in interface ProtocolFilter
ctx
- Context
IOException
public void setContinuousExecution(boolean continousExecution)
Pipeline
can
re-execute its ProtocolFilter(s) after a successful execution. Enabling
this property is useful for protocol that needs to support pipelined
message requests as the ProtocolFilter are automatically re-executed,
avoiding the overhead of releasing the current Thread, registering
back the SelectionKey to the SelectorHandler and waiting for a new
NIO event.
Some protocols (like http) can get the http headers in one
SocketChannel.read, parse the message and then get the next http message
on the second SocketChannel.read(). Not having to release the Thread
and re-execute the ProtocolFilter greatly improve performance.
continousExecution
- true to enable continuous execution.
(default is false).public boolean isContinuousExecution()
Pipeline
can
re-execute its ProtocolFilter after a successful execution.
protected void log(String msg, Throwable t)
msg
- String
t
- Throwable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |