public class SessionRegistryImpl extends Object implements SessionRegistry, ApplicationListener<SessionDestroyedEvent>
SessionRegistry
which listens for SessionDestroyedEvents
published in the Spring application context.
For this class to function correctly in a web application, it is important that you register an
HttpSessionEventPublisher
in the web.xml file so that this class is notified of sessions that expire.
| Modifier and Type | Field and Description |
|---|---|
protected org.apache.commons.logging.Log |
logger |
| Constructor and Description |
|---|
SessionRegistryImpl() |
| Modifier and Type | Method and Description |
|---|---|
List<Object> |
getAllPrincipals()
Obtains all the known principals in the
SessionRegistry. |
List<SessionInformation> |
getAllSessions(Object principal,
boolean includeExpiredSessions)
Obtains all the known sessions for the specified principal.
|
SessionInformation |
getSessionInformation(String sessionId)
Obtains the session information for the specified
sessionId. |
void |
onApplicationEvent(SessionDestroyedEvent event) |
void |
refreshLastRequest(String sessionId)
Updates the given
sessionId so its last request time is equal to the present date and time. |
void |
registerNewSession(String sessionId,
Object principal)
Registers a new session for the specified principal.
|
void |
removeSessionInformation(String sessionId)
Deletes all the session information being maintained for the specified
sessionId. |
public List<Object> getAllPrincipals()
SessionRegistrySessionRegistry.getAllPrincipals in interface SessionRegistrySessionRegistry.getAllSessions(Object, boolean).public List<SessionInformation> getAllSessions(Object principal, boolean includeExpiredSessions)
SessionRegistrygetAllSessions in interface SessionRegistryprincipal - to locate sessions for (should never be null)includeExpiredSessions - if true, the returned sessions will also include those that have
expired for the principalpublic SessionInformation getSessionInformation(String sessionId)
SessionRegistrysessionId. Even expired sessions are
returned (although destroyed sessions are never returned).getSessionInformation in interface SessionRegistrysessionId - to lookup (should never be null)null if not foundpublic void onApplicationEvent(SessionDestroyedEvent event)
onApplicationEvent in interface ApplicationListener<SessionDestroyedEvent>public void refreshLastRequest(String sessionId)
SessionRegistrysessionId so its last request time is equal to the present date and time.
Silently returns if the given sessionId cannot be found or the session is marked to expire.refreshLastRequest in interface SessionRegistrysessionId - for which to update the date and time of the last request (should never be null)public void registerNewSession(String sessionId, Object principal)
SessionRegistryregisterNewSession in interface SessionRegistrysessionId - to associate with the principal (should never be null)principal - to associate with the session (should never be null)public void removeSessionInformation(String sessionId)
SessionRegistrysessionId. If the
sessionId is not found, the method gracefully returns.removeSessionInformation in interface SessionRegistrysessionId - to delete information for (should never be null)