|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.grizzly.BaseSelectionKeyHandler
com.sun.grizzly.DefaultSelectionKeyHandler
public class DefaultSelectionKeyHandler
Default implementation of a SelectionKey Handler. By default, this class will attach a Long to a SelectionKey in order to calculate the time a SelectionKey can stay active. By default, a SelectionKey will be active for 30 seconds. If during that 30 seconds the client isn't pushing bytes (or closing the connection). the SelectionKey will be expired and its channel closed.
Field Summary | |
---|---|
protected long |
nextKeysExpiration
Next time the exprireKeys() will delete keys. |
protected long |
timeout
|
Fields inherited from class com.sun.grizzly.BaseSelectionKeyHandler |
---|
logger, selectorHandler |
Constructor Summary | |
---|---|
DefaultSelectionKeyHandler()
|
|
DefaultSelectionKeyHandler(SelectorHandler selectorHandler)
|
Method Summary | |
---|---|
protected void |
addExpirationStamp(SelectionKey key)
|
protected void |
addExpirationStamp(SelectionKey key,
long currentTime)
Adds expiration timeout stamp to the SelectionKey
depending on its attachment |
void |
copyTo(Copyable copy)
Copies current object content to copy object |
protected void |
doRegisterKey(SelectionKey key,
int selectionKeyOps,
long currentTime)
Registers SelectionKey to handle certain operations |
void |
expire(Iterator<SelectionKey> iterator)
Expire a SelectionKey set. |
void |
expire(SelectionKey key,
long currentTime)
Deprecated. |
protected long |
getExpirationStamp(Object attachment)
Gets expiration timeout stamp from the SelectionKey
depending on its attachment |
long |
getTimeout()
|
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 ops)
Register a SelectableChannel on Selector . |
void |
register(SelectionKey key,
int selectionKeyOps)
Register a SelectionKey on Selector . |
void |
register(SelectionKey key,
long currentTime)
Attach a times out to the SelectionKey used to cancel idle connection. |
void |
setTimeout(long timeout)
Set expiration timeout for the SelectionKey . |
Methods inherited from class com.sun.grizzly.BaseSelectionKeyHandler |
---|
cancel, close, doAfterKeyCancel, doRegisterKey, getLogger, getSelectorHandler, notifyLocallyClose, notifyRemotlyClose, register, removeConnectionCloseHandler, setConnectionCloseHandler, setLogger, setSelectorHandler |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected long nextKeysExpiration
protected long timeout
Constructor Detail |
---|
public DefaultSelectionKeyHandler()
public DefaultSelectionKeyHandler(SelectorHandler selectorHandler)
Method Detail |
---|
public void copyTo(Copyable copy)
copyTo
in interface Copyable
copyTo
in class BaseSelectionKeyHandler
copy
- represents target object, where current object's content will be copiedpublic void process(SelectionKey key)
SelectionKey
process notification
process
in interface SelectionKeyHandler
process
in class BaseSelectionKeyHandler
key
- SelectionKey
to processpublic void postProcess(SelectionKey key)
SelectionKey
post process notification
postProcess
in interface SelectionKeyHandler
postProcess
in class BaseSelectionKeyHandler
key
- SelectionKey
to processpublic void register(Iterator<SelectionKey> keyIterator, int selectionKeyOps)
SelectionKey
s.
Note: After processing each SelectionKey
it should be
removed from Iterator
register
in interface SelectionKeyHandler
register
in class BaseSelectionKeyHandler
selectionKeyOps
- The interest set to apply when registering.
to registerpublic void register(SelectionKey key, int selectionKeyOps)
SelectionKey
on Selector
.
register
in interface SelectionKeyHandler
register
in class BaseSelectionKeyHandler
key
- SelectionKey
selectionKeyOps
- The interest set to apply when registering.
to registerprotected void doRegisterKey(SelectionKey key, int selectionKeyOps, long currentTime)
SelectionKey
to handle certain operations
public void register(SelectableChannel channel, int ops) throws ClosedChannelException
SelectableChannel
on Selector
.
register
in interface SelectionKeyHandler
register
in class BaseSelectionKeyHandler
channel
- SelectableChannel
ops
- The interest set to apply when registering.
to register
ClosedChannelException
public void register(SelectionKey key, long currentTime)
register
in interface SelectionKeyHandler
register
in class BaseSelectionKeyHandler
key
- SelectionKey
to registercurrentTime
- the System.currentTimeMillispublic 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
expire
in class BaseSelectionKeyHandler
key
- SelectionKey
to expirecurrentTime
- the System.currentTimeMillispublic void expire(Iterator<SelectionKey> iterator)
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
expire
in class BaseSelectionKeyHandler
iterator
- Iterator
of SelectionKey
s
to expirepublic long getTimeout()
public void setTimeout(long timeout)
SelectionKey
.
If during that defined timeout the client isn't pushing bytes
(or closing the connection), the SelectionKey will be expired
and its channel closed. The negative timeout value will let
SelectionKey
never expire.
timeout
- in secondsprotected void addExpirationStamp(SelectionKey key, long currentTime)
SelectionKey
depending on its attachment
{@link
- SelectionKey}protected void addExpirationStamp(SelectionKey key)
protected long getExpirationStamp(Object attachment)
SelectionKey
depending on its attachment
{@link
- SelectionKey}
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |