public interface SessionManager
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.
Modifier and Type | Field and Description |
---|---|
static AttachmentKey<SessionManager> | ATTACHMENT_KEY |
Modifier and Type | Method and Description |
---|---|
Session | createSession(HttpServerExchange serverExchange, SessionConfig sessionCookieConfig) Creates a new session. |
Set<String> | getActiveSessions() Returns the identifiers of those sessions that are active on this node, excluding passivated sessions |
Set<String> | getAllSessions() Returns the identifiers of all sessions, including both active and passive |
String | getDeploymentName() Uniquely identifies this session manager |
Session | getSession(HttpServerExchange serverExchange, SessionConfig sessionCookieConfig) |
Session | getSession(String sessionId) Retrieves a session with the given session id |
SessionManagerStatistics | getStatistics() Returns the statistics for this session manager, or null, if statistics are not supported. |
Set<String> | getTransientSessions() Returns the identifiers of those sessions that would be lost upon shutdown of this node |
void | registerSessionListener(SessionListener listener) Registers a session listener for the session manager |
void | removeSessionListener(SessionListener listener) Removes a session listener from the session manager |
void | setDefaultSessionTimeout(int timeout) Sets the default session timeout |
void | start() Starts the session manager |
void | stop() stops the session manager |
static final AttachmentKey<SessionManager> ATTACHMENT_KEY
String getDeploymentName()
void start()
void stop()
Session createSession(HttpServerExchange serverExchange, SessionConfig sessionCookieConfig)
SessionListener
s 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.
Session getSession(HttpServerExchange serverExchange, SessionConfig sessionCookieConfig)
Session getSession(String sessionId)
sessionId
- The session IDvoid registerSessionListener(SessionListener listener)
listener
- The listenervoid removeSessionListener(SessionListener listener)
listener
- the listenervoid setDefaultSessionTimeout(int timeout)
timeout
- the timeoutSet<String> getTransientSessions()
Set<String> getActiveSessions()
Set<String> getAllSessions()
SessionManagerStatistics getStatistics()
Copyright © 2020 JBoss by Red Hat. All rights reserved.