## org.apache.catalina.valves
Class CometConnectionManagerValve

    java.lang.Object
      org.apache.catalina.valves.ValveBase
          org.apache.catalina.valves.CometConnectionManagerValve

All Implemented Interfaces:
  java.util.EventListener, javax.management.MBeanRegistration, javax.servlet.http.HttpSessionListener, Contained, Lifecycle, LifecycleListener, Valve

    public class CometConnectionManagerValve

extends ValveBase
implements Lifecycle, javax.servlet.http.HttpSessionListener, LifecycleListener

Implementation of a Valve that tracks Comet connections, and closes them when the associated session expires or the webapp is reloaded.

This Valve should be attached to a Context.

Version:
  $Revision: 769328 $ $Date: 2009-04-28 12:39:24 +0200 (Tue, 28 Apr 2009) $
Author:
  Remy Maucherat

Field Summary
`protected java.util.List<Request>` `cometRequests` List of current Coment connections.
`protected java.lang.String` `cometRequestsAttribute` Name of session attribute used to store list of comet connections.
`protected static java.lang.String` `info` The descriptive information related to this implementation.
`protected LifecycleSupport` `lifecycle` The lifecycle event support for this component.
`protected StringManager` `sm` The string manager for this package.
`protected boolean` `started` Has this component been started yet?

Fields inherited from class org.apache.catalina.valves.ValveBase
`container, containerLog, controller, domain, mserver, next, oname`

Fields inherited from interface org.apache.catalina.Lifecycle
`AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, DESTROY_EVENT, INIT_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT`

Constructor Summary
`CometConnectionManagerValve()`

Method Summary
`void` `addLifecycleListener(LifecycleListener listener)` Add a lifecycle event listener to this component.
`void` `event(Request request, Response response, CometEvent event)` Use events to update the connection state.
`LifecycleListener[]` `findLifecycleListeners()` Get the lifecycle listeners associated with this lifecycle.
`java.lang.String` `getInfo()` Return descriptive information about this Valve implementation.
`void` `invoke(Request request, Response response)` Register requests for tracking, whenever needed.
`void` `lifecycleEvent(LifecycleEvent event)` Acknowledge the occurrence of the specified event.
`void` `removeLifecycleListener(LifecycleListener listener)` Remove a lifecycle event listener from this component.
`void` `sessionCreated(javax.servlet.http.HttpSessionEvent se)` Notification that a session was created.
`void` `sessionDestroyed(javax.servlet.http.HttpSessionEvent se)` Notification that a session is about to be invalidated.
`void` `start()` Prepare for the beginning of active use of the public methods of this component.
`void` `stop()` Gracefully terminate the active use of the public methods of this component.

Methods inherited from class org.apache.catalina.valves.ValveBase
`backgroundProcess, createObjectName, getContainer, getContainerName, getController, getDomain, getNext, getObjectName, getParentName, postDeregister, postRegister, preDeregister, preRegister, setContainer, setController, setNext, setObjectName, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### info

    protected static final java.lang.String info

  The descriptive information related to this implementation.

  See Also:
    Constant Field Values

### sm

    protected StringManager sm

  The string manager for this package.

### lifecycle

    protected LifecycleSupport lifecycle

  The lifecycle event support for this component.

### started

    protected boolean started

  Has this component been started yet?

### cometRequests

    protected java.util.List<Request> cometRequests

  List of current Coment connections.

### cometRequestsAttribute

    protected java.lang.String cometRequestsAttribute

  Name of session attribute used to store list of comet connections.

Constructor Detail

### CometConnectionManagerValve

    public CometConnectionManagerValve()

Method Detail

### addLifecycleListener

    public void addLifecycleListener(LifecycleListener listener)

  Add a lifecycle event listener to this component.

  Specified by:
    `addLifecycleListener` in interface `Lifecycle`
  Parameters:
    `listener` - The listener to add

### findLifecycleListeners

    public LifecycleListener[] findLifecycleListeners()

  Get the lifecycle listeners associated with this lifecycle. If this Lifecycle has no listeners registered, a zero-length array is returned.

  Specified by:
    `findLifecycleListeners` in interface `Lifecycle`

### removeLifecycleListener

    public void removeLifecycleListener(LifecycleListener listener)

  Remove a lifecycle event listener from this component.

  Specified by:
    `removeLifecycleListener` in interface `Lifecycle`
  Parameters:
    `listener` - The listener to add

### start

    public void start()
               throws LifecycleException

  Prepare for the beginning of active use of the public methods of this component. This method should be called after `configure()`, and before any of the public methods of the component are utilized.

  Specified by:
    `start` in interface `Lifecycle`
  Throws:
    `LifecycleException` - if this component detects a fatal error that prevents this component from being used

### stop

    public void stop()
              throws LifecycleException

  Gracefully terminate the active use of the public methods of this component. This method should be the last one called on a given instance of this component.

  Specified by:
    `stop` in interface `Lifecycle`
  Throws:
    `LifecycleException` - if this component detects a fatal error that needs to be reported

### lifecycleEvent

    public void lifecycleEvent(LifecycleEvent event)

  Description copied from interface: `LifecycleListener`
  Acknowledge the occurrence of the specified event.

  Specified by:
    `lifecycleEvent` in interface `LifecycleListener`
  Parameters:
    `event` - LifecycleEvent that has occurred

### getInfo

    public java.lang.String getInfo()

  Return descriptive information about this Valve implementation.

  Specified by:
    `getInfo` in interface `Valve`
  Overrides:
    `getInfo` in class `ValveBase`

### invoke

    public void invoke(Request request,
                       Response response)
                throws java.io.IOException,
                       javax.servlet.ServletException

  Register requests for tracking, whenever needed.

  Specified by:
    `invoke` in interface `Valve`
  Specified by:
    `invoke` in class `ValveBase`
  Parameters:
    `request` - The servlet request to be processed
    `response` - The servlet response to be created
  Throws:
    `java.io.IOException` - if an input/output error occurs
    `javax.servlet.ServletException` - if a servlet error occurs

### event

    public void event(Request request,
                      Response response,
                      CometEvent event)
               throws java.io.IOException,
                      javax.servlet.ServletException

  Use events to update the connection state.

  Specified by:
    `event` in interface `Valve`
  Overrides:
    `event` in class `ValveBase`
  Parameters:
    `request` - The servlet request to be processed
    `response` - The servlet response to be created
  Throws:
    `java.io.IOException` - if an input/output error occurs
    `javax.servlet.ServletException` - if a servlet error occurs

### sessionCreated

    public void sessionCreated(javax.servlet.http.HttpSessionEvent se)

  Description copied from interface: `javax.servlet.http.HttpSessionListener`
  Notification that a session was created.

  Specified by:
    `sessionCreated` in interface `javax.servlet.http.HttpSessionListener`
  Parameters:
    `se` - the notification event

### sessionDestroyed

    public void sessionDestroyed(javax.servlet.http.HttpSessionEvent se)

  Description copied from interface: `javax.servlet.http.HttpSessionListener`
  Notification that a session is about to be invalidated.

  Specified by:
    `sessionDestroyed` in interface `javax.servlet.http.HttpSessionListener`
  Parameters:
    `se` - the notification event

Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.