Class Session
java.lang.Object
org.glassfish.grizzly.http.server.Session
Simple session object.
- Author:
- Jeanfrancois Arcand
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongaccess()Updates the "last accessed" timestamp with the current time.Return aConcurrentMapof attributes.getAttribute(String key) Return an attribute.longReturns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.longReturn a long representing the maximum idle time (in milliseconds) a session can be.longbooleanisNew()Returnstrueif the client does not yet know about the session or if the client chooses not to join the session.booleanisValid()Is the current Session valid?removeAttribute(String key) Remove an attribute.voidsetAttribute(String key, Object value) Add an attribute to this session.protected voidsetIdInternal(String id) Sets the session identifier for this session.voidsetSessionTimeout(long sessionTimeout) Set a long representing the maximum idle time (in milliseconds) a session can be.voidsetTimestamp(long timestamp) Set the timestamp when this session was accessed the last time.voidsetValid(boolean isValid) Set this object as validated.
-
Constructor Details
-
Session
public Session() -
Session
Create a new session using a session identifier- Parameters:
id- session identifier
-
-
Method Details
-
isValid
public boolean isValid()Is the current Session valid?- Returns:
- true if valid.
-
setValid
public void setValid(boolean isValid) Set this object as validated.- Parameters:
isValid-
-
isNew
public boolean isNew()Returnstrueif 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.- Returns:
trueif the server has created a session, but the client has not yet joined
-
getIdInternal
- Returns:
- the session identifier for this session.
-
setIdInternal
Sets the session identifier for this session.- Parameters:
id-
-
setAttribute
Add an attribute to this session.- Parameters:
key-value-
-
getAttribute
Return an attribute.- Parameters:
key-- Returns:
- an attribute
-
removeAttribute
Remove an attribute.- Parameters:
key-- Returns:
- true if successful.
-
attributes
Return aConcurrentMapof attributes.- Returns:
- the attributes associated with this session.
-
getCreationTime
public long getCreationTime()Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.- Returns:
- a
longspecifying when this session was created, expressed in milliseconds since 1/1/1970 GMT
-
getSessionTimeout
public long getSessionTimeout()Return a long representing the maximum idle time (in milliseconds) a session can be.- Returns:
- a long representing the maximum idle time (in milliseconds) a session can be.
-
setSessionTimeout
public void setSessionTimeout(long sessionTimeout) Set a long representing the maximum idle time (in milliseconds) a session can be.- Parameters:
sessionTimeout- a long representing the maximum idle time (in milliseconds) a session can be.
-
getTimestamp
public long getTimestamp()- Returns:
- the timestamp when this session was accessed the last time
-
setTimestamp
public void setTimestamp(long timestamp) Set the timestamp when this session was accessed the last time.- Parameters:
timestamp- a long representing when the session was accessed the last time
-
access
public long access()Updates the "last accessed" timestamp with the current time.- Returns:
- the time stamp
-