public interface 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.
Modifier and Type | Method and Description |
---|---|
String | changeSessionId(HttpServerExchange exchange, SessionConfig config) Generate a new session id for this session, and return the new id. |
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. |
Set<String> | getAttributeNames() Returns an Set of String objects containing the names of all the objects bound to this session. |
long | getCreationTime() Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT. |
String | getId() Returns a string containing the unique identifier assigned to this session. |
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. |
int | getMaxInactiveInterval() Returns the maximum time interval, in seconds, that the servlet container will keep this session open between client accesses. |
SessionManager | getSessionManager() |
void | invalidate(HttpServerExchange exchange) Invalidates this session then unbinds any objects bound to it. |
Object | removeAttribute(String name) Removes the object bound with the specified name from this session. |
void | requestDone(HttpServerExchange serverExchange) Called when a request is done with the session. |
Object | setAttribute(String name, Object value) Binds an object to this session, using the name specified. |
void | setMaxInactiveInterval(int interval) Specifies the time, in seconds, between client requests before the servlet container will invalidate this session. |
String getId()
IllegalStateException
- if this method is called on an invalidated sessionvoid requestDone(HttpServerExchange serverExchange)
serverExchange
- The http server exchange for this requestlong getCreationTime()
long
specifying when this session was created, expressed in milliseconds since 1/1/1970 GMTIllegalStateException
- if this method is called on an invalidated sessionlong getLastAccessedTime()
Actions that your application takes, such as getting or setting a value associated with the session, do not affect the access time.
long
representing the last time the client sent a request associated with this session, expressed in milliseconds since 1/1/1970 GMTIllegalStateException
- if this method is called on an invalidated sessionvoid setMaxInactiveInterval(int interval)
interval
- An integer specifying the number of secondsint getMaxInactiveInterval()
setMaxInactiveInterval
method. A negative time indicates the session should never timeout.setMaxInactiveInterval(int)
Object getAttribute(String name)
null
if no object is bound under the name.name
- a string specifying the name of the objectIllegalStateException
- if this method is called on an invalidated sessionSet<String> getAttributeNames()
Set
of String
objects containing the names of all the objects bound to this session.Set
of String
objects specifying the names of all the objects bound to this sessionIllegalStateException
- if this method is called on an invalidated sessionObject setAttribute(String name, Object value)
If the value passed in is null, this has the same effect as calling removeAttribute()
.
name
- the name to which the object is bound; cannot be nullvalue
- the object to be boundIllegalStateException
- if this method is called on an invalidated sessionObject removeAttribute(String name)
name
- the name of the object to remove from this sessionIllegalStateException
- if this method is called on an invalidated sessionvoid invalidate(HttpServerExchange exchange)
IllegalStateException
- if this method is called on an already invalidated sessionSessionManager getSessionManager()
String changeSessionId(HttpServerExchange exchange, SessionConfig config)
Copyright © 2015 JBoss by Red Hat. All rights reserved.