Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.gisgraphy.webapp.listener
Class UserCounterListener

    java.lang.Object
      com.gisgraphy.webapp.listener.UserCounterListener

All Implemented Interfaces:
  java.util.EventListener, javax.servlet.http.HttpSessionAttributeListener, javax.servlet.ServletContextListener

    public class UserCounterListener

extends java.lang.Object
implements javax.servlet.ServletContextListener, javax.servlet.http.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 java.lang.String` | `COUNT_KEY` Name of user counter variable
`static java.lang.String` | `EVENT_KEY` The default event we're looking to trap.
`static java.lang.String` | `USERS_KEY` Name of users Set in the ServletContext

Constructor Summary
`UserCounterListener()`

Method Summary
`void` | `attributeAdded(javax.servlet.http.HttpSessionBindingEvent event)` This method is designed to catch when user's login and record their name
`void` | `attributeRemoved(javax.servlet.http.HttpSessionBindingEvent event)` When user's logout, remove their name from the hashMap
`void` | `attributeReplaced(javax.servlet.http.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(javax.servlet.ServletContextEvent event)` Set the servletContext, users and counter to null
`void` | `contextInitialized(javax.servlet.ServletContextEvent sce)` Initialize the context

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 java.lang.String COUNT_KEY

  Name of user counter variable

  See Also:
    Constant Field Values

### USERS_KEY

    public static final java.lang.String USERS_KEY

  Name of users Set in the ServletContext

  See Also:
    Constant Field Values

### EVENT_KEY

    public static final java.lang.String EVENT_KEY

  The default event we're looking to trap.

  See Also:
    Constant Field Values

Constructor Detail

### UserCounterListener

    public UserCounterListener()

Method Detail

### contextInitialized

    public void contextInitialized(javax.servlet.ServletContextEvent sce)

  Initialize the context

  Specified by:
    `contextInitialized` in interface `javax.servlet.ServletContextListener`
  Parameters:
    `sce` - the event

### contextDestroyed

    public void contextDestroyed(javax.servlet.ServletContextEvent event)

  Set the servletContext, users and counter to null

  Specified by:
    `contextDestroyed` in interface `javax.servlet.ServletContextListener`
  Parameters:
    `event` - The servletContextEvent

### attributeAdded

    public void attributeAdded(javax.servlet.http.HttpSessionBindingEvent event)

  This method is designed to catch when user's login and record their name

  Specified by:
    `attributeAdded` in interface `javax.servlet.http.HttpSessionAttributeListener`
  Parameters:
    `event` - the event to process
  See Also:
    `HttpSessionAttributeListener.attributeAdded(javax.servlet.http.HttpSessionBindingEvent)`

### attributeRemoved

    public void attributeRemoved(javax.servlet.http.HttpSessionBindingEvent event)

  When user's logout, remove their name from the hashMap

  Specified by:
    `attributeRemoved` in interface `javax.servlet.http.HttpSessionAttributeListener`
  Parameters:
    `event` - the session binding event
  See Also:
    `HttpSessionAttributeListener.attributeRemoved(javax.servlet.http.HttpSessionBindingEvent)`

### attributeReplaced

    public void attributeReplaced(javax.servlet.http.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 `javax.servlet.http.HttpSessionAttributeListener`
  Parameters:
    `event` - the session binding event
  See Also:
    `HttpSessionAttributeListener.attributeReplaced(javax.servlet.http.HttpSessionBindingEvent)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009. All Rights Reserved.