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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Set<org.glassfish.grizzly.Connection>
    Returns the Set of currently active Connections.
    int
    Returns the total number of connections ever created by the Transport
    org.glassfish.grizzly.filterchain.NextAction
    handleAccept(org.glassfish.grizzly.filterchain.FilterChainContext ctx)
    Method is called, when new Connection was accepted by a Transport
    org.glassfish.grizzly.filterchain.NextAction
    handleClose(org.glassfish.grizzly.filterchain.FilterChainContext ctx)
    Method is called, when the Connection is getting closed
    org.glassfish.grizzly.filterchain.NextAction
    handleConnect(org.glassfish.grizzly.filterchain.FilterChainContext ctx)
    Method is called, when new client Connection was connected to some endpoint

    Methods inherited from class org.glassfish.grizzly.filterchain.BaseFilter

    createContext, exceptionOccurred, handleEvent, handleRead, handleWrite, onAdded, onFilterChainChanged, onRemoved, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 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 new Connection was accepted by a Transport
      Specified by:
      handleAccept in interface org.glassfish.grizzly.filterchain.Filter
      Overrides:
      handleAccept in class org.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 client Connection was connected to some endpoint
      Specified by:
      handleConnect in interface org.glassfish.grizzly.filterchain.Filter
      Overrides:
      handleConnect in class org.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 the Connection is getting closed
      Specified by:
      handleClose in interface org.glassfish.grizzly.filterchain.Filter
      Overrides:
      handleClose in class org.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 the Transport
      Returns:
      the total number of connections ever created by the Transport
    • getActiveConnections

      public Set<org.glassfish.grizzly.Connection> getActiveConnections()
      Returns the Set of currently active Connections.
      Returns:
      the Set of currently active Connections