Quadcap Embeddable Server

com.quadcap.http.server22.HSession Class Reference

Inheritance diagram for com.quadcap.http.server22.HSession:

HttpSession List of all members.

Detailed Description

This class implements the javax.servlet.http.HttpSession interface.

Author:
Stan Bailes

Definition at line 58 of file HSession.java.

Public Member Functions

 HSession (WebApplication app, String sessionId, int maxInactiveInterval)
 Construct a new session object.

String getId ()
 Returns the identifier assigned to this session.

HttpSessionContext getSessionContext ()
 Returns the context in which this session is bound.

long getCreationTime ()
 Returns the time at which this session representation was created, in milliseconds since midnight, January 1, 1970 UTC.

long getLastAccessedTime ()
 Returns the last time the client sent a request carrying the identifier assigned to the session.

void invalidate ()
 Causes this representation of the session to be invalidated and removed from its context.

void setAttribute (String name, Object value)
 Binds the specified object into the session's application layer data with the given name.

Object getAttribute (String name)
 Returns the object bound to the given name in the session's application layer data.

void removeAttribute (String name)
 Removes the object bound to the given name in the session's application layer data.

Enumeration getAttributeNames ()
 Return an enumeration of the names of objects in the session's application layer data.

String[] getValueNames ()
 Returns an array of the names of all the application layer data objects bound into the session.

Object getValue (String name)
void putValue (String name, Object value)
void removeValue (String name)
boolean isNew ()
 A session is considered to be "new" if it has been created by the server, but the client has not yet acknowledged joining the session.

int getMaxInactiveInterval ()
void setMaxInactiveInterval (int ivl)

Package Functions

boolean isValid ()
 ---- Package-private implementation -----

void setNotNew ()
void updateLastAccess ()

Package Attributes

WebApplication app
String sessionId
boolean valid = true
long creationTime = new Date().getTime()
long lastAccessTime = creationTime
int maxInactiveInterval
Hashtable appData = new Hashtable()
boolean newSession = true


Constructor & Destructor Documentation

com.quadcap.http.server22.HSession.HSession WebApplication  app,
String  sessionId,
int  maxInactiveInterval
 

Construct a new session object.

Parameters:
app the server context (session context) owning this session.
sessionId this session's id.

Definition at line 74 of file HSession.java.


Member Function Documentation

Object com.quadcap.http.server22.HSession.getAttribute String  name  ) 
 

Returns the object bound to the given name in the session's application layer data.

Returns null if there is no such binding.

Parameters:
name the name of the binding to find
Returns:
the value bound to that name, or null if the binding does not exist.
Exceptions:
IllegalStateException if an attempt is made to access HttpSession's session data after it has been invalidated

Definition at line 205 of file HSession.java.

References com.quadcap.http.server22.HSession.appData, com.quadcap.http.server22.HSession.getAttribute(), and com.quadcap.http.server22.HSession.valid.

Referenced by com.quadcap.http.server22.HSession.getAttribute().

Enumeration com.quadcap.http.server22.HSession.getAttributeNames  ) 
 

Return an enumeration of the names of objects in the session's application layer data.

Returns:
an enumeration of names

Definition at line 242 of file HSession.java.

References com.quadcap.http.server22.HSession.appData, and com.quadcap.http.server22.HSession.valid.

long com.quadcap.http.server22.HSession.getCreationTime  ) 
 

Returns the time at which this session representation was created, in milliseconds since midnight, January 1, 1970 UTC.

Returns:
the time when the session was created
Exceptions:
IllegalStateException if an attempt is made to access session data after the session has been invalidated

Definition at line 119 of file HSession.java.

References com.quadcap.http.server22.HSession.creationTime, and com.quadcap.http.server22.HSession.valid.

String com.quadcap.http.server22.HSession.getId  ) 
 

Returns the identifier assigned to this session.

An HttpSession's identifier is a unique string that is created and maintained by HttpSessionContext.

Returns:
the identifier assigned to this session
Exceptions:
IllegalStateException if an attempt is made to access session data after the session has been invalidated

Definition at line 91 of file HSession.java.

References com.quadcap.http.server22.HSession.sessionId, and com.quadcap.http.server22.HSession.valid.

Referenced by com.quadcap.http.server22.HttpRequest.getRequestedSessionId(), com.quadcap.http.server22.HttpRequest.getSession(), and com.quadcap.http.server22.WebApplication.removeSession().

long com.quadcap.http.server22.HSession.getLastAccessedTime  ) 
 

Returns the last time the client sent a request carrying the identifier assigned to the session.

