EAF 7.4 Implementation

com.lutris.appserver.server.sessionEnhydra
Class BasicSession

java.lang.Object
  extended by com.lutris.appserver.server.sessionEnhydra.BasicSession
All Implemented Interfaces:
com.lutris.appserver.server.session.Session, com.lutris.appserver.server.sessionEnhydra.StandardSession, java.io.Serializable, javax.servlet.http.HttpSession
Direct Known Subclasses:
PagedSession

public class BasicSession
extends java.lang.Object
implements com.lutris.appserver.server.sessionEnhydra.StandardSession, javax.servlet.http.HttpSession, java.io.Serializable

The standard implementation of the StandardSession interface. The session reflects and instance of a client interacting with the application. A BasicSession maybe associated with a user or exist in a unauthenticated state. The session manager associated with a BasicSession object must be a StandardSessionManager or a derivation.

Version:
$Revision: 1.5 $
Author:
John Marco, Shawn McMurdo
See Also:
Serialized Form

Field Summary
 SessionData data
          The application specific data for this session.
protected  StandardSessionManager sessionManager
           
protected  com.lutris.appserver.server.user.User user
           
 
Constructor Summary
  BasicSession()
          Need the following constructor in order to serialize?
protected BasicSession(StandardSessionManager sessionManager, java.lang.String sessionKey)
          Construct a new session.
protected BasicSession(StandardSessionManager sessionManager, java.lang.String sessionKey, SessionData sessionData)
          Construct a new session.
 
Method Summary
 void clearUser()
          Remove the user association with this session.
 int decrementRefCount()
          Returns the number of active references to this object.
 java.lang.Object getAttribute(java.lang.String name)
           
 java.util.Enumeration getAttributeNames()
           
 long getCreationTime()
           
 javax.servlet.http.HttpSession getHttpSession()
           
 java.lang.String getId()
           
 long getLastAccessedTime()
           
 long getMaxIdleTime()
          Obtain the maximum idle time for this object.
 int getMaxInactiveInterval()
           
 long getMaxNoUserIdleTime()
          Obtain the maximum idle time when a User object is not associated with the session.
 int getRefCount()
          Returns the number of active references to this object.
 javax.servlet.ServletContext getServletContext()
           
 javax.servlet.http.HttpSessionContext getSessionContext()
           
 SessionData getSessionData()
          Obtain the application specific data for this session.
 java.lang.String getSessionKey()
          Obtain the unique key associated with this session.
 com.lutris.appserver.server.session.SessionManager getSessionManager()
          Obtain the session manager associated with this session.
 long getTimeCreated()
          Obtain the creation time for this object.
 long getTimeExpires()
          Obtain the time of expiry for this object.
 long getTimeLastUsed()
          Obtain the time of last use for this object.
 com.lutris.appserver.server.user.User getUser()
          Obtain the user associated with this session.
 java.lang.Object getValue(java.lang.String name)
           
 java.lang.String[] getValueNames()
           
 int incrementRefCount()
          Returns the number of active references to this object.
 void invalidate()
           
 boolean isNew()
          Returns true if the session is new.
 void putValue(java.lang.String name, java.lang.Object value)
           
 void removeAttribute(java.lang.String name)
           
 void removeValue(java.lang.String name)
           
 void setAttribute(java.lang.String name, java.lang.Object value)
           
 void setHttpSession(javax.servlet.http.HttpSession httpSession)
           
 void setMaxIdleTime(long maxIdleTime)
          Set the maximum idle time for this object.
 void setMaxInactiveInterval(int interval)
           
 void setMaxNoUserIdleTime(long maxIdleTime)
          set the maximum idle time when a User object is not associated with the session.
 void setTimeExpires(long timeExpires)
          Set the time of expiry for this object.
 void setUser(com.lutris.appserver.server.user.User sessionUser)
          Set the user associated with this session.
 java.lang.String toString()
          Prints a string representation of this object.
 void touch()
          Set the "last used" timestamp to the current time, resetting the idle period.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sessionManager

protected transient StandardSessionManager sessionManager

user

protected com.lutris.appserver.server.user.User user

data

public SessionData data
The application specific data for this session.

Constructor Detail

BasicSession

public BasicSession()
Need the following constructor in order to serialize?


BasicSession

protected BasicSession(StandardSessionManager sessionManager,
                       java.lang.String sessionKey)
