Class WebSessionKeyCache<T>

java.lang.Object
org.tentackle.web.app.WebSessionKeyCache<T>
Type Parameters:
T - the session key type

public class WebSessionKeyCache<T> extends Object
A cache mapping user session infos to the web container's session keys.
Author:
harald
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a session key cache.
  • Method Summary

    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.
    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
    Terminates the session cache.

    Methods inherited from class java.lang.Object

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

    • WebSessionKeyCache

      public WebSessionKeyCache()
      Creates a session key cache.
  • Method Details

    • startup

      public void startup(long cleanupInterval)
      Starts the session key cache.

      This will start a thread to clean up 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 session 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 Collection<T> getSessionKeys(org.tentackle.session.SessionInfo sessionInfo)
      Gets the session keys for a user session info.
      Parameters:
      sessionInfo - the session info
      Returns:
      the session keys, never null