Top Description Fields Constructors Methods
org.glassfish.grizzly.http.server

public Class Session

extends Object
Class Inheritance
Imports
java.util.concurrent.ConcurrentHashMap, .ConcurrentMap

Simple session object.
Author
Jeanfrancois Arcand

Field Summary

Modifier and TypeField and Description
private final ConcurrentMap<String, Object>
attributes

Cache attribute (thread safe)

private final long
creationTime

When this session was created.

private String
id

A session identifier

private boolean
isNew

Is this session new.

private boolean
isValid

Is this Session valid.

private long
private long
timestamp

Creation time stamp.

Constructor Summary

AccessConstructor and Description
public
public
Session(String
session identifier
id
)

Create a new session using a session identifier

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

the time stamp
access
()

Updates the "last accessed" timestamp with the current time.

public ConcurrentMap<String, Object>

Returns:

the attributes associated with this session.
attributes
()

Return a ConcurrentMap of attributes.

public Object

Returns:

an attribute
getAttribute
(String key)

Return an attribute.

public long

Returns:

a long specifying when this session was created, expressed in milliseconds since 1/1/1970 GMT
getCreationTime
()

Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.

public String
getIdInternal()

Returns: the session identifier for this session.

public long

Returns:

a long representing the maximum idle time (in milliseconds) a session can be.
getSessionTimeout
()

Return a long representing the maximum idle time (in milliseconds) a session can be.

public long
getTimestamp()

Returns: the timestamp when this session was accessed the last time

public boolean

Returns:

true if the server has created a session, but the client has not yet joined
isNew
()

Returns true if the client does not yet know about the session or if the client chooses not to join the session.

public boolean

Returns:

true if valid.
isValid
()

Is the current Session valid?

public Object

Returns:

true if successful.
removeAttribute
(String key)

Remove an attribute.

public void
setAttribute(String key, Object value)

Add an attribute to this session.

protected void
setIdInternal(String id)

Sets the session identifier for this session.

public void
setSessionTimeout(long
a long representing the maximum idle time (in milliseconds) a session can be.
sessionTimeout
)

Set a long representing the maximum idle time (in milliseconds) a session can be.

public void
setTimestamp(long
a long representing when the session was accessed the last time
timestamp
)

Set the timestamp when this session was accessed the last time.

public void
setValid(boolean isValid)

Set this object as validated.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributesback to summary
private final ConcurrentMap<String, Object> attributes

Cache attribute (thread safe)

creationTimeback to summary
private final long creationTime

When this session was created.

idback to summary
private String id

A session identifier

isNewback to summary
private boolean isNew

Is this session new.

isValidback to summary
private boolean isValid

Is this Session valid.

sessionTimeoutback to summary
private long sessionTimeout

Timeout

timestampback to summary
private long timestamp

Creation time stamp.

Constructor Detail

Sessionback to summary
public Session()
Sessionback to summary
public Session(String id)

Create a new session using a session identifier

Parameters
id:String

session identifier

Method Detail

accessback to summary
public long access()

Updates the "last accessed" timestamp with the current time.

Returns:long

the time stamp

attributesback to summary
public ConcurrentMap<String, Object> attributes()

Return a ConcurrentMap of attributes.

Returns:ConcurrentMap<String, Object>

the attributes associated with this session.

getAttributeback to summary
public Object getAttribute(String key)

Return an attribute.

Returns:Object

an attribute

getCreationTimeback to summary
public long getCreationTime()

Returns the time when this session was created, measured in milliseconds since midnight January 1, 1970 GMT.

Returns:long

a long specifying when this session was created, expressed in milliseconds since 1/1/1970 GMT

getIdInternalback to summary
public String getIdInternal()
Returns:String

the session identifier for this session.

getSessionTimeoutback to summary
public long getSessionTimeout()

Return a long representing the maximum idle time (in milliseconds) a session can be.

Returns:long

a long representing the maximum idle time (in milliseconds) a session can be.

getTimestampback to summary
public long getTimestamp()
Returns:long

the timestamp when this session was accessed the last time

isNewback to summary
public boolean isNew()

Returns 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.

Returns:boolean

true if the server has created a session, but the client has not yet joined

isValidback to summary
public boolean isValid()

Is the current Session valid?

Returns:boolean

true if valid.

removeAttributeback to summary
public Object removeAttribute(String key)

Remove an attribute.

Returns:Object

true if successful.

setAttributeback to summary
public void setAttribute(String key, Object value)

Add an attribute to this session.

setIdInternalback to summary
protected void setIdInternal(String id)

Sets the session identifier for this session.

setSessionTimeoutback to summary
public void setSessionTimeout(long sessionTimeout)

Set a long representing the maximum idle time (in milliseconds) a session can be.

Parameters
sessionTimeout:long

a long representing the maximum idle time (in milliseconds) a session can be.

setTimestampback to summary
public void setTimestamp(long timestamp)

Set the timestamp when this session was accessed the last time.

Parameters
timestamp:long

a long representing when the session was accessed the last time

setValidback to summary
public void setValid(boolean isValid)

Set this object as validated.