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 theHttpServerExchange
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 Summary
Fields Modifier and Type Field Description static AttachmentKey<SessionManager>
ATTACHMENT_KEY
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Session
createSession(HttpServerExchange serverExchange, SessionConfig sessionCookieConfig)
Creates a new session.java.util.Set<java.lang.String>
getActiveSessions()
Returns the identifiers of those sessions that are active on this node, excluding passivated sessionsjava.util.Set<java.lang.String>
getAllSessions()
Returns the identifiers of all sessions, including both active and passivejava.lang.String
getDeploymentName()
Uniquely identifies this session managerSession
getSession(HttpServerExchange serverExchange, SessionConfig sessionCookieConfig)
Session
getSession(java.lang.String sessionId)
Retrieves a session with the given session idSessionManagerStatistics
getStatistics()
Returns the statistics for this session manager, or null, if statistics are not supported.java.util.Set<java.lang.String>
getTransientSessions()
Returns the identifiers of those sessions that would be lost upon shutdown of this nodevoid
registerSessionListener(SessionListener listener)
Registers a session listener for the session managervoid
removeSessionListener(SessionListener listener)
Removes a session listener from the session managervoid
setDefaultSessionTimeout(int timeout)
Sets the default session timeoutvoid
start()
Starts the session managervoid
stop()
stops the session manager
-
-
-
Field Detail
-
ATTACHMENT_KEY
static final AttachmentKey<SessionManager> ATTACHMENT_KEY
-
-
Method Detail
-
getDeploymentName
java.lang.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. AnySessionListener
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 anIllegalStateException
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(java.lang.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
java.util.Set<java.lang.String> getTransientSessions()
Returns the identifiers of those sessions that would be lost upon shutdown of this node
-
getActiveSessions
java.util.Set<java.lang.String> getActiveSessions()
Returns the identifiers of those sessions that are active on this node, excluding passivated sessions
-
getAllSessions
java.util.Set<java.lang.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.
-
-