- java.lang.Object
-
- org.tentackle.web.app.WebSessionKeyCache<T>
-
- Type Parameters:
T- the session key type
public class WebSessionKeyCache<T> extends java.lang.ObjectA cache mapping user session infos to the web container's session keys.- Author:
- harald
-
-
Constructor Summary
Constructors Constructor Description WebSessionKeyCache()Creates a session key cache.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSession(T sessionKey, org.tentackle.session.SessionInfo sessionInfo)Adds a mapping between a session and a user info.
This is usually done in the login controller.org.tentackle.session.SessionInfogetSession(T sessionKey)Gets the session.java.util.Collection<T>getSessionKeys(org.tentackle.session.SessionInfo sessionInfo)Gets the session keys for a user session info.voidremoveSession(T sessionKey)Removes a mapping between a session and a user info.
This is usually done in the logout controller.voidstartup(long cleanupInterval)Starts the session key cache.voidterminate()Terminates the session cache.
-
-
-
Method Detail
-
startup
public void startup(long cleanupInterval)
Starts the session key cache.This will start a thread to cleanup crashed sessions.
Throws TentackleRuntimeException if the cleanup thread is already running.
- Parameters:
cleanupInterval- interval in [ms] to run cleanup
-
terminate
public void terminate()
Terminates the session cache.Throws TentackleRuntimeException if the cleanup thread is not running at all.
-
addSession
public void addSession(T sessionKey, org.tentackle.session.SessionInfo sessionInfo)
Adds a mapping between a session and a user info.
This is usually done in the login controller. If a session with that key already exists, the user info will be replaced.- Parameters:
sessionKey- the (unique) session keysessionInfo- the user's session info
-
removeSession
public void removeSession(T sessionKey)
Removes a mapping between a session and a user info.
This is usually done in the logout controller. If there is no such session, the method will do nothing.- Parameters:
sessionKey- the (unique) session key
-
getSession
public org.tentackle.session.SessionInfo getSession(T sessionKey)
Gets the session.- Parameters:
sessionKey- the session key- Returns:
- the session, null if no such session
-
getSessionKeys
public java.util.Collection<T> getSessionKeys(org.tentackle.session.SessionInfo sessionInfo)
Gets the session keys for a user session info.- Parameters:
sessionInfo- the user info- Returns:
- the session keys, never null
-
-