public final class MapSession extends Object implements ExpiringSession, 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
setMaxInactiveIntervalInSeconds(int) (30 minutes). |
| Constructor and Description |
|---|
MapSession()
Creates a new instance with a secure randomly generated identifier.
|
MapSession(ExpiringSession session)
Creates a new instance from the provided
Session. |
MapSession(String id)
Creates a new instance with the specified id.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
<T> T |
getAttribute(String attributeName)
Gets the Object associated with the specified name or null if no Object is
associated to that name.
|
Set<String> |
getAttributeNames()
Gets the attribute names that have a value associated with it.
|
long |
getCreationTime()
Gets the time when this session was created in milliseconds since midnight of
1/1/1970 GMT.
|
String |
getId()
Gets a unique string that identifies the
Session. |
long |
getLastAccessedTime()
Gets the last time this
Session was accessed expressed in milliseconds
since midnight of 1/1/1970 GMT. |
int |
getMaxInactiveIntervalInSeconds()
Gets the maximum inactive interval in seconds between requests before this session
will be invalidated.
|
int |
hashCode() |
boolean |
isExpired()
Returns true if the session is expired.
|
void |
removeAttribute(String attributeName)
Removes the attribute with the provided attribute name.
|
void |
setAttribute(String attributeName,
Object attributeValue)
Sets the attribute value for the provided attribute name.
|
void |
setCreationTime(long creationTime)
Sets the time that this
Session was created in milliseconds since midnight
of 1/1/1970 GMT. |
void |
setId(String id)
Sets the identifier for this
Session. |
void |
setLastAccessedTime(long lastAccessedTime)
Sets the last accessed time in milliseconds since midnight of 1/1/1970 GMT.
|
void |
setMaxInactiveIntervalInSeconds(int interval)
Sets the maximum inactive interval in seconds between requests before this session
will be invalidated.
|
public static final int DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS
setMaxInactiveIntervalInSeconds(int) (30 minutes).public MapSession()
public MapSession(String id)
id - the identifier to usepublic MapSession(ExpiringSession session)
Session.public void setLastAccessedTime(long lastAccessedTime)
ExpiringSessionsetLastAccessedTime in interface ExpiringSessionlastAccessedTime - the last accessed time in milliseconds since midnight of
1/1/1970 GMTpublic long getCreationTime()
ExpiringSessiongetCreationTime in interface ExpiringSessionpublic String getId()
SessionSession.public long getLastAccessedTime()
ExpiringSessionSession was accessed expressed in milliseconds
since midnight of 1/1/1970 GMT.getLastAccessedTime in interface ExpiringSessionpublic void setMaxInactiveIntervalInSeconds(int interval)
ExpiringSessionsetMaxInactiveIntervalInSeconds in interface ExpiringSessioninterval - the number of seconds that the Session should be kept alive
between client requests.public int getMaxInactiveIntervalInSeconds()
ExpiringSessiongetMaxInactiveIntervalInSeconds in interface ExpiringSessionpublic boolean isExpired()
ExpiringSessionisExpired in interface ExpiringSessionpublic <T> T getAttribute(String attributeName)
SessiongetAttribute in interface SessionT - The return type of the attributeattributeName - the name of the attribute to getpublic Set<String> getAttributeNames()
SessionSession.getAttribute(String) to
obtain the attribute value.getAttributeNames in interface SessionSession.getAttribute(String)public void setAttribute(String attributeName, 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(String attributeName)
SessionremoveAttribute in interface SessionattributeName - the name of the attribute to removepublic void setCreationTime(long creationTime)
Session was created in milliseconds since midnight
of 1/1/1970 GMT. The default is when the Session was instantiated.creationTime - the time that this Session was created in milliseconds
since midnight of 1/1/1970 GMT.public void setId(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.