Time is expressed as milliseconds since midnight, January 1, 1970 UTC. Application level operations, such as getting or setting a value associated with the session, does not affect the access time.

This information is particularly useful in session management policies. For example,

  • a session manager could leave all sessions which have not been used in a long time in a given context.
  • the sessions can be sorted according to age to optimize some task.

Returns:
the last time the client sent a request carrying the identifier assigned to the session
Exceptions:
IllegalStateException if an attempt is made to access session data after the session has been invalidated

Definition at line 146 of file HSession.java.

References com.quadcap.http.server22.HSession.lastAccessTime, and com.quadcap.http.server22.HSession.valid.

Referenced by com.quadcap.http.server22.WebApplication.expireSessions().

int com.quadcap.http.server22.HSession.getMaxInactiveInterval  ) 
 

Definition at line 310 of file HSession.java.

References com.quadcap.http.server22.HSession.maxInactiveInterval, and com.quadcap.http.server22.HSession.valid.

Referenced by com.quadcap.http.server22.WebApplication.expireSessions().

HttpSessionContext com.quadcap.http.server22.HSession.getSessionContext  ) 
 

Returns the context in which this session is bound.

Returns:
the name of the context in which this session is bound
Exceptions:
IllegalStateException if an attempt is made to access session data after the session has been invalidated
Deprecated:
in 2.2

Definition at line 104 of file HSession.java.

Object com.quadcap.http.server22.HSession.getValue String  name  ) 
 

Deprecated:

Definition at line 273 of file HSession.java.

References com.quadcap.http.server22.HSession.getValue().

Referenced by com.quadcap.http.server22.HSession.getValue().

String [] com.quadcap.http.server22.HSession.getValueNames  ) 
 

Returns an array of the names of all the application layer data objects bound into the session.

For example, if you want to delete all of the data objects bound into the session, use this method to obtain their names.

Returns:
an array containing the names of all of the application layer data objects bound into the session
Exceptions:
IllegalStateException if an attempt is made to access session data after the session has been invalidated
Deprecated:

Definition at line 259 of file HSession.java.

References com.quadcap.http.server22.HSession.appData, and com.quadcap.http.server22.HSession.valid.

void com.quadcap.http.server22.HSession.invalidate  ) 
 

Causes this representation of the session to be invalidated and removed from its context.

Exceptions:
IllegalStateException if an attempt is made to access session data after the session has been invalidated

Definition at line 158 of file HSession.java.

References com.quadcap.http.server22.HSession.app, com.quadcap.http.server22.HSession.appData, com.quadcap.http.server22.WebApplication.removeSession(), com.quadcap.http.server22.HSession.removeValue(), and com.quadcap.http.server22.HSession.valid.

Referenced by com.quadcap.http.server22.WebApplication.expireSessions(), and com.quadcap.http.server22.WebApplication.shutdown().

boolean com.quadcap.http.server22.HSession.isNew  ) 
 

A session is considered to be "new" if it has been created by the server, but the client has not yet acknowledged joining the session.

For example, if the server supported only cookie-based sessions and the client had completely disabled the use of cookies, then calls to HttpServletRequest.getSession() would always return "new" sessions.

Returns:
true if the session has been created by the server but the client has not yet acknowledged joining the session; false otherwise
Exceptions:
IllegalStateException if an attempt is made to access session data after the session has been invalidated

Definition at line 305 of file HSession.java.

References com.quadcap.http.server22.HSession.newSession, and com.quadcap.http.server22.HSession.valid.

boolean com.quadcap.http.server22.HSession.isValid  )  [package]
 

---- Package-private implementation -----

Definition at line 323 of file HSession.java.

References com.quadcap.http.server22.HSession.valid.

Referenced by com.quadcap.http.server22.HttpRequest.isRequestedSessionIdValid().

void com.quadcap.http.server22.HSession.putValue String  name,
Object  value
 

Deprecated:

Definition at line 280 of file HSession.java.

References com.quadcap.http.server22.HSession.putValue().

Referenced by com.quadcap.http.server22.HSession.putValue().

void com.quadcap.http.server22.HSession.removeAttribute String  name  ) 
 

Removes the object bound to the given name in the session's application layer data.

Does nothing if there is no object bound to the given name. The value that implements the HttpSessionBindingListener interface will call its valueUnbound() method.

Parameters:
name the name of the object to remove
Exceptions:
IllegalStateException if an attempt is made to access session data after the session has been invalidated

Definition at line 221 of file HSession.java.

References com.quadcap.http.server22.HSession.appData, com.quadcap.http.server22.HSession.removeAttribute(), and com.quadcap.http.server22.HSession.valid.

Referenced by com.quadcap.http.server22.HSession.removeAttribute().

