Class InMemorySessionManager

All Implemented Interfaces:
Iterable<ComponentType>, Channel, ComponentType, Eligible, Manager

A in memory session manager.
  • Constructor Details

    • InMemorySessionManager

      Creates a new session manager with its channel set to itself and the path set to “/”.

      The manager handles all Request events.

    • InMemorySessionManager

      Creates a new session manager with its channel set to itself and the path set to the given path.

      The manager handles all requests that match the given path, using the same rules as browsers do for selecting the cookies that are to be sent.

      Parameters:
      path - the path
    • InMemorySessionManager

      public InMemorySessionManager(Channel componentChannel)
      Creates a new session manager with its channel set to the given channel, the path to “/” and the handler’s priority to 1000.

      The manager handles all Request events.

      Parameters:
      componentChannel - the component channel
    • InMemorySessionManager

      public InMemorySessionManager(Channel componentChannel, String path)
      Creates a new session manager with the given channel and path.

      The manager handles all requests that match the given path, using the same rules as browsers do for selecting the cookies that are to be sent. The request handler’s priority is set to 1000.

      Parameters:
      componentChannel - the component channel
      path - the path
    • InMemorySessionManager

      public InMemorySessionManager(Channel componentChannel, String pattern, int priority, String path)
      Creates a new session manager using the given channel and path.

      The manager handles only requests that match the given pattern. The Request handler is registered with the given priority.

      This constructor can be used if special handling of top level requests is needed.

      Parameters:
      componentChannel - the component channel
      pattern - the path part of a ResourcePattern
      priority - the priority
      path - the path
  • Method Details

    • startDiscarding

      protected Optional<Instant> startDiscarding(long absoluteTimeout, long idleTimeout)
      Description copied from class: SessionManager
      Start discarding all sessions (generate DiscardSession events) that have reached their absolute or idle timeout.

      Do not make the sessions unavailable yet.

      Returns the time when the next timeout occurs. This method is called only if at least one of the timeouts has been specified.

      Implementations have to take care that sessions are only discarded once. As they must remain available while the DiscardSession event is handled this may require marking them as being discarded.

      Specified by:
      startDiscarding in class SessionManager
      Parameters:
      absoluteTimeout - the absolute timeout
      idleTimeout - the idle timeout
      Returns:
      the next timeout (empty if no sessions left)
    • createSession

      protected Session createSession(String sessionId)
      Description copied from class: SessionManager
      Creates a new session with the given id.
      Specified by:
      createSession in class SessionManager
      Parameters:
      sessionId -
      Returns:
      the session
    • lookupSession

      protected Optional<Session> lookupSession(String sessionId)
      Description copied from class: SessionManager
      Lookup the session with the given id.

      Lookup will fail if the session has timed out.

      Specified by:
      lookupSession in class SessionManager
      Parameters:
      sessionId -
      Returns:
      the session
    • removeSession

      protected void removeSession(String sessionId)
      Description copied from class: SessionManager
      Removes the given session from the cache.
      Specified by:
      removeSession in class SessionManager
      Parameters:
      sessionId - the session id
    • sessionCount

      protected int sessionCount()
      Description copied from class: SessionManager
      Return the number of established sessions.
      Specified by:
      sessionCount in class SessionManager
      Returns:
      the result