|
||||||||||
| 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)
Adds expiration timeout stamp to the SelectionKey
depending on its attachment |
void |
copyTo(Copyable copy)
|
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. |
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 SelectionKeys. |
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)
|
| Methods inherited from class com.sun.grizzly.BaseSelectionKeyHandler |
|---|
cancel, close, doAfterKeyCancel, doRegisterKey, getConnectionCloseHandler, getLogger, getSelectorHandler, notifyRemotlyClose, 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 CopyablecopyTo in class BaseSelectionKeyHandlerpublic void process(SelectionKey key)
SelectionKey process notification
process in interface SelectionKeyHandlerprocess in class BaseSelectionKeyHandlerkey - SelectionKey to processpublic void postProcess(SelectionKey key)
SelectionKey post process notification
postProcess in interface SelectionKeyHandlerpostProcess in class BaseSelectionKeyHandlerkey - SelectionKey to process
public void register(Iterator<SelectionKey> keyIterator,
int selectionKeyOps)
SelectionKeys.
Note: After processing each SelectionKey it should be
removed from Iterator
register in interface SelectionKeyHandlerregister in class BaseSelectionKeyHandlerselectionKeyOps - The interest set to apply when registering.
to register
public void register(SelectionKey key,
int selectionKeyOps)
SelectionKey on Selector.
register in interface SelectionKeyHandlerregister in class BaseSelectionKeyHandlerkey - SelectionKeyselectionKeyOps - The interest set to apply when registering.
to register
protected 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 SelectionKeyHandlerregister in class BaseSelectionKeyHandlerchannel - SelectableChannelops - The interest set to apply when registering.
to register
ClosedChannelException
public void register(SelectionKey key,
long currentTime)
register in interface SelectionKeyHandlerregister in class BaseSelectionKeyHandlerkey - SelectionKey to registercurrentTime - the System.currentTimeMillis
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 SelectionKeyHandlerexpire in class BaseSelectionKeyHandlerkey - 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 SelectionKeyHandlerexpire in class BaseSelectionKeyHandleriterator - Iterator of SelectionKeys
to expirepublic long getTimeout()
public void setTimeout(long timeout)
protected void addExpirationStamp(SelectionKey key)
SelectionKey
depending on its attachment
{@link - SelectionKey}
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||