public class Session extends Object
Constructor and Description |
---|
Session() |
Session(String id)
Create a new session using a session identifier
|
Modifier and Type | Method and Description |
---|---|
long |
access()
Updates the "last accessed" timestamp with the current time.
|
ConcurrentMap<String,Object> |
attributes()
Return a
ConcurrentMap of attributes. |
Object |
getAttribute(String key)
Return an attribute.
|
long |
getCreationTime()
Returns the time when this session was created, measured
in milliseconds since midnight January 1, 1970 GMT.
|
String |
getIdInternal() |
long |
getSessionTimeout()
Return a long representing the maximum idle time (in milliseconds) a session can be.
|
long |
getTimestamp() |
boolean |
isNew()
Returns
true if the client does not yet know about the
session or if the client chooses not to join the session. |
boolean |
isValid()
Is the current Session valid?
|
Object |
removeAttribute(String key)
Remove an attribute.
|
void |
setAttribute(String key,
Object value)
Add an attribute to this session.
|
protected void |
setIdInternal(String id)
Sets the session identifier for this session.
|
void |
setSessionTimeout(long sessionTimeout)
Set a long representing the maximum idle time (in milliseconds) a session can be.
|
void |
setTimestamp(long timestamp)
Set the timestamp when this session was accessed the last time.
|
void |
setValid(boolean isValid)
Set this object as validated.
|
public Session()
public Session(String id)
id
- session identifierpublic boolean isValid()
public void setValid(boolean isValid)
isValid
- public boolean isNew()
true
if the client does not yet know about the
session or if the client chooses not to join the session. For
example, if the server used only cookie-based sessions, and
the client had disabled the use of cookies, then a session would
be new on each request.true
if the
server has created a session,
but the client has not yet joinedpublic String getIdInternal()
protected void setIdInternal(String id)
id
- public void setAttribute(String key, Object value)
key
- value
- public Object getAttribute(String key)
key
- public Object removeAttribute(String key)
key
- public ConcurrentMap<String,Object> attributes()
ConcurrentMap
of attributes.public long getCreationTime()
long
specifying
when this session was created,
expressed in
milliseconds since 1/1/1970 GMTpublic long getSessionTimeout()
public void setSessionTimeout(long sessionTimeout)
sessionTimeout
- a long representing the maximum idle time (in milliseconds) a session can be.public long getTimestamp()
public void setTimestamp(long timestamp)
timestamp
- a long representing when the session was accessed the last timepublic long access()
Copyright © 2015 Oracle Corporation. All rights reserved.