org.apache.jcs.utils.servlet.session
Class DistSession

java.lang.Object
  extended byorg.apache.jcs.utils.servlet.session.DistSession
All Implemented Interfaces:
javax.servlet.http.HttpSession, ISessionConstants

public class DistSession
extends java.lang.Object
implements javax.servlet.http.HttpSession, ISessionConstants

DistSession uses the CompositeCache and GroupCache to create a failover-safe distributed session.

Author:
asmuts, Daniel Rall

Field Summary
private  javax.servlet.ServletContext context
           
private  boolean isNew
           
private  boolean isValid
           
private static org.apache.commons.logging.Log log
           
private static boolean REMOVE_ATTR_INVOCATION
           
private  GroupCacheAccess sessCache
           
private  SessionInfo sessInfo
           
private  java.lang.String session_id
           
private static boolean SET_ATTR_INVOCATION
           
 
Fields inherited from interface org.apache.jcs.utils.servlet.session.ISessionConstants
DFLT_INACTIVE_INTERVAL, SESS_CACHE_NAME, SESS_CACHE_SIZE, SESS_INFO_CACHE_NAME, SESS_INFO_CACHE_SIZE
 
Constructor Summary
DistSession()
          Constructor for a new instance with no ServletContext.
DistSession(javax.servlet.ServletContext context)
          Creates a new instance with the specified ServletContext.
 
Method Summary
 void access()
          Update the last access time.
 void clean()
          Clears the session information.
 java.lang.Object getAttribute(java.lang.String name)
          Gets the attribute attribute of the DistSession object
 java.util.Enumeration getAttributeNames()
          Gets the attributeNames attribute of the DistSession object
 long getCreationTime()
          Gets the creationTime attribute of the DistSession object
 java.lang.String getId()
          Gets the id attribute of the DistSession object
 long getLastAccessedTime()
          Gets the lastAccessedTime attribute of the DistSession object
 int getMaxInactiveInterval()
          Gets the maxInactiveInterval attribute of the DistSession object
 javax.servlet.ServletContext getServletContext()
          Returns a reference to the ServletContext this session is a part of.
 javax.servlet.http.HttpSessionContext getSessionContext()
          Deprecated. As of Version 2.1, this method is deprecated and has no replacement. It will be removed in a future version of the Java Servlet API.
 java.lang.Object getValue(java.lang.String name)
          Gets the value attribute of the DistSession object
 java.lang.String[] getValueNames()
          Gets the valueNames attribute of the DistSession object
 boolean init(java.lang.String session_id)
          Initialization for an existing session.
 void initNew()
          Initialization for a new session.
 void invalidate()
          Description of the Method
 boolean isNew()
          Gets the new attribute of the DistSession object
 void putValue(java.lang.String name, java.lang.Object value)
          Description of the Method
 void removeAttribute(java.lang.String name)
          Description of the Method
private  void removeAttribute(java.lang.String name, boolean invocation)
          Description of the Method
 void removeValue(java.lang.String name)
          Description of the Method
 void setAttribute(java.lang.String name, java.lang.Object value)
          Sets the attribute attribute of the DistSession object
 void setMaxInactiveInterval(int i)
          Sets the maxInactiveInterval attribute of the DistSession object
 java.lang.String toString()
          Description of the Method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static final org.apache.commons.logging.Log log

SET_ATTR_INVOCATION

private static boolean SET_ATTR_INVOCATION

REMOVE_ATTR_INVOCATION

private static boolean REMOVE_ATTR_INVOCATION

context

private javax.servlet.ServletContext context

session_id

private java.lang.String session_id

sessInfo

private SessionInfo sessInfo

sessCache

private GroupCacheAccess sessCache

isNew

private boolean isNew

isValid

private boolean isValid
Constructor Detail

DistSession

public DistSession()
Constructor for a new instance with no ServletContext. This method will eventually be deprecated in favor of DistSession(ServletContext).


DistSession

