Interface SessionManager

All Known Implementing Classes:
InMemorySessionManager

public interface SessionManager
Interface that manages sessions.

The session manager is responsible for maintaining session state.

As part of session creation the session manager MUST attempt to retrieve the SessionCookieConfig from the HttpServerExchange and use it to set the session cookie. The frees up the session manager from needing to know details of the cookie configuration. When invalidating a session the session manager MUST also use this to clear the session cookie.

Author:
Stuart Douglas
  • Field Details

  • Method Details

    • getDeploymentName

      String getDeploymentName()
      Uniquely identifies this session manager
      Returns:
      a unique identifier
    • start

      void start()
      Starts the session manager
    • stop

      void stop()
      stops the session manager
    • createSession

      Session createSession(HttpServerExchange serverExchange, SessionConfig sessionCookieConfig)
      Creates a new session. Any SessionListeners registered with this manager will be notified of the session creation.

      This method *MUST* call SessionConfig.findSessionId(io.undertow.server.HttpServerExchange) (io.undertow.server.HttpServerExchange)} first to determine if an existing session ID is present in the exchange. If this id is present then it must be used as the new session ID. If a session with this ID already exists then an IllegalStateException must be thrown.

      This requirement exists to allow forwards across servlet contexts to work correctly. The session manager is responsible for making sure that a newly created session is accessible to later calls to getSession(io.undertow.server.HttpServerExchange, SessionConfig) from the same request. It is recommended that a non static attachment key be used to store the newly created session as an attachment. The attachment key must be static to prevent different session managers from interfering with each other.

      Returns:
      The created session
    • getSession

      Session getSession(HttpServerExchange serverExchange, SessionConfig sessionCookieConfig)
      Returns:
      An IoFuture that can be used to retrieve the session, or an IoFuture that will return null if not found
    • getSession

      Session getSession(String sessionId)
      Retrieves a session with the given session id
      Parameters:
      sessionId - The session ID
      Returns:
      The session, or null if it does not exist
    • registerSessionListener

      void registerSessionListener(SessionListener listener)
      Registers a session listener for the session manager
      Parameters:
      listener - The listener
    • removeSessionListener

      void removeSessionListener(SessionListener listener)
      Removes a session listener from the session manager
      Parameters:
      listener - the listener
    • setDefaultSessionTimeout

      void setDefaultSessionTimeout(int timeout)
      Sets the default session timeout
      Parameters:
      timeout - the timeout
    • getTransientSessions

      Set<String> getTransientSessions()
      Returns the identifiers of those sessions that would be lost upon shutdown of this node
    • getActiveSessions

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

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

      SessionManagerStatistics getStatistics()
      Returns the statistics for this session manager, or null, if statistics are not supported.