|
||||||||||
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)
Cancel a SelectionKey and close its associated Channel. |
protected void |
cancelKey(SelectionKey key)
|
protected Object |
clearKeyAttachment(SelectionKey key)
|
void |
close(SelectionKey key)
Close the SelectionKey's channel input or output, but keep alive the SelectionKey. |
protected void |
closeChannel(SelectableChannel channel)
|
protected void |
closeChannel(SelectionKey key)
|
void |
copyTo(Copyable copy)
Copies current object content to copy object |
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 |
protected boolean |
keyIsValid(SelectionKey key)
|
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(SelectionKey key,
int selectionKeyOps)
Register a SelectionKey on Selector . |
void |
register(SelectionKey key,
long currentTime)
Deprecated. |
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 SelectionKeyHandler
public void setSelectorHandler(SelectorHandler selectorHandler)
SelectorHandler
setSelectorHandler
in interface SelectionKeyHandler
public void process(SelectionKey key)
SelectionKey
process notification
process
in interface SelectionKeyHandler
key
- SelectionKey
to processpublic void postProcess(SelectionKey key)
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)
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
SelectableChannel
on Selector
.
register
in interface SelectionKeyHandler
channel
- SelectableChannel
selectionKeyOps
- The interest set to apply when registering.
to register
ClosedChannelException
public void register(Iterator<SelectionKey> keyIterator, int selectionKeyOps)
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)
SelectionKey
set. Method checks
each SelectionKey
from the Set
. 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)
cancel
in interface SelectionKeyHandler
key
- SelectionKey
to cancelpublic void close(SelectionKey key)
close
in interface SelectionKeyHandler
key
- SelectionKey
to closepublic void copyTo(Copyable copy)
copyTo
in interface Copyable
copy
- represents target object, where current object's content will be copiedpublic Logger getLogger()
public void setLogger(Logger logger)
protected void cancelKey(SelectionKey key)
protected boolean keyIsValid(SelectionKey key)
protected void closeChannel(SelectionKey key)
protected Object clearKeyAttachment(SelectionKey key)
protected void closeChannel(SelectableChannel channel)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |