Package org.eclipse.jetty.server
Interface Session
- All Superinterfaces:
Attributes
- All Known Implementing Classes:
ManagedSession
The interface to a generic session associated with a request.
This interface may be used directly, or it may be wrapped by an API specific
representation of a session. Such wrappers must implement the Session.API
sub interface.
Depending on the implementation the attribute values may be stored locally in memory or in a remote
database. The instances of the attribute values may be different to those passed to Attributes.setAttribute(String, Object)
or to those returned in previous Attributes.getAttribute(String)
calls.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
An API wrapper of the core session.static interface
Listener interface that if implemented by a value of an attribute of an enclosingContext
at start, will be notified of session lifecycle events.static interface
Listener interface that if implemented by a session attribute value, will be notified of session value events.Nested classes/interfaces inherited from interface org.eclipse.jetty.util.Attributes
Attributes.Layer, Attributes.Lazy, Attributes.Mapped, Attributes.Synthetic, Attributes.Wrapper
-
Field Summary
Fields inherited from interface org.eclipse.jetty.util.Attributes
NULL
-
Method Summary
Modifier and TypeMethodDescription<T extends Session.API>
TgetApi()
getId()
long
int
static Session
getSession
(Object session) Get the session associated with an API session wrapper.void
Invalidate this session in the current context and all sessions of the same identity with associated contexts.boolean
isNew()
boolean
isValid()
void
Renew the identity of the session.void
setMaxInactiveInterval
(int secs) Methods inherited from interface org.eclipse.jetty.util.Attributes
asAttributeMap, clearAttributes, equals, getAttribute, getAttributeNameSet, hashCode, removeAttribute, setAttribute
-
Method Details
-
getSession
Get the session associated with an API session wrapper.
- Parameters:
session
- The API wrapper of the session- Returns:
- The associated Session.
-
getApi
- Type Parameters:
T
- The type of the API wrapper.- Returns:
- An API wrapper of this session or null if there is none.
-
isValid
boolean isValid()- Returns:
- true if the session is has not been invalidated nor expired due to inactivity.
-
getId
String getId()- Returns:
- A identifier for the session. Depending on the implementation may be unique within the context, the server, the JVM or a cluster.
- See Also:
-
getExtendedId
String getExtendedId()- Returns:
- The session identifier as returned by
getId()
extended with additional routing information. The additional information does not form part of the identity, but may be used by implementations and associated infrastructure to help route request for the same session to the same server.
-
getLastAccessedTime
long getLastAccessedTime()- Returns:
- the time, as represented by
System.currentTimeMillis()
, that the session was last accessed by a request.
-
setMaxInactiveInterval
void setMaxInactiveInterval(int secs) - Parameters:
secs
- The period in secs in which the session will remain valid (unless explicitly invalidated) when not accessed by any requests.
-
getMaxInactiveInterval
int getMaxInactiveInterval()- Returns:
- The period in secs in which the session will remain valid (unless explicitly invalidated) when not accessed by any requests.
-
renewId
Renew the identity of the session. Typically, this is done after a change of authentication or confidentiality.- Parameters:
request
- The request from which the session was obtained.response
- The response which may be updated with the new session identity.
-
invalidate
void invalidate()Invalidate this session in the current context and all sessions of the same identity with associated contexts.
-
isNew
- Returns:
true
if the session has been newly created within the scope of the current request.- Throws:
IllegalStateException
-
encodeURI
-