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.booleanlongReturns the identifiers of those sessions that are active on this node, excluding passivated sessionsReturns the identifiers of all sessions, including both active and passivelonglongUniquely identifies this session managerlonglonglonglonglonggetSession(HttpServerExchange serverExchange, SessionConfig config) getSession(String sessionId) Retrieves a session with the given session idlongReturns 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 nodeinthashCode()voidregisterSessionListener(SessionListener listener) Registers a session listener for the session managervoidremoveSessionListener(SessionListener listener) Removes a session listener from the session managervoidsetDefaultSessionTimeout(int timeout) Sets the default session timeoutvoidstart()Starts the session managervoidstop()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:SessionManagerUniquely identifies this session manager- Specified by:
getDeploymentNamein interfaceSessionManager- Returns:
- a unique identifier
-
start
public void start()Description copied from interface:SessionManagerStarts the session manager- Specified by:
startin interfaceSessionManager
-
stop
public void stop()Description copied from interface:SessionManagerstops the session manager- Specified by:
stopin interfaceSessionManager
-
createSession
Description copied from interface:SessionManagerCreates a new session. AnySessionListeners 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 anIllegalStateExceptionmust 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:
createSessionin interfaceSessionManager- Returns:
- The created session
-
getSession
- Specified by:
getSessionin 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:SessionManagerRetrieves a session with the given session id- Specified by:
getSessionin interfaceSessionManager- Parameters:
sessionId- The session ID- Returns:
- The session, or null if it does not exist
-
registerSessionListener
Description copied from interface:SessionManagerRegisters a session listener for the session manager- Specified by:
registerSessionListenerin interfaceSessionManager- Parameters:
listener- The listener
-
removeSessionListener
Description copied from interface:SessionManagerRemoves a session listener from the session manager- Specified by:
removeSessionListenerin interfaceSessionManager- Parameters:
listener- the listener
-
setDefaultSessionTimeout
public void setDefaultSessionTimeout(int timeout) Description copied from interface:SessionManagerSets the default session timeout- Specified by:
setDefaultSessionTimeoutin interfaceSessionManager- Parameters:
timeout- the timeout
-
getTransientSessions
Description copied from interface:SessionManagerReturns the identifiers of those sessions that would be lost upon shutdown of this node- Specified by:
getTransientSessionsin interfaceSessionManager
-
getActiveSessions
Description copied from interface:SessionManagerReturns the identifiers of those sessions that are active on this node, excluding passivated sessions- Specified by:
getActiveSessionsin interfaceSessionManager
-
getAllSessions
Description copied from interface:SessionManagerReturns the identifiers of all sessions, including both active and passive- Specified by:
getAllSessionsin interfaceSessionManager
-
equals
-
hashCode
public int hashCode() -
toString
-
getStatistics
Description copied from interface:SessionManagerReturns the statistics for this session manager, or null, if statistics are not supported.- Specified by:
getStatisticsin interfaceSessionManager
-
getCreatedSessionCount
public long getCreatedSessionCount()- Specified by:
getCreatedSessionCountin interfaceSessionManagerStatistics- Returns:
- The number of sessions that this session manager has created
-
getMaxActiveSessions
public long getMaxActiveSessions()- Specified by:
getMaxActiveSessionsin interfaceSessionManagerStatistics- Returns:
- the maximum number of sessions this session manager supports
-
getHighestSessionCount
public long getHighestSessionCount()- Specified by:
getHighestSessionCountin 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:
getActiveSessionCountin interfaceSessionManagerStatistics- Returns:
- The number of active sessions
-
getExpiredSessionCount
public long getExpiredSessionCount()- Specified by:
getExpiredSessionCountin interfaceSessionManagerStatistics- Returns:
- The number of expired sessions
-
getRejectedSessions
public long getRejectedSessions()- Specified by:
getRejectedSessionsin interfaceSessionManagerStatistics- Returns:
- The number of rejected sessions
-
getMaxSessionAliveTime
public long getMaxSessionAliveTime()- Specified by:
getMaxSessionAliveTimein interfaceSessionManagerStatistics- Returns:
- The longest a session has been alive for in milliseconds
-
getAverageSessionAliveTime
public long getAverageSessionAliveTime()- Specified by:
getAverageSessionAliveTimein interfaceSessionManagerStatistics- Returns:
- The average session lifetime in milliseconds
-
getStartTime
public long getStartTime()- Specified by:
getStartTimein interfaceSessionManagerStatistics- Returns:
- The timestamp at which the session manager started
-