com.sun.grizzly.utils
Class IdleTimeoutFilter

java.lang.Object
  extended by com.sun.grizzly.filterchain.FilterAdapter
      extended by com.sun.grizzly.utils.IdleTimeoutFilter
All Implemented Interfaces:
Filter

public class IdleTimeoutFilter
extends FilterAdapter

Author:
oleksiys

Nested Class Summary
 class IdleTimeoutFilter.TimeoutChecker
           
 
Field Summary
static String IDLE_ATTRIBUTE_NAME
           
static Attribute<Long> idleAttribute
           
static long UNLIMITED_TIMEOUT
           
static long UNSET_TIMEOUT
           
 
Constructor Summary
IdleTimeoutFilter(long timeout, TimeUnit timeunit)
           
IdleTimeoutFilter(long timeout, TimeUnit timeunit, ScheduledExecutorService scheduledThreadPool)
           
 
Method Summary
protected  void addConnection(Connection connection)
           
protected  void clearTimeout(Connection connection)
           
protected  long getConnectionTimeout(Connection connection)
           
 Long getExpirationTime(Connection connection, TimeUnit timeunit)
           
 ScheduledExecutorService getScheduledThreadPool()
           
 long getTimeout(TimeUnit timeunit)
           
 NextAction handleRead(FilterChainContext ctx, NextAction nextAction)
          Execute a unit of processing work to be performed, when channel will become available for reading.
 NextAction handleWrite(FilterChainContext ctx, NextAction nextAction)
          Execute a unit of processing work to be performed, when channel will become available for writing.
 void initialize()
           
 boolean isHandleAccepted()
           
 boolean isHandleConnected()
           
 NextAction postAccept(FilterChainContext ctx, NextAction nextAction)
          Execute any cleanup activities, such as releasing resources that were acquired during the execution of Filter#handleAccept(com.sun.grizzly.FilterChainContext) method of this Filter instance.
 NextAction postConnect(FilterChainContext ctx, NextAction nextAction)
          Execute any cleanup activities, such as releasing resources that were acquired during the execution of Filter#handleConnect(com.sun.grizzly.FilterChainContext) method of this Filter instance.
 NextAction postRead(FilterChainContext ctx, NextAction nextAction)
          Execute any cleanup activities, such as releasing resources that were acquired during the execution of Filter#handleRead(com.sun.grizzly.FilterChainContext) method of this Filter instance.
 NextAction postWrite(FilterChainContext ctx, NextAction nextAction)
          Execute any cleanup activities, such as releasing resources that were acquired during the execution of Filter#handleWrite(com.sun.grizzly.FilterChainContext) method of this Filter instance.
protected  void registerChecker()
           
 void release()
           
protected  void resetTimeout(Connection connection)
           
protected  void setConnectionTimeout(Connection connection, long timeout)
           
 void setExpirationTime(Connection connection, long timeout, TimeUnit timeunit)
           
 void setHandleAccepted(boolean isHandleAccepted)
           
 void setHandleConnected(boolean isHandleConnected)
           
 void setScheduledThreadPool(ScheduledExecutorService scheduledThreadPool)
           
 void setTimeout(long timeout, TimeUnit timeunit)
           
 
Methods inherited from class com.sun.grizzly.filterchain.FilterAdapter
exceptionOccurred, getFilterChain, getIndex, handleAccept, handleClose, handleConnect, isIndexable, postClose, setIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNLIMITED_TIMEOUT

public static final long UNLIMITED_TIMEOUT
See Also:
Constant Field Values

UNSET_TIMEOUT

public static final long UNSET_TIMEOUT
See Also:
Constant Field Values

IDLE_ATTRIBUTE_NAME

public static final String IDLE_ATTRIBUTE_NAME
See Also:
Constant Field Values

idleAttribute

public static Attribute<Long> idleAttribute
Constructor Detail

IdleTimeoutFilter

public IdleTimeoutFilter(long timeout,
                         TimeUnit timeunit)

IdleTimeoutFilter

public IdleTimeoutFilter(long timeout,
                         TimeUnit timeunit,
                         ScheduledExecutorService scheduledThreadPool)
Method Detail

getScheduledThreadPool

public ScheduledExecutorService getScheduledThreadPool()

setScheduledThreadPool

