org.appfuse.webapp.listener
Class UserCounterListener

java.lang.Object
  extended by org.appfuse.webapp.listener.UserCounterListener
All Implemented Interfaces:
EventListener, HttpSessionAttributeListener, ServletContextListener

public class UserCounterListener
extends Object
implements ServletContextListener, HttpSessionAttributeListener

UserCounterListener class used to count the current number of active users for the applications. Does this by counting how many user objects are stuffed into the session. It Also grabs these users and exposes them in the servlet context.

Author:
Matt Raible

Field Summary
static String COUNT_KEY
           
static String EVENT_KEY
           
static String USERS_KEY
           
 
Constructor Summary
UserCounterListener()
           
 
Method Summary
 void attributeAdded(HttpSessionBindingEvent event)
          This method is designed to catch when user's login and record their name
 void attributeRemoved(HttpSessionBindingEvent event)
          When user's logout, remove their name from the hashMap
 void attributeReplaced(HttpSessionBindingEvent event)
          Needed for Acegi Security 1.0, as it adds an anonymous user to the session and then replaces it after authentication.
 void contextDestroyed(ServletContextEvent event)
           
 void contextInitialized(ServletContextEvent sce)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COUNT_KEY

public static final String COUNT_KEY
See Also:
Constant Field Values

USERS_KEY

public static final String USERS_KEY
See Also:
Constant Field Values

EVENT_KEY

public static final String EVENT_KEY
See Also:
Constant Field Values
Constructor Detail

UserCounterListener

public UserCounterListener()
Method Detail

contextInitialized

public void contextInitialized(ServletContextEvent sce)
Specified by:
contextInitialized in interface ServletContextListener

contextDestroyed

public void contextDestroyed(ServletContextEvent event)
Specified by:
contextDestroyed in interface ServletContextListener

attributeAdded

public void attributeAdded(HttpSessionBindingEvent event)
This method is designed to catch when user's login and record their name

Specified by:
attributeAdded in interface HttpSessionAttributeListener
See Also:
HttpSessionAttributeListener.attributeAdded(javax.servlet.http.HttpSessionBindingEvent)

attributeRemoved

public void attributeRemoved(HttpSessionBindingEvent event)
When user's logout, remove their name from the hashMap

Specified by:
attributeRemoved in interface HttpSessionAttributeListener
See Also:
HttpSessionAttributeListener.attributeRemoved(javax.servlet.http.HttpSessionBindingEvent)

attributeReplaced

public void attributeReplaced(HttpSessionBindingEvent event)
Needed for Acegi Security 1.0, as it adds an anonymous user to the session and then replaces it after authentication. http://forum.springframework.org/showthread.php?p=63593

Specified by:
attributeReplaced in interface HttpSessionAttributeListener
See Also:
HttpSessionAttributeListener.attributeReplaced(javax.servlet.http.HttpSessionBindingEvent)


Copyright � 2002-2006