Top Description Fields Methods
io.undertow.server.session

public Interface SessionManager

Known Direct Implementers
io.undertow.server.session.InMemorySessionManager
Imports
io.undertow.server.HttpServerExchange, io.undertow.util.AttachmentKey, java.util.Set

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 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.

Author
Stuart Douglas

Field Summary

Modifier and TypeField and Description
public static final AttachmentKey<SessionManager>

Method Summary

Modifier and TypeMethod and Description
public Session

Returns:

The created session
createSession
(final HttpServerExchange serverExchange, final SessionConfig sessionCookieConfig)

Creates a new session.

public Set<String>
getActiveSessions()

Returns the identifiers of those sessions that are active on this node, excluding passivated sessions

public Set<String>
getAllSessions()

Returns the identifiers of all sessions, including both active and passive

public String

Returns:

a unique identifier
getDeploymentName
()

Uniquely identifies this session manager

public Session

Returns:

An IoFuture that can be used to retrieve the session, or an IoFuture that will return null if not found
getSession
(final HttpServerExchange serverExchange, final SessionConfig sessionCookieConfig)

public Session

Returns:

The session, or null if it does not exist
getSession
(final String
The session ID
sessionId
)

Retrieves a session with the given session id

public SessionManagerStatistics
getStatistics()

Returns the statistics for this session manager, or null, if statistics are not supported.

public Set<String>
getTransientSessions()

Returns the identifiers of those sessions that would be lost upon shutdown of this node

public void
registerSessionListener(final SessionListener
The listener
listener
)

Registers a session listener for the session manager

public void
removeSessionListener(final SessionListener
the listener
listener
)

Removes a session listener from the session manager

public void
setDefaultSessionTimeout(final int
the timeout
timeout
)

Sets the default session timeout

public void
start()

Starts the session manager

public void
stop()

stops the session manager

Field Detail

ATTACHMENT_KEYback to summary
public static final AttachmentKey<SessionManager> ATTACHMENT_KEY

Method Detail

createSessionback to summary
public Session createSession(final HttpServerExchange serverExchange, final SessionConfig sessionCookieConfig)

Creates a new session. Any SessionListeners 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.

Returns:Session

The created session

getActiveSessionsback to summary
public Set<String> getActiveSessions()

Returns the identifiers of those sessions that are active on this node, excluding passivated sessions

getAllSessionsback to summary
public Set<String> getAllSessions()

Returns the identifiers of all sessions, including both active and passive

getDeploymentNameback to summary
public String getDeploymentName()

Uniquely identifies this session manager

Returns:String

a unique identifier

getSessionback to summary
public Session getSession(final HttpServerExchange serverExchange, final SessionConfig sessionCookieConfig)
Returns:Session

An IoFuture that can be used to retrieve the session, or an IoFuture that will return null if not found

getSessionback to summary
public Session getSession(final String sessionId)

Retrieves a session with the given session id

Parameters
sessionId:String

The session ID

Returns:Session

The session, or null if it does not exist

getStatisticsback to summary
public SessionManagerStatistics getStatistics()

Returns the statistics for this session manager, or null, if statistics are not supported.

getTransientSessionsback to summary
public Set<String> getTransientSessions()

Returns the identifiers of those sessions that would be lost upon shutdown of this node

registerSessionListenerback to summary
public void registerSessionListener(final SessionListener listener)

Registers a session listener for the session manager

Parameters
listener:SessionListener

The listener

removeSessionListenerback to summary
public void removeSessionListener(final SessionListener listener)

Removes a session listener from the session manager

Parameters
listener:SessionListener

the listener

setDefaultSessionTimeoutback to summary
public void setDefaultSessionTimeout(final int timeout)

Sets the default session timeout

Parameters
timeout:int

the timeout

startback to summary
public void start()

Starts the session manager

stopback to summary
public void stop()

stops the session manager