Construct a new session. Only called by StandardSessionManager.

Parameters:
sessionManager - The session manager that will manager this session.
sessionKey - The unique session key associated with the session.

BasicSession

protected BasicSession(StandardSessionManager sessionManager,
                       java.lang.String sessionKey,
                       SessionData sessionData)
Construct a new session. Only called by StandardSessionManager.

Parameters:
sessionManager - The session manager that will manager this session.
sessionKey - The unique session key associated with the session.
sessionData - The session data to associate with this session.
Method Detail

touch

public void touch()
Set the "last used" timestamp to the current time, resetting the idle period.

Specified by:
touch in interface com.lutris.appserver.server.sessionEnhydra.StandardSession

getUser

public com.lutris.appserver.server.user.User getUser()
Obtain the user associated with this session.

Specified by:
getUser in interface com.lutris.appserver.server.session.Session
Returns:
The user object or null if the session is not logged in.

setUser

public void setUser(com.lutris.appserver.server.user.User sessionUser)
             throws com.lutris.appserver.server.session.SessionException
Set the user associated with this session. This will register the user with the SessionManager.

If it is neccessary to prevent a user from logging on multiple times, this can be accomplished by synchronizing on the Sessionmanager object and enquiring about the number of users associated with a session. It is then possible to delete other sessions before adding a new session.

Specified by:
setUser in interface com.lutris.appserver.server.session.Session
Parameters:
user - the user object to associate with the session.
Throws:
com.lutris.appserver.server.session.SessionException - if the user cannot be associated with the session.

clearUser

public void clearUser()
               throws com.lutris.appserver.server.session.SessionException
Remove the user association with this session. This will unregister the user with the SessionManager.

Specified by:
clearUser in interface com.lutris.appserver.server.session.Session
Throws:
com.lutris.appserver.server.session.SessionException - if an error occurs.

getSessionKey

public java.lang.String getSessionKey()
Obtain the unique key associated with this session.

Specified by:
getSessionKey in interface com.lutris.appserver.server.session.Session
Returns:
A String containing the key for this session.

getSessionManager

public com.lutris.appserver.server.session.SessionManager getSessionManager()
Obtain the session manager associated with this session.

Specified by:
getSessionManager in interface com.lutris.appserver.server.session.Session
Returns:
The session manager object.

getSessionData

public SessionData getSessionData()
Obtain the application specific data for this session.

Specified by:
getSessionData in interface com.lutris.appserver.server.session.Session
Returns:
A SessionData object containing application specific data for this session.

getTimeCreated

public long getTimeCreated()
Obtain the creation time for this object. The time is in milliseconds since Midnight, Jan 1, 1970 (epoch).

Specified by:
getTimeCreated in interface com.lutris.appserver.server.sessionEnhydra.StandardSession
Returns:
The creation time since epoch for this object.

getTimeLastUsed

public long getTimeLastUsed()
Obtain the time of last use for this object. The time is in milliseconds since Midnight, Jan 1, 1970 (epoch).

Specified by:
getTimeLastUsed in interface com.lutris.appserver.server.sessionEnhydra.StandardSession
Returns:
The time of last use since epoch for this object.

getTimeExpires

public long getTimeExpires()
Obtain the time of expiry for this object. The time is in milliseconds since Midnight, Jan 1, 1970 (epoch). Returns zero (or negative) if there is no expiration date. Note: this is a maximum lifespan for the session, regardless of activity.

Specified by:
getTimeExpires in interface com.lutris.appserver.server.sessionEnhydra.StandardSession
Returns:
The time of expiry since epoch for this object.

setTimeExpires

public void setTimeExpires(long timeExpires)
Set the time of expiry for this object. The time is in milliseconds since Midnight, Jan 1, 1970 (epoch). Set this value to zero (or less) to indicate that the session does not have a maximum age.

Specified by:
setTimeExpires in interface com.lutris.appserver.server.sessionEnhydra.StandardSession
Parameters:
timeLastUsed - The time of expiry since epoch.

getMaxIdleTime

public long getMaxIdleTime()
Obtain the maximum idle time for this object. Zero (or negative) indicates that sessions may be idle indefinetly.

Specified by:
getMaxIdleTime in interface com.lutris.appserver.server.sessionEnhydra.StandardSession
Returns:
The maximum number of milliseconds this session may be idle.

setMaxIdleTime

