org.apache.catalina.valves

## Class CometConnectionManagerValve

- java.lang.Object
- - org.apache.catalina.util.LifecycleBase
  - - org.apache.catalina.util.LifecycleMBeanBase
    - - org.apache.catalina.valves.ValveBase
      - - org.apache.catalina.valves.CometConnectionManagerValve

All Implemented Interfaces:
  EventListener, MBeanRegistration, HttpSessionListener, Contained, Lifecycle, LifecycleListener, Valve

    public class CometConnectionManagerValve
    extends ValveBase
    implements 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.

Author:
  Remy Maucherat

### Field Summary

Fields
`protected List<Request>` `cometRequests` List of current Comet connections.
`protected String` `cometRequestsAttribute` Name of session attribute used to store list of comet connections.
`protected static String` `info` The descriptive information related to this implementation.

### Fields inherited from class org.apache.catalina.valves.ValveBase

`asyncSupported, container, containerLog, next, sm`

### Fields inherited from class org.apache.catalina.util.LifecycleMBeanBase

`mserver`

### Fields inherited from interface org.apache.catalina.Lifecycle

`AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT`

### Constructor Summary

Constructors
Constructor and Description
`CometConnectionManagerValve()`

### Method Summary

Methods
`void` `event(Request request, Response response, CometEvent event)` Use events to update the connection state.
`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` `sessionCreated(HttpSessionEvent se)` Notification that a session was created.
`void` `sessionDestroyed(HttpSessionEvent se)` Notification that a session is about to be invalidated.
`protected void` `startInternal()` Start this component and implement the requirements of `LifecycleBase.startInternal()`.
`protected void` `stopInternal()` Stop this component and implement the requirements of `LifecycleBase.stopInternal()`.

### Methods inherited from class org.apache.catalina.valves.ValveBase

`backgroundProcess, getContainer, getDomainInternal, getNext, getObjectNameKeyProperties, initInternal, isAsyncSupported, setAsyncSupported, setContainer, setNext, toString`

### Methods inherited from class org.apache.catalina.util.LifecycleMBeanBase

`destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister`

### Methods inherited from class org.apache.catalina.util.LifecycleBase

`addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, init, removeLifecycleListener, setState, setState, start, stop`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### info

    protected static final String info

The descriptive information related to this implementation.

See Also:
  Constant Field Values

#### cometRequests

    protected final List<Request> cometRequests

List of current Comet connections.

#### cometRequestsAttribute

    protected final String cometRequestsAttribute

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

See Also:
  Constant Field Values

### Constructor Detail

#### CometConnectionManagerValve

    public CometConnectionManagerValve()

### Method Detail

#### startInternal

    protected void startInternal()
                          throws LifecycleException

Start this component and implement the requirements of `LifecycleBase.startInternal()`.

Overrides:
  `startInternal` in class `ValveBase`
Throws:
  `LifecycleException` - if this component detects a fatal error that prevents this component from being used

#### stopInternal

    protected void stopInternal()
                         throws LifecycleException

Stop this component and implement the requirements of `LifecycleBase.stopInternal()`.

Overrides:
  `stopInternal` in class `ValveBase`
Throws:
  `LifecycleException` - if this component detects a fatal error that prevents this component from being used

#### 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 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 IOException,
                       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:
  `IOException` - if an input/output error occurs
  `ServletException` - if a servlet error occurs

#### event

    public void event(Request request,
             Response response,
             CometEvent event)
               throws IOException,
                      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:
  `IOException` - if an input/output error occurs
  `ServletException` - if a servlet error occurs

#### sessionCreated

    public void sessionCreated(HttpSessionEvent se)

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

Specified by:
  `sessionCreated` in interface `HttpSessionListener`
Parameters:
  `se` - the notification event

#### sessionDestroyed

    public void sessionDestroyed(HttpSessionEvent se)

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

Specified by:
  `sessionDestroyed` in interface `HttpSessionListener`
Parameters:
  `se` - the notification event