public DistSession(javax.servlet.ServletContext context)
Creates a new instance with the specified ServletContext.

Parameters:
context -
Method Detail

init

public boolean init(java.lang.String session_id)
Initialization for an existing session. The session must be initialized to be used. The sessInfo is not passed int he constructor, becaue these will be pooled.

Returns:
true if the init is successful;

initNew

public void initNew()
Initialization for a new session.


clean

public void clean()
Clears the session information.


getServletContext

public javax.servlet.ServletContext getServletContext()
Returns a reference to the ServletContext this session is a part of.


getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Gets the attribute attribute of the DistSession object

Specified by:
getAttribute in interface javax.servlet.http.HttpSession
Returns:
The attribute value

getAttributeNames

public java.util.Enumeration getAttributeNames()
Gets the attributeNames attribute of the DistSession object

Specified by:
getAttributeNames in interface javax.servlet.http.HttpSession
Returns:
The attributeNames value

getCreationTime

public long getCreationTime()
Gets the creationTime attribute of the DistSession object

Specified by:
getCreationTime in interface javax.servlet.http.HttpSession
Returns:
The creationTime value

getId

public java.lang.String getId()
Gets the id attribute of the DistSession object

Specified by:
getId in interface javax.servlet.http.HttpSession
Returns:
The id value

getLastAccessedTime

public long getLastAccessedTime()
Gets the lastAccessedTime attribute of the DistSession object

Specified by:
getLastAccessedTime in interface javax.servlet.http.HttpSession
Returns:
The lastAccessedTime value

access

public void access()
Update the last access time.


getMaxInactiveInterval

public int getMaxInactiveInterval()
Gets the maxInactiveInterval attribute of the DistSession object

Specified by:
getMaxInactiveInterval in interface javax.servlet.http.HttpSession
Returns:
The maxInactiveInterval value

getSessionContext

public javax.servlet.http.HttpSessionContext getSessionContext()
Deprecated. As of Version 2.1, this method is deprecated and has no replacement. It will be removed in a future version of the Java Servlet API.

Specified by:
getSessionContext in interface javax.servlet.http.HttpSession
Returns:
The sessionContext value

getValue

public java.lang.Object getValue(java.lang.String name)
Gets the value attribute of the DistSession object

Specified by:
getValue in interface javax.servlet.http.HttpSession
Returns:
The value value

getValueNames

public java.lang.String[] getValueNames()
Gets the valueNames attribute of the DistSession object

Specified by:
getValueNames in interface javax.servlet.http.HttpSession
Returns:
The valueNames value

invalidate

public void invalidate()
Description of the Method

Specified by:
invalidate in interface javax.servlet.http.HttpSession

isNew

public boolean isNew()
Gets the new attribute of the DistSession object

Specified by:
isNew in interface javax.servlet.http.HttpSession
Returns:
The new value

putValue

public void putValue(java.lang.String name,
                     java.lang.Object value)
Description of the Method

Specified by:
putValue in interface javax.servlet.http.HttpSession

removeAttribute

public void removeAttribute(java.lang.String name)
Description of the Method

Specified by:
removeAttribute in interface javax.servlet.http.HttpSession

removeAttribute

private void removeAttribute(java.lang.String name,
                             boolean invocation)
Description of the Method


removeValue

public void removeValue(java.lang.String name)
Description of the Method

Specified by:
removeValue in interface javax.servlet.http.HttpSession

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Sets the attribute attribute of the DistSession object

Specified by:
setAttribute in interface javax.servlet.http.HttpSession
Parameters:
name - The new attribute value
value - The new attribute value

setMaxInactiveInterval

public void setMaxInactiveInterval(int i)
Sets the maxInactiveInterval attribute of the DistSession object

Specified by:
setMaxInactiveInterval in interface javax.servlet.http.HttpSession
Parameters:
i - The new maxInactiveInterval value

toString

public java.lang.String toString()
Description of the Method