org.glassfish.grizzly.utils
Class ActivityCheckFilter

java.lang.Object
  extended by org.glassfish.grizzly.filterchain.BaseFilter
      extended by org.glassfish.grizzly.utils.ActivityCheckFilter
All Implemented Interfaces:
Filter

public class ActivityCheckFilter
extends BaseFilter

The Filter is responsible for tracking Connection activity and closing Connection ones it becomes idle for certain amount of time. Unlike IdleTimeoutFilter, this Filter assumes Connection is idle, even if some event is being executed on it, so it really requires some action to be executed on Connection to reset the timeout.

Author:
Alexey Stashok
See Also:
IdleTimeoutFilter

Nested Class Summary
static interface ActivityCheckFilter.TimeoutHandler
           
 
Field Summary
static java.lang.String ACTIVE_ATTRIBUTE_NAME
           
 
Constructor Summary
protected ActivityCheckFilter(DelayedExecutor executor, DelayedExecutor.Worker<Connection> worker, long timeout, java.util.concurrent.TimeUnit timeoutUnit)
           
  ActivityCheckFilter(DelayedExecutor executor, long timeout, java.util.concurrent.TimeUnit timeoutUnit)
           
  ActivityCheckFilter(DelayedExecutor executor, long timeout, java.util.concurrent.TimeUnit timeoutUnit, ActivityCheckFilter.TimeoutHandler handler)
           
 
Method Summary
static DelayedExecutor createDefaultIdleDelayedExecutor()
           
static DelayedExecutor createDefaultIdleDelayedExecutor(long checkInterval, java.util.concurrent.TimeUnit checkIntervalUnit)
           
 long getTimeout(java.util.concurrent.TimeUnit timeunit)
           
 NextAction handleAccept(FilterChainContext ctx)
          Execute a unit of processing work to be performed, when server channel has accepted the client connection.
 NextAction handleClose(FilterChainContext ctx)
          Execute a unit of processing work to be performed, when connection has been closed.
 NextAction handleConnect(FilterChainContext ctx)
          Execute a unit of processing work to be performed, when channel gets connected.
 NextAction handleRead(FilterChainContext ctx)
          Execute a unit of processing work to be performed, when channel will become available for reading.
 NextAction handleWrite(FilterChainContext ctx)
          Execute a unit of processing work to be performed, when some data should be written on channel.
 
Methods inherited from class org.glassfish.grizzly.filterchain.BaseFilter
createContext, exceptionOccurred, getFilterChain, getIndex, handleEvent, onAdded, onFilterChainChanged, onRemoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTIVE_ATTRIBUTE_NAME

public static final java.lang.String ACTIVE_ATTRIBUTE_NAME
See Also:
Constant Field Values
Constructor Detail

ActivityCheckFilter

public ActivityCheckFilter(DelayedExecutor executor,
                           long timeout,
                           java.util.concurrent.TimeUnit timeoutUnit)

ActivityCheckFilter

public ActivityCheckFilter(DelayedExecutor executor,
                           long timeout,
                           java.util.concurrent.TimeUnit timeoutUnit,
                           ActivityCheckFilter.TimeoutHandler handler)

ActivityCheckFilter

protected ActivityCheckFilter(DelayedExecutor executor,
                              DelayedExecutor.Worker<Connection> worker,
                              long timeout,
                              java.util.concurrent.TimeUnit timeoutUnit)
Method Detail

handleAccept

public NextAction handleAccept(FilterChainContext ctx)
                        throws java.io.IOException
Description copied from class: BaseFilter
Execute a unit of processing work to be performed, when server channel has accepted the client connection. This Filter may either complete the required processing and return false, or delegate remaining processing to the next Filter in a FilterChain containing this Filter by returning true.

Specified by:
handleAccept in interface Filter
Overrides:
handleAccept in class BaseFilter
Parameters:
ctx - FilterChainContext
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
java.io.IOException

handleConnect

public NextAction handleConnect(FilterChainContext ctx)
                         throws java.io.IOException
Description copied from class: BaseFilter
Execute a unit of processing work to be performed, when channel gets connected. This Filter may either complete the required processing and return false, or delegate remaining processing to the next Filter in a FilterChain containing this Filter by returning true.

Specified by:
handleConnect in interface Filter
Overrides:
handleConnect in class BaseFilter
Parameters:
ctx - FilterChainContext
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
java.io.IOException

handleRead

public NextAction handleRead(FilterChainContext ctx)
                      throws java.io.IOException
Description copied from class: BaseFilter
Execute a unit of processing work to be performed, when channel will become available for reading. This Filter may either complete the required processing and return false, or delegate remaining processing to the next Filter in a FilterChain containing this Filter by returning true.

Specified by:
handleRead in interface Filter
Overrides:
handleRead in class BaseFilter
Parameters:
ctx - FilterChainContext
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
java.io.IOException

handleWrite

public NextAction handleWrite(FilterChainContext ctx)
                       throws java.io.IOException
Description copied from class: BaseFilter
Execute a unit of processing work to be performed, when some data should be written on channel. This Filter may either complete the required processing and return false, or delegate remaining processing to the next Filter in a FilterChain containing this Filter by returning true.

Specified by:
handleWrite in interface Filter
Overrides:
handleWrite in class BaseFilter
Parameters:
ctx - FilterChainContext
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
java.io.IOException

handleClose

public NextAction handleClose(FilterChainContext ctx)
                       throws java.io.IOException
Description copied from class: BaseFilter
Execute a unit of processing work to be performed, when connection has been closed. This Filter may either complete the required processing and return false, or delegate remaining processing to the next Filter in a FilterChain containing this Filter by returning true.

Specified by:
handleClose in interface Filter
Overrides:
handleClose in class BaseFilter
Parameters:
ctx - FilterChainContext
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
java.io.IOException

createDefaultIdleDelayedExecutor

public static DelayedExecutor createDefaultIdleDelayedExecutor()

createDefaultIdleDelayedExecutor

public static DelayedExecutor createDefaultIdleDelayedExecutor(long checkInterval,
                                                               java.util.concurrent.TimeUnit checkIntervalUnit)

getTimeout

public long getTimeout(java.util.concurrent.TimeUnit timeunit)


Copyright © 2011 Oracle Corpration. All Rights Reserved.