public class InMemorySessionDataAccess extends java.lang.Object implements SessionDataAccess
SessionDataAccess
implementation that uses PackedMap
to map user ID to session ID, session ID to
user ID and session ID to session expiration.
Sessions aren't automatically removed when expired.
Constructor and Description |
---|
InMemorySessionDataAccess() |
Modifier and Type | Method and Description |
---|---|
void |
addSession(Session session)
Adds a new session.
|
Session |
getSessionByID(java.lang.String sessionID)
Retrieves the active session with given session ID.
|
Session |
getSessionByUser(java.lang.String userID)
Retrieves the active session of the given user.
|
void |
refreshSession(java.lang.String sessionID,
long newExpiration)
Refreshes the expiration date of the session.
|
void |
removeSession(Session session)
Removes a session.
|
public void addSession(Session session)
SessionDataAccess
addSession
in interface SessionDataAccess
session
- the new Session
.public Session getSessionByUser(java.lang.String userID)
SessionDataAccess
getSessionByUser
in interface SessionDataAccess
userID
- the identifier of the user.null
if none matching the user.public Session getSessionByID(java.lang.String sessionID)
SessionDataAccess
getSessionByID
in interface SessionDataAccess
sessionID
- the identifier of the session.null
if none with that ID.public void refreshSession(java.lang.String sessionID, long newExpiration)
SessionDataAccess
refreshSession
in interface SessionDataAccess
sessionID
- the ID of the session to refresh.newExpiration
- the new expiration date.public void removeSession(Session session)
SessionDataAccess
removeSession
in interface SessionDataAccess
session
- the Session
to remove.