Class WebSessionKeyCache<T>

  • Type Parameters:
    T - the session key type

    public class WebSessionKeyCache<T>
    extends java.lang.Object
    A 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
      void addSessionInfo​(T sessionKey, org.tentackle.session.SessionInfo sessionInfo)
      Adds a mapping between a session and a session info.
      This is usually done in the login controller.
      org.tentackle.session.SessionInfo getSessionInfo​(T sessionKey)
      Gets the session info.
      java.util.Collection<T> getSessionKeys​(org.tentackle.session.SessionInfo sessionInfo)
      Gets the session keys for a user session info.
      void removeSessionInfo​(T sessionKey)
      Removes a mapping between a session and a session info.
      This is usually done in the logout controller.
      void startup​(long cleanupInterval)
      Starts the session key cache.
      void terminate()
      Terminates the session cache.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • WebSessionKeyCache

        public WebSessionKeyCache()
        Creates a session key 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.

      • addSessionInfo

        public void addSessionInfo​(T sessionKey,
                                   org.tentackle.session.SessionInfo sessionInfo)
        Adds a mapping between a session and a session 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 key
        sessionInfo - the user's session info
      • removeSessionInfo

        public void removeSessionInfo​(T sessionKey)
        Removes a mapping between a session and a session 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
      • getSessionInfo

        public org.tentackle.session.SessionInfo getSessionInfo​(T sessionKey)
        Gets the session info.
        Parameters:
        sessionKey - the session key
        Returns:
        the session info, null if no such session info
      • 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