public void setScheduledThreadPool(ScheduledExecutorService scheduledThreadPool)

getTimeout

public long getTimeout(TimeUnit timeunit)

setTimeout

public void setTimeout(long timeout,
                       TimeUnit timeunit)

isHandleAccepted

public boolean isHandleAccepted()

setHandleAccepted

public void setHandleAccepted(boolean isHandleAccepted)

isHandleConnected

public boolean isHandleConnected()

setHandleConnected

public void setHandleConnected(boolean isHandleConnected)

handleRead

public NextAction handleRead(FilterChainContext ctx,
                             NextAction nextAction)
                      throws IOException
Description copied from class: FilterAdapter
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 FilterAdapter
Parameters:
ctx - FilterChainContext
nextAction - default NextAction, which Filter could change in order to control how FilterChain will continue the execution
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
IOException

handleWrite

public NextAction handleWrite(FilterChainContext ctx,
                              NextAction nextAction)
                       throws IOException
Description copied from class: FilterAdapter
Execute a unit of processing work to be performed, when channel will become available for writing. 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 FilterAdapter
Parameters:
ctx - FilterChainContext
nextAction - default NextAction, which Filter could change in order to control how FilterChain will continue the execution
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
IOException

postRead

public NextAction postRead(FilterChainContext ctx,
                           NextAction nextAction)
                    throws IOException
Description copied from class: FilterAdapter
Execute any cleanup activities, such as releasing resources that were acquired during the execution of Filter#handleRead(com.sun.grizzly.FilterChainContext) method of this Filter instance.

Specified by:
postRead in interface Filter
Overrides:
postRead in class FilterAdapter
Parameters:
ctx - FilterChainContext
nextAction - default NextAction, which Filter could change in order to control how FilterChain will continue the execution
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
IOException

postWrite

public NextAction postWrite(FilterChainContext ctx,
                            NextAction nextAction)
                     throws IOException
Description copied from class: FilterAdapter
Execute any cleanup activities, such as releasing resources that were acquired during the execution of Filter#handleWrite(com.sun.grizzly.FilterChainContext) method of this Filter instance.

Specified by:
postWrite in interface Filter
Overrides:
postWrite in class FilterAdapter
Parameters:
ctx - FilterChainContext
nextAction - default NextAction, which Filter could change in order to control how FilterChain will continue the execution
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
IOException

postAccept

public NextAction postAccept(FilterChainContext ctx,
                             NextAction nextAction)
                      throws IOException
Description copied from class: FilterAdapter
Execute any cleanup activities, such as releasing resources that were acquired during the execution of Filter#handleAccept(com.sun.grizzly.FilterChainContext) method of this Filter instance.

Specified by:
postAccept in interface Filter
Overrides:
postAccept in class FilterAdapter
Parameters:
ctx - FilterChainContext
nextAction - default NextAction, which Filter could change in order to control how FilterChain will continue the execution
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
IOException

postConnect

public NextAction postConnect(FilterChainContext ctx,
                              NextAction nextAction)
                       throws IOException
Description copied from class: FilterAdapter
Execute any cleanup activities, such as releasing resources that were acquired during the execution of Filter#handleConnect(com.sun.grizzly.FilterChainContext) method of this Filter instance.

Specified by:
postConnect in interface Filter
Overrides:
postConnect in class FilterAdapter
Parameters:
ctx - FilterChainContext
nextAction - default NextAction, which Filter could change in order to control how FilterChain will continue the execution
Returns:
NextAction instruction for FilterChain, how it should continue the execution
Throws:
IOException

initialize

public void initialize()

release

public void release()

registerChecker

protected void registerChecker()

addConnection

protected void addConnection(Connection connection)

clearTimeout

protected void clearTimeout(Connection connection)

resetTimeout

protected void resetTimeout(Connection connection)

getConnectionTimeout

protected long getConnectionTimeout(Connection connection)

setConnectionTimeout

protected void setConnectionTimeout(Connection connection,
                                    long timeout)

getExpirationTime

public Long getExpirationTime(Connection connection,
                              TimeUnit timeunit)

setExpirationTime

public void setExpirationTime(Connection connection,
                              long timeout,
                              TimeUnit timeunit)


Copyright © 2009 SUN Microsystems. All Rights Reserved.