com.ora.jsp.servlets
Class SessionCounterListener

java.lang.Object
  extended bycom.ora.jsp.servlets.SessionCounterListener
All Implemented Interfaces:
java.util.EventListener, javax.servlet.http.HttpSessionListener

public class SessionCounterListener
extends java.lang.Object
implements javax.servlet.http.HttpSessionListener

This class manages a counter for the number of active sessions in an application. The counter is made available to the rest of the application as a servlet context attribute of type int[] with one element.

Version:
1.0
Author:
Hans Bergsten, Gefion software

Field Summary
private static java.lang.String COUNTER_ATTR
           
 
Constructor Summary
SessionCounterListener()
           
 
Method Summary
private  int[] getCounter(javax.servlet.http.HttpSessionEvent hse)
          Returns the counter held in the session scope, or a new counter if it doesn't exist.
 void sessionCreated(javax.servlet.http.HttpSessionEvent hse)
          Increments the counter held in the session scope.
 void sessionDestroyed(javax.servlet.http.HttpSessionEvent hse)
          Decrements the counter held in the session scope.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COUNTER_ATTR

private static final java.lang.String COUNTER_ATTR
See Also:
Constant Field Values
Constructor Detail

SessionCounterListener

public SessionCounterListener()
Method Detail

sessionCreated

public void sessionCreated(javax.servlet.http.HttpSessionEvent hse)
Increments the counter held in the session scope.

Specified by:
sessionCreated in interface javax.servlet.http.HttpSessionListener

sessionDestroyed

public void sessionDestroyed(javax.servlet.http.HttpSessionEvent hse)
Decrements the counter held in the session scope.

Specified by:
sessionDestroyed in interface javax.servlet.http.HttpSessionListener

getCounter

private int[] getCounter(javax.servlet.http.HttpSessionEvent hse)
Returns the counter held in the session scope, or a new counter if it doesn't exist.