public void setMaxIdleTime(long maxIdleTime)
Set the maximum idle time for this object. Set this to zero (or negative) to disable idle checking.

Specified by:
setMaxIdleTime in interface com.lutris.appserver.server.sessionEnhydra.StandardSession
Parameters:
maxIdleTime - The maximum number of milliseconds this session may be idle, or zero (or negative) to allow sessions to be idle indefinetly.

getMaxNoUserIdleTime

public long getMaxNoUserIdleTime()
Obtain the maximum idle time when a User object is not associated with the session. Zero (or negative) indicates that sessions may be idle indefinetly.

Specified by:
getMaxNoUserIdleTime in interface com.lutris.appserver.server.sessionEnhydra.StandardSession
Returns:
The maximum number of milliseconds this session may be idle.

setMaxNoUserIdleTime

public void setMaxNoUserIdleTime(long maxIdleTime)
set the maximum idle time when a User object is not associated with the session. Set this to zero (or negative) to disable idle checking.

Specified by:
setMaxNoUserIdleTime in interface com.lutris.appserver.server.sessionEnhydra.StandardSession
Parameters:
maxIdleTime - The maximum number of milliseconds this session may be idle.

isNew

public boolean isNew()
Returns true if the session is new. A session is new if it has been created but a client cookie was never used to reference it. In other words, the cookie associated with the session was never submitted by a client.

Specified by:
isNew in interface com.lutris.appserver.server.session.Session
Specified by:
isNew in interface javax.servlet.http.HttpSession
Returns:
true if the session is new.

getRefCount

public int getRefCount()
Returns the number of active references to this object.

Returns:
the number of references.

incrementRefCount

public int incrementRefCount()
Returns the number of active references to this object.

Returns:
the number of references.

decrementRefCount

public int decrementRefCount()
Returns the number of active references to this object.

Returns:
the number of references.

toString

public java.lang.String toString()
Prints a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
the string representation.

getHttpSession

public javax.servlet.http.HttpSession getHttpSession()
Specified by:
getHttpSession in interface com.lutris.appserver.server.session.Session
Specified by:
getHttpSession in interface com.lutris.appserver.server.sessionEnhydra.StandardSession

setHttpSession

public void setHttpSession(javax.servlet.http.HttpSession httpSession)
Specified by:
setHttpSession in interface com.lutris.appserver.server.session.Session

getCreationTime

public long getCreationTime()
Specified by:
getCreationTime in interface javax.servlet.http.HttpSession

getId

public java.lang.String getId()
Specified by:
getId in interface javax.servlet.http.HttpSession

getLastAccessedTime

public long getLastAccessedTime()
Specified by:
getLastAccessedTime in interface javax.servlet.http.HttpSession

setMaxInactiveInterval

public void setMaxInactiveInterval(int interval)
Specified by:
setMaxInactiveInterval in interface javax.servlet.http.HttpSession

getMaxInactiveInterval

public int getMaxInactiveInterval()
Specified by:
getMaxInactiveInterval in interface javax.servlet.http.HttpSession

getSessionContext

public javax.servlet.http.HttpSessionContext getSessionContext()
Specified by:
getSessionContext in interface javax.servlet.http.HttpSession

getServletContext

public javax.servlet.ServletContext getServletContext()
Specified by:
getServletContext in interface javax.servlet.http.HttpSession

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Specified by:
getAttribute in interface javax.servlet.http.HttpSession

getValue

public java.lang.Object getValue(java.lang.String name)
Specified by:
getValue in interface javax.servlet.http.HttpSession

getAttributeNames

public java.util.Enumeration getAttributeNames()
Specified by:
getAttributeNames in interface javax.servlet.http.HttpSession

getValueNames

public java.lang.String[] getValueNames()
Specified by:
getValueNames in interface javax.servlet.http.HttpSession

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Specified by:
setAttribute in interface javax.servlet.http.HttpSession

putValue

public void putValue(java.lang.String name,
                     java.lang.Object value)
Specified by:
putValue in interface javax.servlet.http.HttpSession

removeAttribute

public void removeAttribute(java.lang.String name)
Specified by:
removeAttribute in interface javax.servlet.http.HttpSession

removeValue

public void removeValue(java.lang.String name)
Specified by:
removeValue in interface javax.servlet.http.HttpSession

invalidate

public void invalidate()
Specified by:
invalidate in interface javax.servlet.http.HttpSession

EAF 7.4 Implementation