public class SessionRegistryImpl extends java.lang.Object implements SessionRegistry, org.springframework.context.ApplicationListener
SessionRegistry
which also listens for HttpSessionDestroyedEvents
published in the Spring application context.
NB: It is important that you register the HttpSessionEventPublisher in
web.xml so that this class is notified of sessions that expire.
| Modifier and Type | Field and Description |
|---|---|
protected static org.apache.commons.logging.Log |
logger |
| Constructor and Description |
|---|
SessionRegistryImpl() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object[] |
getAllPrincipals()
Obtains all the known principals in the
SessionRegistry. |
SessionInformation[] |
getAllSessions(java.lang.Object principal,
boolean includeExpiredSessions)
Obtains all the known sessions for the specified principal.
|
SessionInformation |
getSessionInformation(java.lang.String sessionId)
Obtains the session information for the specified
sessionId. |
void |
onApplicationEvent(org.springframework.context.ApplicationEvent event) |
void |
refreshLastRequest(java.lang.String sessionId)
Updates the given
sessionId so its last request time is equal to the present date and time. |
void |
registerNewSession(java.lang.String sessionId,
java.lang.Object principal)
Registers a new session for the specified principal.
|
void |
removeSessionInformation(java.lang.String sessionId)
Deletes all the session information being maintained for the specified
sessionId. |
public java.lang.Object[] getAllPrincipals()
SessionRegistrySessionRegistry.getAllPrincipals in interface SessionRegistrySessionRegistry.getAllSessions(Object, boolean).public SessionInformation[] getAllSessions(java.lang.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 principalnull if none were foundpublic SessionInformation getSessionInformation(java.lang.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(org.springframework.context.ApplicationEvent event)
onApplicationEvent in interface org.springframework.context.ApplicationListenerpublic void refreshLastRequest(java.lang.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(java.lang.String sessionId,
java.lang.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(java.lang.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)