Class DefaultSessionCache

All Implemented Interfaces:
Component, SessionCache

public class DefaultSessionCache extends AbstractSessionCache
Implementation of SessionCache.

Created: 2017. 6. 24.

  • Constructor Details

  • Method Details

    • getMaxActiveSessions

      public int getMaxActiveSessions()
    • setMaxActiveSessions

      public void setMaxActiveSessions(int maxActiveSessions)
      Description copied from interface: SessionCache
      Sets the maximum number of active sessions allowed in this session cache. The number of active sessions exceeds this limit, attempts to create new sessions will be rejected. If set to 0 (the default), there is no limit.
      Parameters:
      maxActiveSessions - the maximum number of active sessions allowed in this session cache
    • doGet

      protected ManagedSession doGet(String id)
      Description copied from class: AbstractSessionCache
      Get the session matching the key.
      Specified by:
      doGet in class AbstractSessionCache
      Parameters:
      id - the session id
      Returns:
      the Session object matching the id
    • doPutIfAbsent

      protected ManagedSession doPutIfAbsent(String id, ManagedSession session)
      Description copied from class: AbstractSessionCache
      Put the session into the map if it wasn't already there.
      Specified by:
      doPutIfAbsent in class AbstractSessionCache
      Parameters:
      id - the identity of the session
      session - the session object
      Returns:
      null if the session wasn't already in the map, or the existing entry otherwise
    • doComputeIfAbsent

      protected ManagedSession doComputeIfAbsent(String id, Function<String,ManagedSession> mappingFunction)
      Description copied from class: AbstractSessionCache
      Compute the mappingFunction to create a Session object if the session with the given id isn't already in the map, otherwise return the existing Session. This method is expected to have precisely the same behaviour as ConcurrentHashMap.computeIfAbsent(K, java.util.function.Function<? super K, ? extends V>)
      Specified by:
      doComputeIfAbsent in class AbstractSessionCache
      Parameters:
      id - the session id
      mappingFunction - the function to load the data for the session
      Returns:
      an existing Session from the cache
    • doDelete

      protected ManagedSession doDelete(String id)
      Description copied from class: AbstractSessionCache
      Remove the session with this identity from the store.
      Specified by:
      doDelete in class AbstractSessionCache
      Parameters:
      id - the session id
      Returns:
      the Session object if removed; null otherwise
    • getActiveSessions

      public Set<String> getActiveSessions()
      Returns:
      the identifiers of those sessions that are active on this node, excluding passivated sessions
    • getAllSessions

      public Set<String> getAllSessions()
      Returns:
      the identifiers of all sessions, including both active and passive
    • doInitialize

      protected void doInitialize() throws Exception
      Specified by:
      doInitialize in class AbstractComponent
      Throws:
      Exception
    • doDestroy

      protected void doDestroy() throws Exception
      Specified by:
      doDestroy in class AbstractComponent
      Throws:
      Exception
    • toString

      public String toString()
      Overrides:
      toString in class Object