|
||||||||||
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. |
ExecutorService |
getThreadPool()
Return the ExecutorService used to execute this
SelectorHandler 's SelectionKey ops |
boolean |
isOpen()
Is the underlying Selector open. |
SelectionKey |
keyFor(SelectableChannel channel)
Returns SelectionKey , which represents binding between
the SelectableChannel and this SelectorHandler |
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 |
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(SelectableChannel channel,
int ops,
Object attachment)
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 |
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 |
setThreadPool(ExecutorService threadPool)
Set the ExecutorService used to execute this
SelectorHandler 's SelectionKey ops |
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 |
Methods inherited from interface com.sun.grizzly.tcp.PendingIOhandler |
---|
addPendingIO, addPendingKeyCancel |
Method Detail |
---|
Controller.Protocol protocol()
Selector getSelector()
Selector
void setSelector(Selector selector)
Selector
selector
- underlying Selector
SelectionKey keyFor(SelectableChannel channel)
SelectionKey
, which represents binding between
the SelectableChannel
and this SelectorHandler
channel
- SelectableChannel
SelectionKey
, which represents binding between
the SelectableChannel
and this SelectorHandlerSet<SelectionKey> keys()
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
-
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(SelectableChannel channel, int ops, Object attachment)
SelectableChannel
on the Selector
.
key
- ops
- interested operationsattachment
- void 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.
AsyncQueueWriter
ExecutorService getThreadPool()
ExecutorService
used to execute this
SelectorHandler
's SelectionKey
ops
Controller
's
ExecutorService
should be used.void setThreadPool(ExecutorService threadPool)
ExecutorService
used to execute this
SelectorHandler
's SelectionKey
ops
The
- thread pool to use, or null if the Controller
's
ExecutorService
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 |