public class SessionRegistryImpl extends Object implements SessionRegistry, ApplicationListener<SessionDestroyedEvent>
SessionRegistry
which
listens for SessionDestroyedEvent
s 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() |
SessionRegistryImpl(ConcurrentMap<Object,Set<String>> principals,
Map<String,SessionInformation> sessionIds) |
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 SessionRegistryImpl()
public SessionRegistryImpl(ConcurrentMap<Object,Set<String>> principals, Map<String,SessionInformation> sessionIds)
public List<Object> getAllPrincipals()
SessionRegistry
SessionRegistry
.getAllPrincipals
in interface SessionRegistry
SessionRegistry.getAllSessions(Object, boolean)
.public List<SessionInformation> getAllSessions(Object principal, boolean includeExpiredSessions)
SessionRegistry
getAllSessions
in interface SessionRegistry
principal
- 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)
SessionRegistry
sessionId
. Even
expired sessions are returned (although destroyed sessions are never returned).getSessionInformation
in interface SessionRegistry
sessionId
- to lookup (should never be null
)null
if not foundpublic void onApplicationEvent(SessionDestroyedEvent event)
onApplicationEvent
in interface ApplicationListener<SessionDestroyedEvent>
public void refreshLastRequest(String sessionId)
SessionRegistry
sessionId
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 SessionRegistry
sessionId
- for which to update the date and time of the last request (should
never be null
)public void registerNewSession(String sessionId, Object principal)
SessionRegistry
registerNewSession
in interface SessionRegistry
sessionId
- to associate with the principal (should never be null
)principal
- to associate with the session (should never be null
)public void removeSessionInformation(String sessionId)
SessionRegistry
sessionId
. If the sessionId
is not found, the method
gracefully returns.removeSessionInformation
in interface SessionRegistry
sessionId
- to delete information for (should never be null
)