public class UserCounterListener extends Object implements javax.servlet.ServletContextListener, javax.servlet.http.HttpSessionAttributeListener
Modifier and Type | Field and Description |
---|---|
static String |
COUNT_KEY
Name of user counter variable
|
static String |
EVENT_KEY
The default event we're looking to trap.
|
static String |
USERS_KEY
Name of users Set in the ServletContext
|
Constructor and Description |
---|
UserCounterListener() |
Modifier and Type | Method and Description |
---|---|
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
|
public static final String COUNT_KEY
public static final String USERS_KEY
public static final String EVENT_KEY
public void contextInitialized(javax.servlet.ServletContextEvent sce)
contextInitialized
in interface javax.servlet.ServletContextListener
sce
- the eventpublic void contextDestroyed(javax.servlet.ServletContextEvent event)
contextDestroyed
in interface javax.servlet.ServletContextListener
event
- The servletContextEventpublic void attributeAdded(javax.servlet.http.HttpSessionBindingEvent event)
attributeAdded
in interface javax.servlet.http.HttpSessionAttributeListener
event
- the event to processHttpSessionAttributeListener.attributeAdded(javax.servlet.http.HttpSessionBindingEvent)
public void attributeRemoved(javax.servlet.http.HttpSessionBindingEvent event)
attributeRemoved
in interface javax.servlet.http.HttpSessionAttributeListener
event
- the session binding eventHttpSessionAttributeListener.attributeRemoved(javax.servlet.http.HttpSessionBindingEvent)
public void attributeReplaced(javax.servlet.http.HttpSessionBindingEvent event)
attributeReplaced
in interface javax.servlet.http.HttpSessionAttributeListener
event
- the session binding eventHttpSessionAttributeListener.attributeReplaced(javax.servlet.http.HttpSessionBindingEvent)
Copyright © 2015. All rights reserved.