okapi.util
Class OkapiSession

java.lang.Object
  extended by okapi.util.OkapiSession

public class OkapiSession
extends java.lang.Object

The OkapiSession class provides a mechanism for tracking users within an OkapiSite and maintaining state within the application. It allows servlets to view and manipulate session-specific information, such as creation time and the unique session identifier. It also includes methods to bind objects to the session for later retrieval allowing the application to hold onto data between connections. OkapiSession utilizes a DB table to hold the session info, so that session-tracking can occur within a multi-server installation of an OkapiSite. However, a method is provided to cache the OkapiSession as an HttpSession, so that as long as a user is hitting the same server, DB calls are not required. Thus many methods have parallels in the javax.servlet.http.HttpSession interface.

Version:
$Revision: 31044 $, $Date: 2008-09-02 17:08:01 -0400 (Tue, 02 Sep 2008) $
Author:
MIT Stellar team

Constructor Summary
OkapiSession()
          Constructs OkapiSession with a new sessionID.
OkapiSession(java.lang.String sessionID)
          Constructs OkapiSession with this sessionID.
 
Method Summary
 java.lang.Object getAttribute(java.lang.String name)
          Returns the object bound in the session under the specified name or null if there is no matching binding.
 java.util.Enumeration getAttributeNames()
          Returns an Enumeration of String objects containing the names of all the objects bound to this session, or null if there are no bindings.
 java.util.Hashtable getAttributes()
          Returns all the name/value pairs in the session as a hashtable.
 java.util.Date getCreationTime()
          Returns the time at which the session was created.
 java.lang.String getID()
          Returns the unique String identifier assigned to this session.
 java.util.Date getLastAccessTime()
          Returns the time at which the client last sent a request associated with this session, as an Date object.
 java.lang.String getUserID()
          Returns the unique userID for the owner of this session.
 void invalidate()
          Causes the session to be immediately invalidated.
 boolean isNew()
          Returns whether the session is new.
 void removeAttribute(java.lang.String name)
          Removes the object bound to the specified name or does nothing if there is no binding.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Binds the specified object value under the specified name in the session.
 void updateHttpSession(javax.servlet.http.HttpSession servletSession)
          Updates the HttpSession with the values from the OkapiSession.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OkapiSession

public OkapiSession(java.lang.String sessionID)
Constructs OkapiSession with this sessionID.


OkapiSession

public OkapiSession()
Constructs OkapiSession with a new sessionID.

Method Detail

getCreationTime

public java.util.Date getCreationTime()
Returns the time at which the session was created.


getID

public java.lang.String getID()
Returns the unique String identifier assigned to this session.


getUserID

public java.lang.String getUserID()
Returns the unique userID for the owner of this session.


getLastAccessTime

public java.util.Date getLastAccessTime()
Returns the time at which the client last sent a request associated with this session, as an Date object.


getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Returns the object bound in the session under the specified name or null if there is no matching binding.


getAttributeNames

public java.util.Enumeration getAttributeNames()
Returns an Enumeration of String objects containing the names of all the objects bound to this session, or null if there are no bindings.


invalidate

public void invalidate()
Causes the session to be immediately invalidated. All objects stored in the session are unbound.


isNew

public boolean isNew()
Returns whether the session is new. A session is considered new if it has been created by the server but the client has not yet acknowledged joining the session (i.e., the cookie has not yet been created).


setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Binds the specified object value under the specified name in the session.


removeAttribute

public void removeAttribute(java.lang.String name)
Removes the object bound to the specified name or does nothing if there is no binding.


getAttributes

public java.util.Hashtable getAttributes()
Returns all the name/value pairs in the session as a hashtable.


updateHttpSession

public void updateHttpSession(javax.servlet.http.HttpSession servletSession)
Updates the HttpSession with the values from the OkapiSession.



Copyright ? 2001-2009 MIT. All Rights Reserved.