public interface Session
Modifier and Type | Method and Description |
---|---|
java.lang.String |
changeSessionId()
Changes the session id.
|
<T> T |
getAttribute(java.lang.String attributeName)
Gets the Object associated with the specified name or null if no Object is
associated to that name.
|
java.util.Set<java.lang.String> |
getAttributeNames()
Gets the attribute names that have a value associated with it.
|
default <T> T |
getAttributeOrDefault(java.lang.String name,
T defaultValue)
Return the session attribute value, or a default, fallback value.
|
java.time.Instant |
getCreationTime()
Gets the time when this session was created.
|
java.lang.String |
getId()
Gets a unique string that identifies the
Session . |
java.time.Instant |
getLastAccessedTime()
Gets the last time this
Session was accessed. |
java.time.Duration |
getMaxInactiveInterval()
Gets the maximum inactive interval between requests before this session will be
invalidated.
|
default <T> T |
getRequiredAttribute(java.lang.String name)
Return the session attribute value or if not present raise an
IllegalArgumentException . |
boolean |
isExpired()
Returns true if the session is expired.
|
void |
removeAttribute(java.lang.String attributeName)
Removes the attribute with the provided attribute name.
|
void |
setAttribute(java.lang.String attributeName,
java.lang.Object attributeValue)
Sets the attribute value for the provided attribute name.
|
void |
setLastAccessedTime(java.time.Instant lastAccessedTime)
Sets the last accessed time.
|
void |
setMaxInactiveInterval(java.time.Duration interval)
Sets the maximum inactive interval between requests before this session will be
invalidated.
|
java.lang.String getId()
Session
.Session
java.lang.String changeSessionId()
getId()
will return a new identifier.getId()
will now return<T> T getAttribute(java.lang.String attributeName)
T
- the return type of the attributeattributeName
- the name of the attribute to getdefault <T> T getRequiredAttribute(java.lang.String name)
IllegalArgumentException
.T
- the attribute typename
- the attribute namedefault <T> T getAttributeOrDefault(java.lang.String name, T defaultValue)
T
- the attribute typename
- the attribute namedefaultValue
- a default value to return insteadjava.util.Set<java.lang.String> getAttributeNames()
getAttribute(String)
to
obtain the attribute value.getAttribute(String)
void setAttribute(java.lang.String attributeName, java.lang.Object attributeValue)
removeAttribute(String)
.attributeName
- the attribute name to setattributeValue
- the value of the attribute to set. If null, the attribute
will be removed.void removeAttribute(java.lang.String attributeName)
attributeName
- the name of the attribute to removejava.time.Instant getCreationTime()
void setLastAccessedTime(java.time.Instant lastAccessedTime)
lastAccessedTime
- the last accessed timejava.time.Instant getLastAccessedTime()
Session
was accessed.void setMaxInactiveInterval(java.time.Duration interval)
interval
- the amount of time that the Session
should be kept alive
between client requests.java.time.Duration getMaxInactiveInterval()
boolean isExpired()