Module io.jooby
Package io.jooby

Class SessionStore.InMemory

java.lang.Object
io.jooby.SessionStore.InMemory
All Implemented Interfaces:
SessionStore
Enclosing interface:
SessionStore

public abstract static class SessionStore.InMemory extends Object implements SessionStore
Base class for in-memory session store.
Since:
2.0.0
Author:
edgar.
  • Method Details

    • newSession

      @NonNull public Session newSession(@NonNull Context ctx)
      Description copied from interface: SessionStore
      Creates a new session. This method must:

      - Set session as new Session.setNew(boolean) - Optionally, set session creation time Session.setCreationTime(Instant) - Optionally, set session last accessed time Session.setLastAccessedTime(Instant)

      Specified by:
      newSession in interface SessionStore
      Parameters:
      ctx - Web context.
      Returns:
      A new session.
    • getToken

      @NonNull public SessionToken getToken()
      Session token.
      Returns:
      Session token. Uses a cookie by default: SessionToken.SID.
    • setToken

      @NonNull public SessionStore setToken(@NonNull SessionToken token)
      Set custom session token.
      Parameters:
      token - Session token.
      Returns:
      This store.
    • findSession

      public Session findSession(Context ctx)
      Description copied from interface: SessionStore
      Find an existing session by ID. For existing session this method must:

      - Optionally, Retrieve/restore session creation time - Optionally, Set session last accessed time Session.setLastAccessedTime(Instant)

      Specified by:
      findSession in interface SessionStore
      Parameters:
      ctx - Web context.
      Returns:
      An existing session or null.
    • deleteSession

      public void deleteSession(@NonNull Context ctx, @NonNull Session session)
      Description copied from interface: SessionStore
      Delete a session from store. This method must NOT call Session.destroy().
      Specified by:
      deleteSession in interface SessionStore
      Parameters:
      ctx - Web context.
      session - Current session.
    • touchSession

      public void touchSession(@NonNull Context ctx, @NonNull Session session)
      Description copied from interface: SessionStore
      Session attributes/state has changed. Every time a session attribute is put or removed it, this method is executed as notification callback.
      Specified by:
      touchSession in interface SessionStore
      Parameters:
      ctx - Web context.
      session - Current session.
    • saveSession

      public void saveSession(Context ctx, @NonNull Session session)
      Description copied from interface: SessionStore
      Save a session. This method must save:

      - Session attributes/data - Optionally set Session metadata like: creationTime, lastAccessed time, etc.

      This method is call after response is send to client, so context and response shouldn't be modified.

      Specified by:
      saveSession in interface SessionStore
      Parameters:
      ctx - Web context.
      session - Current session.
    • renewSessionId

      public void renewSessionId(@NonNull Context ctx, @NonNull Session session)
      Description copied from interface: SessionStore
      Renew Session ID. This operation might or might not be implemented by a Session Store.
      Specified by:
      renewSessionId in interface SessionStore
      Parameters:
      ctx - Web Context.
      session - Session.