|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface SelectorHandler
A SelectorHandler handles all java.nio.channels.Selector operations. One or more instance of a Selector are handled by SelectorHandler. The logic for processing of SelectionKey interest (OP_ACCEPT,OP_READ, etc.) is usually defined using an instance of SelectorHandler.
Method Summary | |
---|---|
SelectableChannel |
acceptWithoutRegistration(SelectionKey key)
Accepts connection, without registering it for reading or writing |
ConnectorHandler |
acquireConnectorHandler()
Return an instance of the ConnectorHandler |
void |
closeChannel(SelectableChannel channel)
Closes SelectableChannel |
void |
configureChannel(SelectableChannel channel)
Configure the channel operations. |
AsyncQueueReader |
getAsyncQueueReader()
Returns AsyncQueueReader associated with this
SelectorHandler . |
AsyncQueueWriter |
getAsyncQueueWriter()
Returns AsyncQueueWriter associated with this
SelectorHandler . |
Class<? extends SelectionKeyHandler> |
getPreferredSelectionKeyHandler()
Get the preffered SelectionKeyHandler implementation for this SelectorHandler. |
ProtocolChainInstanceHandler |
getProtocolChainInstanceHandler()
Return the ProtocolChainInstanceHandler |
SelectionKeyHandler |
getSelectionKeyHandler()
Get the SelectionKeyHandler associated with this SelectorHandler. |
Selector |
getSelector()
Gets the underlying selector. |
boolean |
isOpen()
Is the underlying Selector open. |
Set<SelectionKey> |
keys()
The SelectionKey that has been registered. |
boolean |
onAcceptInterest(SelectionKey key,
Context controllerCtx)
Handle OP_ACCEPT. |
boolean |
onConnectInterest(SelectionKey key,
Context controllerCtx)
Handle OP_CONNECT. |
boolean |
onReadInterest(SelectionKey key,
Context controllerCtx)
Handle OP_READ. |
boolean |
onWriteInterest(SelectionKey key,
Context controllerCtx)
Handle OP_WRITE. |
void |
pause()
Pause this SelectorHandler |
Pipeline |
pipeline()
Return the Pipeline used to execute this
SelectorHandler 's SelectionKey ops |
void |
postSelect(Context controllerCtx)
This method is garantee to always be called after operation Selector.select(). |
void |
preSelect(Context controllerCtx)
This method is garantee to always be called before operation Selector.select(). |
Controller.Protocol |
protocol()
A token decribing the protocol supported by an implementation of this interface |
void |
register(SelectableChannel channel,
int ops)
Register the SelectableChannel on the Selector . |
void |
register(SelectionKey key,
int ops)
Register the SelectionKey on the Selector. |
void |
releaseConnectorHandler(ConnectorHandler connectorHandler)
Release a ConnectorHandler. |
void |
resume()
Resume this SelectorHandler |
Set<SelectionKey> |
select(Context controllerCtx)
Invoke the Selector.select() method. |
void |
setPipeline(Pipeline pipeline)
Set the Pipeline used to execute this
SelectorHandler 's SelectionKey ops |
void |
setProtocolChainInstanceHandler(ProtocolChainInstanceHandler protocolChainInstanceHandler)
Set the ProtocolChainInstanceHandler to use for
creating instance of ProtocolChain . |
void |
setSelectionKeyHandler(SelectionKeyHandler selectionKeyHandler)
Set SelectionKeyHandler associated with this SelectorHandler. |
void |
setSelector(Selector selector)
Sets the underlying Selector |
void |
shutdown()
Shutdown this instance. |
Methods inherited from interface com.sun.grizzly.util.Copyable |
---|
copyTo |
Methods inherited from interface com.sun.grizzly.util.AttributeHolder |
---|
getAttribute, getAttributes, removeAttribute, setAttribute, setAttributes |
Methods inherited from interface com.sun.grizzly.util.SupportStateHolder |
---|
getStateHolder |
Method Detail |
---|
Controller.Protocol protocol()
Selector getSelector()
Selector
void setSelector(Selector selector)
Selector
selector
- underlying Selector
Set<SelectionKey> keys()
Set
of SelectionKey
boolean isOpen()
void pause()
SelectorHandler
void resume()
SelectorHandler
void shutdown()
void preSelect(Context controllerCtx) throws IOException
controllerCtx
- Context
IOException
Set<SelectionKey> select(Context controllerCtx) throws IOException
controllerCtx
-
Set
of SelectionKey
IOException
void postSelect(Context controllerCtx) throws IOException
controllerCtx
- Context
IOException
void register(SelectableChannel channel, int ops)
SelectableChannel
on the Selector
.
key
- ops
- interested operationsvoid register(SelectionKey key, int ops)
key
- ops
- interested operationsSelectableChannel acceptWithoutRegistration(SelectionKey key) throws IOException
key
-
SelectableChannel
IOException
boolean onAcceptInterest(SelectionKey key, Context controllerCtx) throws IOException
key
- SelectionKey
controllerCtx
- Context
IOException
boolean onReadInterest(SelectionKey key, Context controllerCtx) throws IOException
key
- SelectionKey
controllerCtx
- Context
IOException
boolean onWriteInterest(SelectionKey key, Context controllerCtx) throws IOException
key
- SelectionKey
controllerCtx
- Context
IOException
boolean onConnectInterest(SelectionKey key, Context controllerCtx) throws IOException
key
- SelectionKey
controllerCtx
- Context
IOException
ConnectorHandler acquireConnectorHandler()
ConnectorHandler
ConnectorHandler
void releaseConnectorHandler(ConnectorHandler connectorHandler)
connectorHandler
- ConnectorHandler
void configureChannel(SelectableChannel channel) throws IOException
channel
- SelectableChannel
to configure
IOException
- on possible configuration related errorAsyncQueueReader getAsyncQueueReader()
AsyncQueueReader
associated with this
SelectorHandler
. Method will return null, if this
SelectorHandler
is not running.
AsyncQueueReader
AsyncQueueWriter getAsyncQueueWriter()
AsyncQueueWriter
associated with this
SelectorHandler
. Method will return null, if this
SelectorHandler
is not running.
AsyncQuqueWriter
Pipeline pipeline()
Pipeline
used to execute this
SelectorHandler
's SelectionKey
ops
Controller
's
Pipeline
should be used.void setPipeline(Pipeline pipeline)
Pipeline
used to execute this
SelectorHandler
's SelectionKey
ops
The
- pipeline to use, or null if the Controller
's
Pipeline
should be used.Class<? extends SelectionKeyHandler> getPreferredSelectionKeyHandler()
SelectionKeyHandler getSelectionKeyHandler()
void setSelectionKeyHandler(SelectionKeyHandler selectionKeyHandler)
void setProtocolChainInstanceHandler(ProtocolChainInstanceHandler protocolChainInstanceHandler)
ProtocolChainInstanceHandler
to use for
creating instance of ProtocolChain
.
ProtocolChainInstanceHandler getProtocolChainInstanceHandler()
ProtocolChainInstanceHandler
void closeChannel(SelectableChannel channel)
SelectableChannel
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |