public final class MapSession extends java.lang.Object implements Session, java.io.Serializable
A Session implementation that is backed by a Map. The
defaults for the properties are:
MapSession was instantiatedMapSession was instantiatedThis implementation has no synchronization, so it is best to use the copy constructor when working on multiple threads.
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS
Default
setMaxInactiveInterval(Duration) (30 minutes). |
| Constructor and Description |
|---|
MapSession()
Creates a new instance with a secure randomly generated identifier.
|
MapSession(Session session)
Creates a new instance from the provided
Session. |
MapSession(java.lang.String id)
Creates a new instance with the specified id.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
changeSessionId()
Changes the session id.
|
boolean |
equals(java.lang.Object obj) |
<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.
|
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.
|
java.lang.String |
getOriginalId()
Get the original session id.
|
int |
hashCode() |
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 |
setCreationTime(java.time.Instant creationTime)
Sets the time that this
Session was created. |
void |
setId(java.lang.String id)
Sets the identifier for this
Session. |
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.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitgetAttributeOrDefault, getRequiredAttributepublic static final int DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS
setMaxInactiveInterval(Duration) (30 minutes).public MapSession()
public MapSession(java.lang.String id)
id - the identifier to usepublic void setLastAccessedTime(java.time.Instant lastAccessedTime)
SessionsetLastAccessedTime in interface SessionlastAccessedTime - the last accessed timepublic java.time.Instant getCreationTime()
SessiongetCreationTime in interface Sessionpublic java.lang.String getId()
SessionSession.public java.lang.String getOriginalId()
changeSessionId()public java.lang.String changeSessionId()
SessionSession.getId() will return a new identifier.changeSessionId in interface SessionSession.getId() will now returnpublic java.time.Instant getLastAccessedTime()
SessionSession was accessed.getLastAccessedTime in interface Sessionpublic void setMaxInactiveInterval(java.time.Duration interval)
SessionsetMaxInactiveInterval in interface Sessioninterval - the amount of time that the Session should be kept alive
between client requests.public java.time.Duration getMaxInactiveInterval()
SessiongetMaxInactiveInterval in interface Sessionpublic boolean isExpired()
Sessionpublic <T> T getAttribute(java.lang.String attributeName)
SessiongetAttribute in interface SessionT - the return type of the attributeattributeName - the name of the attribute to getpublic java.util.Set<java.lang.String> getAttributeNames()
SessionSession.getAttribute(String) to
obtain the attribute value.getAttributeNames in interface SessionSession.getAttribute(String)public void setAttribute(java.lang.String attributeName,
java.lang.Object attributeValue)
SessionSession.removeAttribute(String) .setAttribute in interface SessionattributeName - the attribute name to setattributeValue - the value of the attribute to set. If null, the attribute
will be removed.public void removeAttribute(java.lang.String attributeName)
SessionremoveAttribute in interface SessionattributeName - the name of the attribute to removepublic void setCreationTime(java.time.Instant creationTime)
creationTime - the time that this Session was created.public void setId(java.lang.String id)
Session. The id should be a secure random
generated value to prevent malicious users from guessing this value. The default is
a secure random generated identifier.id - the identifier for this session.public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object