Package org.glassfish.grizzly.utils
Class ActivityCheckFilter
- java.lang.Object
-
- org.glassfish.grizzly.filterchain.BaseFilter
-
- org.glassfish.grizzly.utils.ActivityCheckFilter
-
- All Implemented Interfaces:
Filter
public class ActivityCheckFilter extends BaseFilter
The Filter is responsible for trackingConnectionactivity and closingConnectionones it becomes idle for certain amount of time. UnlikeIdleTimeoutFilter, this Filter assumesConnectionis idle, even if some event is being executed on it, so it really requires some action to be executed onConnectionto reset the timeout.- Author:
- Alexey Stashok
- See Also:
IdleTimeoutFilter
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceActivityCheckFilter.TimeoutHandler
-
Field Summary
Fields Modifier and Type Field Description static StringACTIVE_ATTRIBUTE_NAME
-
Constructor Summary
Constructors Modifier Constructor Description ActivityCheckFilter(DelayedExecutor executor, long timeout, TimeUnit timeoutUnit)ActivityCheckFilter(DelayedExecutor executor, long timeout, TimeUnit timeoutUnit, ActivityCheckFilter.TimeoutHandler handler)protectedActivityCheckFilter(DelayedExecutor executor, DelayedExecutor.Worker<Connection> worker, long timeout, TimeUnit timeoutUnit)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DelayedExecutorcreateDefaultIdleDelayedExecutor()static DelayedExecutorcreateDefaultIdleDelayedExecutor(long checkInterval, TimeUnit checkIntervalUnit)longgetTimeout(TimeUnit timeunit)NextActionhandleAccept(FilterChainContext ctx)Execute a unit of processing work to be performed, when server channel has accepted the client connection.NextActionhandleClose(FilterChainContext ctx)Execute a unit of processing work to be performed, when connection has been closed.NextActionhandleConnect(FilterChainContext ctx)Execute a unit of processing work to be performed, when channel gets connected.NextActionhandleRead(FilterChainContext ctx)Execute a unit of processing work to be performed, when channel will become available for reading.NextActionhandleWrite(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, handleEvent, onAdded, onFilterChainChanged, onRemoved, toString
-
-
-
-
Field Detail
-
ACTIVE_ATTRIBUTE_NAME
public static final String ACTIVE_ATTRIBUTE_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ActivityCheckFilter
public ActivityCheckFilter(DelayedExecutor executor, long timeout, TimeUnit timeoutUnit)
-
ActivityCheckFilter
public ActivityCheckFilter(DelayedExecutor executor, long timeout, TimeUnit timeoutUnit, ActivityCheckFilter.TimeoutHandler handler)
-
ActivityCheckFilter
protected ActivityCheckFilter(DelayedExecutor executor, DelayedExecutor.Worker<Connection> worker, long timeout, TimeUnit timeoutUnit)
-
-
Method Detail
-
handleAccept
public NextAction handleAccept(FilterChainContext ctx) throws IOException
Description copied from class:BaseFilterExecute a unit of processing work to be performed, when server channel has accepted the client connection. ThisFiltermay either complete the required processing and return false, or delegate remaining processing to the nextFilterin aFilterChaincontaining thisFilterby returning true.- Specified by:
handleAcceptin interfaceFilter- Overrides:
handleAcceptin classBaseFilter- Parameters:
ctx-FilterChainContext- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
handleConnect
public NextAction handleConnect(FilterChainContext ctx) throws IOException
Description copied from class:BaseFilterExecute a unit of processing work to be performed, when channel gets connected. ThisFiltermay either complete the required processing and return false, or delegate remaining processing to the nextFilterin aFilterChaincontaining thisFilterby returning true.- Specified by:
handleConnectin interfaceFilter- Overrides:
handleConnectin classBaseFilter- Parameters:
ctx-FilterChainContext- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
handleRead
public NextAction handleRead(FilterChainContext ctx) throws IOException
Description copied from class:BaseFilterExecute a unit of processing work to be performed, when channel will become available for reading. ThisFiltermay either complete the required processing and return false, or delegate remaining processing to the nextFilterin aFilterChaincontaining thisFilterby returning true.- Specified by:
handleReadin interfaceFilter- Overrides:
handleReadin classBaseFilter- Parameters:
ctx-FilterChainContext- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
handleWrite
public NextAction handleWrite(FilterChainContext ctx) throws IOException
Description copied from class:BaseFilterExecute a unit of processing work to be performed, when some data should be written on channel. ThisFiltermay either complete the required processing and return false, or delegate remaining processing to the nextFilterin aFilterChaincontaining thisFilterby returning true.- Specified by:
handleWritein interfaceFilter- Overrides:
handleWritein classBaseFilter- Parameters:
ctx-FilterChainContext- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
handleClose
public NextAction handleClose(FilterChainContext ctx) throws IOException
Description copied from class:BaseFilterExecute a unit of processing work to be performed, when connection has been closed. ThisFiltermay either complete the required processing and return false, or delegate remaining processing to the nextFilterin aFilterChaincontaining thisFilterby returning true.- Specified by:
handleClosein interfaceFilter- Overrides:
handleClosein classBaseFilter- Parameters:
ctx-FilterChainContext- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
createDefaultIdleDelayedExecutor
public static DelayedExecutor createDefaultIdleDelayedExecutor()
-
createDefaultIdleDelayedExecutor
public static DelayedExecutor createDefaultIdleDelayedExecutor(long checkInterval, TimeUnit checkIntervalUnit)
-
getTimeout
public long getTimeout(TimeUnit timeunit)
-
-