|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.grizzly.DefaultCallbackHandler
public class DefaultCallbackHandler
Default CallbackHandler
implementation that implements the connect
operations, and delegate the read and write operations to its associated
SelectorHandler
ProtocolChain
, like the default
SelectorHandler
is doing server side component. The code below
can be used for by ConnectorHandler
to manipulater the read
and write operation of a non blocking client implementation.
A ConnectorHandler
can use this CallbackHandler
and delegate
the processing of the bytes to a ProtocolChain
Controller sel = new Controller();
sel.setProtocolChainInstanceHandler(new DefaultProtocolChainInstanceHandler(){
public ProtocolChain poll() {
ProtocolChain protocolChain = protocolChains.poll();
if (protocolChain == null){
protocolChain = new DefaultProtocolChain();
protocolChain.addFilter(new ReadWriteFilter());
protocolChain.addFilter(new LogFilter());
}
return protocolChain;
}
});
TCPConnectorHandler tcph = Controller.acquireConnectorHandler(Protocol.TCP);
tcph.connect(....);
With the above example, all read and write operations
will be handled by the ProtocolChain
instead of having to be
implemented inside the CallbackHandler.onRead(com.sun.grizzly.IOEvent
and
CallbackHandler.onWrite(com.sun.grizzly.IOEvent
Constructor Summary | |
---|---|
DefaultCallbackHandler(ConnectorHandler connectorHandler)
Create a CallbackHandler that delegate the read and write
operation to the ProtocolChain associated with the
ConnectorHandler |
|
DefaultCallbackHandler(ConnectorHandler connectorHandler,
boolean delegateToProtocolChain)
Create a CallbackHandler that delegate the read and write
operation to the ProtocolChain associated with the
ConnectorHandler . |
Method Summary | |
---|---|
boolean |
isDelegateToProtocolChain()
Return true> if delegation to the ProtocolChain is enabled. |
void |
onConnect(IOEvent<Context> ioEvent)
Execute the non blocking connect operation. |
void |
onHandshake(IOEvent<Context> ioEvent)
By default, do nothing. |
void |
onRead(IOEvent<Context> ioEvent)
Delegate the processing of the read operation to the IOEvent{ associated {@link ProtocolChain} |
void |
onWrite(IOEvent<Context> ioEvent)
Delegate the processing of the write operation to the IOEvent{ associated {@link ProtocolChain} |
void |
setDelegateToProtocolChain(boolean delegateToProtocolChain)
Set to true> to enable delagation of the read and write operations to a ProtocolChain true> to enable delagation of the read and write operations
to a ProtocolChain |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DefaultCallbackHandler(ConnectorHandler connectorHandler)
CallbackHandler
that delegate the read and write
operation to the ProtocolChain
associated with the
ConnectorHandler
connectorHandler
- An instance of ConnectorHandler
public DefaultCallbackHandler(ConnectorHandler connectorHandler, boolean delegateToProtocolChain)
CallbackHandler
that delegate the read and write
operation to the ProtocolChain
associated with the
ConnectorHandler
. Delegation is disabled when
connectorHandler
- An instance of ConnectorHandler
delegateToProtocolChain
- true to delegate the read/write operation
to a ProtocolChain
Method Detail |
---|
public void onConnect(IOEvent<Context> ioEvent)
onConnect
in interface CallbackHandler<Context>
ioEvent
- an IOEvent
representing the current state
of the OP_CONNECT operations.public void onRead(IOEvent<Context> ioEvent)
onRead
in interface CallbackHandler<Context>
ioEvent
- an IOEvent
representing the current state of the
OP_CONNECT operations.public void onWrite(IOEvent<Context> ioEvent)
onWrite
in interface CallbackHandler<Context>
ioEvent
- an IOEvent
representing the current state of the
OP_CONNECT operations.public void onHandshake(IOEvent<Context> ioEvent)
onHandshake
in interface SSLCallbackHandler<Context>
ioEvent
- an IOEvent
representing the current state of the
handshake operations.public boolean isDelegateToProtocolChain()
ProtocolChain
is enabled.
ProtocolChain
is enabled.public void setDelegateToProtocolChain(boolean delegateToProtocolChain)
ProtocolChain
true> to enable delagation of the read and write operations
to a ProtocolChain
delegateToProtocolChain
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |