Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.lutris.appserver.server.session
Class BasicSessionHome  view BasicSessionHome download BasicSessionHome.java

java.lang.Object
  extended bycom.lutris.appserver.server.session.BasicSessionHome
All Implemented Interfaces:
StandardSessionHome

public class BasicSessionHome
extends java.lang.Object
implements StandardSessionHome

BasicSessionHome creates instances of BasicSession and manages the 'active'/'passive' state of those sessions. All sessions created by BasicSessionHome are held in memory.

The following parameters can be used to configure the BasicSessionHome. They should be grouped together in a section, normally SessionManager.SessionHome, which is specified to the constructor.

Version:
$Revision: 1.5.2.1.4.1 $

Field Summary
private  java.util.Hashtable activeCache
          The active cache holds sessions that are in the 'active' state.
private  java.util.Hashtable activeThreadCache
          The active thread cache holds all the association between active sessions and the threads that have checked them out.
private  java.lang.String MAX_SESSIONS_KEY
          Configuration keys.
private  long maxSessions
          Maximum number of allowed sessions.
private  java.util.Hashtable passiveCache
          The active cache holds sessions that are in the 'active' state.
private  StandardSessionManager sessionMgr
          The session manager associated with the session home.
private  long UNDEFINED_MAX_SESSIONS
           
 
Constructor Summary
BasicSessionHome(StandardSessionManager sessionMgr, com.lutris.util.Config config)
           
BasicSessionHome(StandardSessionManager sessionMgr, com.lutris.util.Config config, java.lang.ClassLoader loader)
           
 
Method Summary
private  void cleanupNewSession()
          Cleans up (removes) the oldest unused session from the passive cache.
 boolean containsKey(java.lang.String sessionKey)
          Specifies if a key is currently bound to a session.
 StandardSession createSession(java.lang.String sessionKey)
          Creates and returns a new session instance.
private  void debug(int level, java.lang.String msg)
          Prints debug information under Logger.DEBUG.
private  void debug(java.lang.String msg)
          Prints debug information under Logger.DEBUG.
 StandardSession getSession(java.lang.String sessionKey)
          Returns the session bound to the session key.
 StandardSession getSession(java.lang.Thread thread, java.lang.String sessionKey)
          Returns the session bound to the specified session key.
 java.util.Enumeration keys()
          Returns an enumeration of the keys for all the sessions.
 int pagedSize()
          Returns the current number of sessions that are paged to persistent store.
 void passivateSession(java.lang.Thread thread, java.lang.String sessionKey)
          Puts a session into the 'passive' state.
 void removeSession(java.lang.String sessionKey)
          Removes a session from the cache.
 void shutdown()
          Shuts dows the session home.
 int size()
          Returns the current number of sessions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

activeCache

private java.util.Hashtable activeCache
The active cache holds sessions that are in the 'active' state.


activeThreadCache

private java.util.Hashtable activeThreadCache
The active thread cache holds all the association between active sessions and the threads that have checked them out.


passiveCache

private java.util.Hashtable passiveCache
The active cache holds sessions that are in the 'active' state. There is a single mapping of keys to session objects: sessionKey -> session


maxSessions

private long maxSessions
Maximum number of allowed sessions.


MAX_SESSIONS_KEY

private final java.lang.String MAX_SESSIONS_KEY
Configuration keys.

See Also:
Constant Field Values

UNDEFINED_MAX_SESSIONS

private final long UNDEFINED_MAX_SESSIONS
See Also:
Constant Field Values

sessionMgr

private StandardSessionManager sessionMgr
The session manager associated with the session home.

Constructor Detail

BasicSessionHome

public BasicSessionHome(StandardSessionManager sessionMgr,
                        com.lutris.util.Config config)
                 throws com.lutris.util.ConfigException

BasicSessionHome

public BasicSessionHome(StandardSessionManager sessionMgr,
                        com.lutris.util.Config config,
                        java.lang.ClassLoader loader)
                 throws com.lutris.util.ConfigException
Method Detail

createSession

public StandardSession createSession(java.lang.String sessionKey)
                              throws CreateSessionException,
                                     DuplicateKeyException,
                                     SessionException
Creates and returns a new session instance. The session is bound to the specified session key. The session is also associated with the current thread and is considered in the 'active' state. The session remains in the 'active' state until the thread puts the session into the 'passive' state.. Only this thread will be able to put the session into the 'passive' state.

Specified by:
createSession in interface StandardSessionHome

getSession

public StandardSession getSession(java.lang.String sessionKey)
                           throws SessionException
Returns the session bound to the session key. The session must already be in the 'active' state and associated with the current thread, otherwise null is returned.

Specified by:
getSession in interface StandardSessionHome

getSession

public StandardSession getSession(java.lang.Thread thread,
                                  java.lang.String sessionKey)
                           throws SessionException
Returns the session bound to the specified session key. The session is put into the 'active' state. The session is also associated with the specified thread. Only this thread will be able to put the session back into the 'passive' state once it is done with the session.

Specified by:
getSession in interface StandardSessionHome

removeSession

public void removeSession(java.lang.String sessionKey)
                   throws SessionException
Removes a session from the cache. If the session doesn't exist the opration is ignored.

Specified by:
removeSession in interface StandardSessionHome

passivateSession

public void passivateSession(java.lang.Thread thread,
                             java.lang.String sessionKey)
                      throws SessionException
Puts a session into the 'passive' state. A 'passive' session may be made persistent. Only the thread that put the session into the 'active' state may put the session into the 'passive' state.

Specified by:
passivateSession in interface StandardSessionHome

containsKey

public boolean containsKey(java.lang.String sessionKey)
                    throws SessionException
Specifies if a key is currently bound to a session.

Specified by:
containsKey in interface StandardSessionHome

size

public int size()
         throws SessionException
Returns the current number of sessions.

Specified by:
size in interface StandardSessionHome

pagedSize

public int pagedSize()
              throws SessionException
Returns the current number of sessions that are paged to persistent store.

Specified by:
pagedSize in interface StandardSessionHome

keys

public java.util.Enumeration keys()
                           throws SessionException
Returns an enumeration of the keys for all the sessions.

Specified by:
keys in interface StandardSessionHome

cleanupNewSession

private void cleanupNewSession()
                        throws SessionException
Cleans up (removes) the oldest unused session from the passive cache.


shutdown

public void shutdown()
Shuts dows the session home.

Specified by:
shutdown in interface StandardSessionHome

debug

private void debug(java.lang.String msg)
Prints debug information under Logger.DEBUG.


debug

private void debug(int level,
                   java.lang.String msg)
Prints debug information under Logger.DEBUG.