Class InMemorySessionManager
- All Implemented Interfaces:
SessionManager
,SessionManagerStatistics
- Author:
- Stuart Douglas
-
Field Summary
Fields inherited from interface io.undertow.server.session.SessionManager
ATTACHMENT_KEY
-
Constructor Summary
ConstructorsConstructorDescriptionInMemorySessionManager
(SessionIdGenerator sessionIdGenerator, String deploymentName, int maxSessions, boolean expireOldestUnusedSessionOnMax) InMemorySessionManager
(SessionIdGenerator sessionIdGenerator, String deploymentName, int maxSessions, boolean expireOldestUnusedSessionOnMax, boolean statisticsEnabled) InMemorySessionManager
(String deploymentName, int maxSessions) InMemorySessionManager
(String deploymentName, int maxSessions, boolean expireOldestUnusedSessionOnMax) -
Method Summary
Modifier and TypeMethodDescriptioncreateSession
(HttpServerExchange serverExchange, SessionConfig config) Creates a new session.boolean
long
Returns the identifiers of those sessions that are active on this node, excluding passivated sessionsReturns the identifiers of all sessions, including both active and passivelong
long
Uniquely identifies this session managerlong
long
long
long
long
getSession
(HttpServerExchange serverExchange, SessionConfig config) getSession
(String sessionId) Retrieves a session with the given session idlong
Returns the statistics for this session manager, or null, if statistics are not supported.Returns the identifiers of those sessions that would be lost upon shutdown of this nodeint
hashCode()
void
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 managertoString()
-
Constructor Details
-
InMemorySessionManager
public InMemorySessionManager(String deploymentName, int maxSessions, boolean expireOldestUnusedSessionOnMax) -
InMemorySessionManager
public InMemorySessionManager(SessionIdGenerator sessionIdGenerator, String deploymentName, int maxSessions, boolean expireOldestUnusedSessionOnMax) -
InMemorySessionManager
public InMemorySessionManager(SessionIdGenerator sessionIdGenerator, String deploymentName, int maxSessions, boolean expireOldestUnusedSessionOnMax, boolean statisticsEnabled) -
InMemorySessionManager
-
InMemorySessionManager
-
-
Method Details
-
getDeploymentName
Description copied from interface:SessionManager
Uniquely identifies this session manager- Specified by:
getDeploymentName
in interfaceSessionManager
- Returns:
- a unique identifier
-
start
public void start()Description copied from interface:SessionManager
Starts the session manager- Specified by:
start
in interfaceSessionManager
-
stop
public void stop()Description copied from interface:SessionManager
stops the session manager- Specified by:
stop
in interfaceSessionManager
-
createSession
Description copied from interface:SessionManager
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
SessionManager.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.- Specified by:
createSession
in interfaceSessionManager
- Returns:
- The created session
-
getSession
- Specified by:
getSession
in interfaceSessionManager
- Returns:
- An IoFuture that can be used to retrieve the session, or an IoFuture that will return null if not found
-
getSession
Description copied from interface:SessionManager
Retrieves a session with the given session id- Specified by:
getSession
in interfaceSessionManager
- Parameters:
sessionId
- The session ID- Returns:
- The session, or null if it does not exist
-
registerSessionListener
Description copied from interface:SessionManager
Registers a session listener for the session manager- Specified by:
registerSessionListener
in interfaceSessionManager
- Parameters:
listener
- The listener
-
removeSessionListener
Description copied from interface:SessionManager
Removes a session listener from the session manager- Specified by:
removeSessionListener
in interfaceSessionManager
- Parameters:
listener
- the listener
-
setDefaultSessionTimeout
public void setDefaultSessionTimeout(int timeout) Description copied from interface:SessionManager
Sets the default session timeout- Specified by:
setDefaultSessionTimeout
in interfaceSessionManager
- Parameters:
timeout
- the timeout
-
getTransientSessions
Description copied from interface:SessionManager
Returns the identifiers of those sessions that would be lost upon shutdown of this node- Specified by:
getTransientSessions
in interfaceSessionManager
-
getActiveSessions
Description copied from interface:SessionManager
Returns the identifiers of those sessions that are active on this node, excluding passivated sessions- Specified by:
getActiveSessions
in interfaceSessionManager
-
getAllSessions
Description copied from interface:SessionManager
Returns the identifiers of all sessions, including both active and passive- Specified by:
getAllSessions
in interfaceSessionManager
-
equals
-
hashCode
public int hashCode() -
toString
-
getStatistics
Description copied from interface:SessionManager
Returns the statistics for this session manager, or null, if statistics are not supported.- Specified by:
getStatistics
in interfaceSessionManager
-
getCreatedSessionCount
public long getCreatedSessionCount()- Specified by:
getCreatedSessionCount
in interfaceSessionManagerStatistics
- Returns:
- The number of sessions that this session manager has created
-
getMaxActiveSessions
public long getMaxActiveSessions()- Specified by:
getMaxActiveSessions
in interfaceSessionManagerStatistics
- Returns:
- the maximum number of sessions this session manager supports
-
getHighestSessionCount
public long getHighestSessionCount()- Specified by:
getHighestSessionCount
in interfaceSessionManagerStatistics
- Returns:
- the highest number of sessions that have been active at a single time, or -1 if this statistic is not supported
-
getActiveSessionCount
public long getActiveSessionCount()- Specified by:
getActiveSessionCount
in interfaceSessionManagerStatistics
- Returns:
- The number of active sessions
-
getExpiredSessionCount
public long getExpiredSessionCount()- Specified by:
getExpiredSessionCount
in interfaceSessionManagerStatistics
- Returns:
- The number of expired sessions
-
getRejectedSessions
public long getRejectedSessions()- Specified by:
getRejectedSessions
in interfaceSessionManagerStatistics
- Returns:
- The number of rejected sessions
-
getMaxSessionAliveTime
public long getMaxSessionAliveTime()- Specified by:
getMaxSessionAliveTime
in interfaceSessionManagerStatistics
- Returns:
- The longest a session has been alive for in milliseconds
-
getAverageSessionAliveTime
public long getAverageSessionAliveTime()- Specified by:
getAverageSessionAliveTime
in interfaceSessionManagerStatistics
- Returns:
- The average session lifetime in milliseconds
-
getStartTime
public long getStartTime()- Specified by:
getStartTime
in interfaceSessionManagerStatistics
- Returns:
- The timestamp at which the session manager started
-