Class LifeCycleFilter
java.lang.Object
org.glassfish.grizzly.filterchain.BaseFilter
org.glassfish.grizzly.samples.lifecycle.LifeCycleFilter
- All Implemented Interfaces:
org.glassfish.grizzly.filterchain.Filter
public class LifeCycleFilter
extends org.glassfish.grizzly.filterchain.BaseFilter
Sample
Filter, which tracks the connections
lifecycle. The new connections could be either accepted if we have server,
or connected, if we establish client connection.- Author:
- Alexey Stashok
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSet<org.glassfish.grizzly.Connection>Returns theSetof currently activeConnections.intReturns the total number of connections ever created by theTransportorg.glassfish.grizzly.filterchain.NextActionhandleAccept(org.glassfish.grizzly.filterchain.FilterChainContext ctx) Method is called, when newConnectionwas accepted by aTransportorg.glassfish.grizzly.filterchain.NextActionhandleClose(org.glassfish.grizzly.filterchain.FilterChainContext ctx) Method is called, when theConnectionis getting closedorg.glassfish.grizzly.filterchain.NextActionhandleConnect(org.glassfish.grizzly.filterchain.FilterChainContext ctx) Method is called, when new clientConnectionwas connected to some endpointMethods inherited from class org.glassfish.grizzly.filterchain.BaseFilter
createContext, exceptionOccurred, handleEvent, handleRead, handleWrite, onAdded, onFilterChainChanged, onRemoved, toString
-
Constructor Details
-
LifeCycleFilter
public LifeCycleFilter()
-
-
Method Details
-
handleAccept
public org.glassfish.grizzly.filterchain.NextAction handleAccept(org.glassfish.grizzly.filterchain.FilterChainContext ctx) throws IOException Method is called, when newConnectionwas accepted by aTransport- Specified by:
handleAcceptin interfaceorg.glassfish.grizzly.filterchain.Filter- Overrides:
handleAcceptin classorg.glassfish.grizzly.filterchain.BaseFilter- Parameters:
ctx- the filter chain context- Returns:
- the next action to be executed by chain
- Throws:
IOException
-
handleConnect
public org.glassfish.grizzly.filterchain.NextAction handleConnect(org.glassfish.grizzly.filterchain.FilterChainContext ctx) throws IOException Method is called, when new clientConnectionwas connected to some endpoint- Specified by:
handleConnectin interfaceorg.glassfish.grizzly.filterchain.Filter- Overrides:
handleConnectin classorg.glassfish.grizzly.filterchain.BaseFilter- Parameters:
ctx- the filter chain context- Returns:
- the next action to be executed by chain
- Throws:
IOException
-
handleClose
public org.glassfish.grizzly.filterchain.NextAction handleClose(org.glassfish.grizzly.filterchain.FilterChainContext ctx) throws IOException Method is called, when theConnectionis getting closed- Specified by:
handleClosein interfaceorg.glassfish.grizzly.filterchain.Filter- Overrides:
handleClosein classorg.glassfish.grizzly.filterchain.BaseFilter- Parameters:
ctx- the filter chain context- Returns:
- the next action to be executed by chain
- Throws:
IOException
-
getTotalConnections
public int getTotalConnections()Returns the total number of connections ever created by theTransport- Returns:
- the total number of connections ever
created by the
Transport
-
getActiveConnections
Returns theSetof currently activeConnections.- Returns:
- the
Setof currently activeConnections
-