void com.quadcap.http.server22.HSession.removeValue String  name  ) 
 

Deprecated:

Definition at line 287 of file HSession.java.

References com.quadcap.http.server22.HSession.removeValue().

Referenced by com.quadcap.http.server22.HSession.invalidate(), and com.quadcap.http.server22.HSession.removeValue().

void com.quadcap.http.server22.HSession.setAttribute String  name,
Object  value
 

Binds the specified object into the session's application layer data with the given name.

Any existing binding with the same name is replaced. New (or existing) values that implement the HttpSessionBindingListener interface will call its valueBound() method.

Parameters:
name the name to which the data object will be bound. This parameter cannot be null.
value the data object to be bound. This parameter cannot be null.
Exceptions:
IllegalStateException if an attempt is made to access session data after the session has been invalidated.

Definition at line 183 of file HSession.java.

References com.quadcap.http.server22.HSession.appData, com.quadcap.http.server22.HSession.setAttribute(), and com.quadcap.http.server22.HSession.valid.

Referenced by com.quadcap.http.server22.HSession.setAttribute().

void com.quadcap.http.server22.HSession.setMaxInactiveInterval int  ivl  ) 
 

Definition at line 314 of file HSession.java.

References com.quadcap.http.server22.HSession.setMaxInactiveInterval(), and com.quadcap.http.server22.HSession.valid.

Referenced by com.quadcap.http.server22.HSession.setMaxInactiveInterval().

void com.quadcap.http.server22.HSession.setNotNew  )  [package]
 

Definition at line 324 of file HSession.java.

References com.quadcap.http.server22.HSession.newSession.

void com.quadcap.http.server22.HSession.updateLastAccess  )  [package]
 

Definition at line 325 of file HSession.java.

References com.quadcap.http.server22.HSession.lastAccessTime.

Referenced by com.quadcap.http.server22.HttpRequest.getSession().


Member Data Documentation

WebApplication com.quadcap.http.server22.HSession.app [package]
 

Definition at line 59 of file HSession.java.

Referenced by com.quadcap.http.server22.HSession.invalidate().

Hashtable com.quadcap.http.server22.HSession.appData = new Hashtable() [package]
 

Definition at line 65 of file HSession.java.

Referenced by com.quadcap.http.server22.HSession.getAttribute(), com.quadcap.http.server22.HSession.getAttributeNames(), com.quadcap.http.server22.HSession.getValueNames(), com.quadcap.http.server22.HSession.invalidate(), com.quadcap.http.server22.HSession.removeAttribute(), and com.quadcap.http.server22.HSession.setAttribute().

long com.quadcap.http.server22.HSession.creationTime = new Date().getTime() [package]
 

Definition at line 62 of file HSession.java.

Referenced by com.quadcap.http.server22.HSession.getCreationTime().

long com.quadcap.http.server22.HSession.lastAccessTime = creationTime [package]
 

Definition at line 63 of file HSession.java.

Referenced by com.quadcap.http.server22.HSession.getLastAccessedTime(), and com.quadcap.http.server22.HSession.updateLastAccess().

int com.quadcap.http.server22.HSession.maxInactiveInterval [package]
 

Definition at line 64 of file HSession.java.

Referenced by com.quadcap.http.server22.HSession.getMaxInactiveInterval().

boolean com.quadcap.http.server22.HSession.newSession = true [package]
 

Definition at line 66 of file HSession.java.

Referenced by com.quadcap.http.server22.HSession.isNew(), and com.quadcap.http.server22.HSession.setNotNew().

String com.quadcap.http.server22.HSession.sessionId [package]
 

Definition at line 60 of file HSession.java.

Referenced by com.quadcap.http.server22.HSession.getId().

boolean com.quadcap.http.server22.HSession.valid = true [package]
 

Definition at line 61 of file HSession.java.

Referenced by com.quadcap.http.server22.HSession.getAttribute(), com.quadcap.http.server22.HSession.getAttributeNames(), com.quadcap.http.server22.HSession.getCreationTime(), com.quadcap.http.server22.HSession.getId(), com.quadcap.http.server22.HSession.getLastAccessedTime(), com.quadcap.http.server22.HSession.getMaxInactiveInterval(), com.quadcap.http.server22.HSession.getValueNames(), com.quadcap.http.server22.HSession.invalidate(), com.quadcap.http.server22.HSession.isNew(), com.quadcap.http.server22.HSession.isValid(), com.quadcap.http.server22.HSession.removeAttribute(), com.quadcap.http.server22.HSession.setAttribute(), and com.quadcap.http.server22.HSession.setMaxInactiveInterval().