|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.grizzly.BaseSelectionKeyHandler
public class BaseSelectionKeyHandler
This class is an implementation of a SelectionKeyHandler which does not use the SelectionKey attachment, does not expire keys or utilize a keep-alive mechanism. However, this is currently not the SelectionKeyHandler provisioned by default with Grizzly's Controller. Hence for an application to use this SelectionKeyHandler, Grizzly's Controller must be explicitly configured to use this SelectionKeyHandler implementation.
| Field Summary | |
|---|---|
protected Logger |
logger
|
protected SelectorHandler |
selectorHandler
Associated SelectorHandler |
| Constructor Summary | |
|---|---|
BaseSelectionKeyHandler()
|
|
BaseSelectionKeyHandler(SelectorHandler selectorHandler)
|
|
| Method Summary | |
|---|---|
void |
cancel(SelectionKey key)
if SelectionKey is valid, its canceled . |
void |
close(SelectionKey key)
Close the SelectionKey's channel input or output, but keep alive the SelectionKey. |
void |
copyTo(Copyable copy)
|
protected void |
doAfterKeyCancel(SelectionKey key)
performed when a key is canceled. closes the channel and notifies ConnectionCloseHandler ,
if SelectionKey.attachment() instanceof SelectionKeyAttachment then
its release method is called. |
protected void |
doRegisterKey(SelectionKey key,
int selectionKeyOps)
Registers SelectionKey to handle certain operations |
void |
expire(Iterator<SelectionKey> keyIterator)
Expire a SelectionKey set. |
void |
expire(SelectionKey key,
long currentTime)
Deprecated. |
ConnectionCloseHandler |
getConnectionCloseHandler()
Return the ConnectionClosedHandler. |
Logger |
getLogger()
|
SelectorHandler |
getSelectorHandler()
Get associated SelectorHandler |
void |
notifyRemotlyClose(SelectionKey key)
Notify a ConnectionCloseHandler that a remote connection
has been closed. |
void |
postProcess(SelectionKey key)
SelectionKey post process notification |
void |
process(SelectionKey key)
SelectionKey process notification |
void |
register(Iterator<SelectionKey> keyIterator,
int selectionKeyOps)
Register a set of SelectionKeys. |
void |
register(SelectableChannel channel,
int selectionKeyOps)
Register a SelectableChannel on Selector. |
void |
register(SelectionKey key,
int selectionKeyOps)
Register a SelectionKey on Selector. |
void |
register(SelectionKey key,
long currentTime)
Deprecated. |
void |
setConnectionCloseHandler(ConnectionCloseHandler cch)
Set the the ConnectionClosedHandler |
void |
setLogger(Logger logger)
|
void |
setSelectorHandler(SelectorHandler selectorHandler)
Set associated SelectorHandler |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Logger logger
protected SelectorHandler selectorHandler
SelectorHandler
| Constructor Detail |
|---|
public BaseSelectionKeyHandler()
public BaseSelectionKeyHandler(SelectorHandler selectorHandler)
| Method Detail |
|---|
public SelectorHandler getSelectorHandler()
SelectorHandler
getSelectorHandler in interface SelectionKeyHandlerpublic void setSelectorHandler(SelectorHandler selectorHandler)
SelectorHandler
setSelectorHandler in interface SelectionKeyHandlerpublic void process(SelectionKey key)
SelectionKey process notification
process in interface SelectionKeyHandlerkey - SelectionKey to processpublic void postProcess(SelectionKey key)
SelectionKey post process notification
postProcess in interface SelectionKeyHandlerkey - SelectionKey to process
public void register(SelectionKey key,
long currentTime)
SelectionKeyHandler
register in interface SelectionKeyHandlerkey - SelectionKey to registercurrentTime - the System.currentTimeMillis
public void register(SelectionKey key,
int selectionKeyOps)
SelectionKey on Selector.
register in interface SelectionKeyHandlerkey - SelectionKeyselectionKeyOps - The interest set to apply when registering.
to register
protected void doRegisterKey(SelectionKey key,
int selectionKeyOps)
SelectionKey to handle certain operations
public void register(SelectableChannel channel,
int selectionKeyOps)
throws ClosedChannelException
SelectableChannel on Selector.
register in interface SelectionKeyHandlerchannel - SelectableChannelselectionKeyOps - The interest set to apply when registering.
to register
ClosedChannelException
public void register(Iterator<SelectionKey> keyIterator,
int selectionKeyOps)
SelectionKeys.
Note: After processing each SelectionKey it should be
removed from Iterator
register in interface SelectionKeyHandlerselectionKeyOps - The interest set to apply when registering.
to register
public void expire(SelectionKey key,
long currentTime)
SelectionKeyHandlerSelectionKey. If a SelectionKey is
inactive for certain time (timeout), the SelectionKey
will be cancelled and its associated Channel closed.
expire in interface SelectionKeyHandlerkey - SelectionKey to expirecurrentTime - the System.currentTimeMillispublic void expire(Iterator<SelectionKey> keyIterator)
SelectionKey set. Method checks
each SelectionKey from theSet. And if
a SelectionKey is inactive for certain time (timeout),
the SelectionKey will be cancelled and its associated Channel closed.
expire in interface SelectionKeyHandlerkeyIterator - Iterator of SelectionKeys
to expirepublic void cancel(SelectionKey key)
doAfterKeyCancel(SelectionKey key) is called even if key is invalid.
cancel in interface SelectionKeyHandlerkey - SelectionKey to cancelprotected void doAfterKeyCancel(SelectionKey key)
ConnectionCloseHandler ,
if SelectionKey.attachment() instanceof SelectionKeyAttachment then
its release method is called.
public void notifyRemotlyClose(SelectionKey key)
ConnectionCloseHandler that a remote connection
has been closed.
key - a Selectionkeypublic void close(SelectionKey key)
close in interface SelectionKeyHandlerkey - SelectionKey to closepublic ConnectionCloseHandler getConnectionCloseHandler()
ConnectionClosedHandler.
ConnectionClosedHandlerpublic void setConnectionCloseHandler(ConnectionCloseHandler cch)
ConnectionClosedHandler
cch - ConnectionClosedHandlerpublic void copyTo(Copyable copy)
copyTo in interface Copyablepublic Logger getLogger()
public void setLogger(Logger logger)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||