|
||||||||||
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)
Copies current object content to copy object |
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. |
Logger |
getLogger()
|
SelectorHandler |
getSelectorHandler()
Get associated SelectorHandler |
void |
notifyLocallyClose(SelectionKey key)
Notify a ConnectionCloseHandler that a remote connection
has been closed. |
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 SelectionKey s. |
void |
register(SelectableChannel channel,
int selectionKeyOps)
Register a SelectableChannel on Selector . |
void |
register(SelectableChannel channel,
int selectionKeyOps,
Object attachment)
Register a SelectableChannel on Selector . |
void |
register(SelectionKey key,
int selectionKeyOps)
Register a SelectionKey on Selector . |
void |
register(SelectionKey key,
long currentTime)
Deprecated. |
void |
removeConnectionCloseHandler(ConnectionCloseHandler cch)
Removes the the ConnectionCloseHandler from a set. |
void |
setConnectionCloseHandler(ConnectionCloseHandler cch)
Adds the the ConnectionCloseHandler to a set. |
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()
SelectionKeyHandler
SelectorHandler
getSelectorHandler
in interface SelectionKeyHandler
public void setSelectorHandler(SelectorHandler selectorHandler)
SelectionKeyHandler
SelectorHandler
setSelectorHandler
in interface SelectionKeyHandler
public void process(SelectionKey key)
SelectionKeyHandler
SelectionKey
process notification
process
in interface SelectionKeyHandler
key
- SelectionKey
to processpublic void postProcess(SelectionKey key)
SelectionKeyHandler
SelectionKey
post process notification
postProcess
in interface SelectionKeyHandler
key
- SelectionKey
to processpublic void register(SelectionKey key, long currentTime)
SelectionKeyHandler
register
in interface SelectionKeyHandler
key
- SelectionKey
to registercurrentTime
- the System.currentTimeMillispublic void register(SelectionKey key, int selectionKeyOps)
SelectionKeyHandler
SelectionKey
on Selector
.
register
in interface SelectionKeyHandler
key
- SelectionKey
selectionKeyOps
- The interest set to apply when registering.
to registerprotected void doRegisterKey(SelectionKey key, int selectionKeyOps)
SelectionKey
to handle certain operations
public void register(SelectableChannel channel, int selectionKeyOps) throws ClosedChannelException
SelectionKeyHandler
SelectableChannel
on Selector
.
register
in interface SelectionKeyHandler
channel
- SelectableChannel
selectionKeyOps
- The interest set to apply when registering.
to register
ClosedChannelException
public void register(SelectableChannel channel, int selectionKeyOps, Object attachment) throws ClosedChannelException
SelectionKeyHandler
SelectableChannel
on Selector
.
register
in interface SelectionKeyHandler
channel
- SelectableChannel
selectionKeyOps
- The interest set to apply when registering.
to registerattachment
- attachment
ClosedChannelException
public void register(Iterator<SelectionKey> keyIterator, int selectionKeyOps)
SelectionKeyHandler
SelectionKey
s.
Note: After processing each SelectionKey
it should be
removed from Iterator
register
in interface SelectionKeyHandler
selectionKeyOps
- The interest set to apply when registering.
to registerpublic void expire(SelectionKey key, long currentTime)
SelectionKeyHandler
SelectionKey
. If a SelectionKey
is
inactive for certain time (timeout), the SelectionKey
will be cancelled and its associated Channel closed.
expire
in interface SelectionKeyHandler
key
- SelectionKey
to expirecurrentTime
- the System.currentTimeMillispublic void expire(Iterator<SelectionKey> keyIterator)
SelectionKeyHandler
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 SelectionKeyHandler
keyIterator
- Iterator
of SelectionKey
s
to expirepublic void cancel(SelectionKey key)
doAfterKeyCancel(SelectionKey)
is called even if key is invalid.
cancel
in interface SelectionKeyHandler
key
- 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.
notifyRemotlyClose
in interface ConnectionCloseHandlerNotifier
key
- a SelectionKey
public void notifyLocallyClose(SelectionKey key)
ConnectionCloseHandler
that a remote connection
has been closed.
notifyLocallyClose
in interface ConnectionCloseHandlerNotifier
key
- a SelectionKey
public void close(SelectionKey key)
SelectionKeyHandler
close
in interface SelectionKeyHandler
key
- SelectionKey
to closepublic void setConnectionCloseHandler(ConnectionCloseHandler cch)
ConnectionCloseHandler
to a set.
cch
- ConnectionCloseHandler
public void removeConnectionCloseHandler(ConnectionCloseHandler cch)
ConnectionCloseHandler
from a set.
cch
- ConnectionCloseHandler
public void copyTo(Copyable copy)
Copyable
copyTo
in interface Copyable
copy
- represents target object, where current object's content will be copiedpublic Logger getLogger()
public void setLogger(Logger logger)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |