Top Description Methods
io.undertow.server.session

public Interface Session

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

Represents a HTTP session.

Many operations provide both a blocking and an asynchronous version.

When using the async versions of operations no guarantee is made as to which threads will run listeners registered with this session manger. When using the blocking version the listeners are guaranteed to run in the calling thread.

Author
Stuart Douglas

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

The new session ID
changeSessionId
(final HttpServerExchange exchange, final SessionConfig config)

Generate a new session id for this session, and return the new id.

public Object

Returns:

the object with the specified name
getAttribute
(String
a string specifying the name of the object
name
)

Returns the object bound with the specified name in this session, or null if no object is bound under the name.

public Set<String>

Returns:

an Set of String objects specifying the names of all the objects bound to this session
getAttributeNames
()

Returns an Set of String objects containing the names of all the objects bound to this session.

public long

Returns:

a long specifying when this session was created, expressed in milliseconds since 1/1/1970 GMT
getCreationTime
()

Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.

public String

Returns:

a string specifying the identifier assigned to this session
getId
()

Returns a string containing the unique identifier assigned to this session.

public long

Returns:

a long representing the last time the client sent a request associated with this session, expressed in milliseconds since 1/1/1970 GMT
getLastAccessedTime
()

Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight January 1, 1970 GMT, and marked by the time the container received the request.

public int

Returns:

an integer specifying the number of seconds this session remains open between client requests
getMaxInactiveInterval
()

Returns the maximum time interval, in seconds, that the servlet container will keep this session open between client accesses.

public SessionManager

Returns:

The session manager that is associated with this session
getSessionManager
()

public void
invalidate(final HttpServerExchange exchange)

Invalidates this session then unbinds any objects bound to it.

public Object
removeAttribute(final String
the name of the object to remove from this session
name
)

Removes the object bound with the specified name from this session.

public void
requestDone(final HttpServerExchange
The http server exchange for this request
serverExchange
)

Called when a request is done with the session.

public Object

Returns:

An IOFuture containing the previous value
setAttribute
(final String
the name to which the object is bound; cannot be null
name
,
Object
the object to be bound
value
)

Binds an object to this session, using the name specified.

public void
setMaxInactiveInterval(int
An integer specifying the number of seconds
interval
)

Specifies the time, in seconds, between client requests before the servlet container will invalidate this session.

Method Detail

changeSessionIdback to summary
public String changeSessionId(final HttpServerExchange exchange, final SessionConfig config)

Generate a new session id for this session, and return the new id.

Returns:String

The new session ID

getAttributeback to summary
public Object getAttribute(String name)

Returns the object bound with the specified name in this session, or null if no object is bound under the name.

Parameters
name:String

a string specifying the name of the object

Returns:Object

the object with the specified name

Exceptions
IllegalStateException:
if this method is called on an invalidated session
getAttributeNamesback to summary
public Set<String> getAttributeNames()

Returns an Set of String objects containing the names of all the objects bound to this session.

Returns:Set<String>

an Set of String objects specifying the names of all the objects bound to this session

Exceptions
IllegalStateException:
if this method is called on an invalidated session
getCreationTimeback to summary
public long getCreationTime()

Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.

Returns:long

a long specifying when this session was created, expressed in milliseconds since 1/1/1970 GMT

Exceptions
IllegalStateException:
if this method is called on an invalidated session
getIdback to summary
public String getId()

Returns a string containing the unique identifier assigned to this session. The identifier is assigned by the servlet container and is implementation dependent.

Returns:String

a string specifying the identifier assigned to this session

getLastAccessedTimeback to summary
public long getLastAccessedTime()

Returns the last time the client sent a request associated with this session, as the number of milliseconds since midnight January 1, 1970 GMT, and marked by the time the container received the request.

Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time.

Returns:long

a long representing the last time the client sent a request associated with this session, expressed in milliseconds since 1/1/1970 GMT

Exceptions
IllegalStateException:
if this method is called on an invalidated session
getMaxInactiveIntervalback to summary
public int getMaxInactiveInterval()

Returns the maximum time interval, in seconds, that the servlet container will keep this session open between client accesses. After this interval, the servlet container will invalidate the session. The maximum time interval can be set with the setMaxInactiveInterval method. A negative time indicates the session should never timeout.

Returns:int

an integer specifying the number of seconds this session remains open between client requests

See Also
setMaxInactiveInterval
getSessionManagerback to summary
public SessionManager getSessionManager()
Returns:SessionManager

The session manager that is associated with this session

invalidateback to summary
public void invalidate(final HttpServerExchange exchange)

Invalidates this session then unbinds any objects bound to it.

Exceptions
IllegalStateException:
if this method is called on an already invalidated session
removeAttributeback to summary
public Object removeAttribute(final String name)

Removes the object bound with the specified name from this session. If the session does not have an object bound with the specified name, this method does nothing.

Parameters
name:String

the name of the object to remove from this session

Exceptions
IllegalStateException:
if this method is called on an invalidated session
requestDoneback to summary
public void requestDone(final HttpServerExchange serverExchange)

Called when a request is done with the session.

Parameters
serverExchange:HttpServerExchange

The http server exchange for this request

setAttributeback to summary
public Object setAttribute(final String name, Object value)

Binds an object to this session, using the name specified. If an object of the same name is already bound to the session, the object is replaced.

If the value passed in is null, this has the same effect as calling removeAttribute().

Parameters
name:String

the name to which the object is bound; cannot be null

value:Object

the object to be bound

Returns:Object

An IOFuture containing the previous value

Exceptions
IllegalStateException:
if this method is called on an invalidated session
setMaxInactiveIntervalback to summary
public void setMaxInactiveInterval(int interval)

Specifies the time, in seconds, between client requests before the servlet container will invalidate this session. A negative time indicates the session should never timeout.

Parameters
interval:int

An integer specifying the number of seconds