|
||||||||||
| 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 | |
|---|---|
java.nio.channels.SelectableChannel |
acceptWithoutRegistration(java.nio.channels.SelectionKey key)
Accepts connection, without registering it for reading or writing |
ConnectorHandler |
acquireConnectorHandler()
Return an instance of the ConnectorHandler |
void |
closeChannel(java.nio.channels.SelectableChannel channel)
Closes SelectableChannel |
void |
configureChannel(java.nio.channels.SelectableChannel channel)
Configure the channel operations. |
AsyncQueueReader |
getAsyncQueueReader()
Returns AsyncQueueReader associated with this
SelectorHandler. |
AsyncQueueWriter |
getAsyncQueueWriter()
Returns AsyncQueueWriter associated with this
SelectorHandler. |
java.lang.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. |
java.nio.channels.Selector |
getSelector()
Gets the underlying selector. |
java.util.concurrent.ExecutorService |
getThreadPool()
Return the ExecutorService used to execute this
SelectorHandler's SelectionKey ops |
boolean |
isOpen()
Is the underlying Selector open. |
java.nio.channels.SelectionKey |
keyFor(java.nio.channels.SelectableChannel channel)
Returns SelectionKey, which represents binding between
the SelectableChannel and this SelectorHandler |
java.util.Set<java.nio.channels.SelectionKey> |
keys()
The SelectionKey that has been registered. |
boolean |
onAcceptInterest(java.nio.channels.SelectionKey key,
Context controllerCtx)
Handle OP_ACCEPT. |
boolean |
onConnectInterest(java.nio.channels.SelectionKey key,
Context controllerCtx)
Handle OP_CONNECT. |
boolean |
onReadInterest(java.nio.channels.SelectionKey key,
Context controllerCtx)
Handle OP_READ. |
boolean |
onWriteInterest(java.nio.channels.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(java.nio.channels.SelectableChannel channel,
int ops)
Register the SelectableChannel on the Selector. |
void |
register(java.nio.channels.SelectableChannel channel,
int ops,
java.lang.Object attachment)
Register the SelectableChannel on the Selector. |
void |
register(java.nio.channels.SelectionKey key,
int ops)
Register the SelectionKey on the Selector. |
void |
releaseConnectorHandler(ConnectorHandler connectorHandler)
Release a ConnectorHandler. |
void |
resume()
Resume this SelectorHandler |
java.util.Set<java.nio.channels.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(java.nio.channels.Selector selector)
Sets the underlying Selector |
void |
setThreadPool(java.util.concurrent.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()
java.nio.channels.Selector getSelector()
Selectorvoid setSelector(java.nio.channels.Selector selector)
Selector
selector - underlying Selectorjava.nio.channels.SelectionKey keyFor(java.nio.channels.SelectableChannel channel)
SelectionKey, which represents binding between
the SelectableChannel and this SelectorHandler
channel - SelectableChannel
SelectionKey, which represents binding between
the SelectableChannel and this SelectorHandlerjava.util.Set<java.nio.channels.SelectionKey> keys()
boolean isOpen()
void pause()
SelectorHandler
void resume()
SelectorHandler
void shutdown()
void preSelect(Context controllerCtx)
throws java.io.IOException
controllerCtx - Context
java.io.IOException
java.util.Set<java.nio.channels.SelectionKey> select(Context controllerCtx)
throws java.io.IOException
controllerCtx -
java.io.IOException
void postSelect(Context controllerCtx)
throws java.io.IOException
controllerCtx - Context
java.io.IOException
void register(java.nio.channels.SelectableChannel channel,
int ops)
SelectableChannel on the Selector.
key - ops - interested operations
void register(java.nio.channels.SelectableChannel channel,
int ops,
java.lang.Object attachment)
SelectableChannel on the Selector.
key - ops - interested operationsattachment -
void register(java.nio.channels.SelectionKey key,
int ops)
key - ops - interested operations
java.nio.channels.SelectableChannel acceptWithoutRegistration(java.nio.channels.SelectionKey key)
throws java.io.IOException
key -
SelectableChannel
java.io.IOException
boolean onAcceptInterest(java.nio.channels.SelectionKey key,
Context controllerCtx)
throws java.io.IOException
key - SelectionKeycontrollerCtx - Context
java.io.IOException
boolean onReadInterest(java.nio.channels.SelectionKey key,
Context controllerCtx)
throws java.io.IOException
key - SelectionKeycontrollerCtx - Context
java.io.IOException
boolean onWriteInterest(java.nio.channels.SelectionKey key,
Context controllerCtx)
throws java.io.IOException
key - SelectionKeycontrollerCtx - Context
java.io.IOException
boolean onConnectInterest(java.nio.channels.SelectionKey key,
Context controllerCtx)
throws java.io.IOException
key - SelectionKeycontrollerCtx - Context
java.io.IOExceptionConnectorHandler acquireConnectorHandler()
ConnectorHandler
ConnectorHandlervoid releaseConnectorHandler(ConnectorHandler connectorHandler)
connectorHandler - ConnectorHandler
void configureChannel(java.nio.channels.SelectableChannel channel)
throws java.io.IOException
channel - SelectableChannel to configure
java.io.IOException - on possible configuration related errorAsyncQueueReader getAsyncQueueReader()
AsyncQueueReader associated with this
SelectorHandler. Method will return null, if this
SelectorHandler is not running.
AsyncQueueReaderAsyncQueueWriter getAsyncQueueWriter()
AsyncQueueWriter associated with this
SelectorHandler. Method will return null, if this
SelectorHandler is not running.
AsyncQueueWriterjava.util.concurrent.ExecutorService getThreadPool()
ExecutorService used to execute this
SelectorHandler's SelectionKey ops
Controller's
ExecutorService should be used.void setThreadPool(java.util.concurrent.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.java.lang.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(java.nio.channels.SelectableChannel channel)
SelectableChannel
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||