EAF 7.4 Implementation

com.lutris.appserver.server.sessionEnhydra
Class BasicSessionHome

java.lang.Object
  extended by com.lutris.appserver.server.sessionEnhydra.BasicSessionHome
All Implemented Interfaces:
com.lutris.appserver.server.sessionEnhydra.StandardSessionHome

public class BasicSessionHome
extends java.lang.Object
implements com.lutris.appserver.server.sessionEnhydra.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.3 $
Author:
Kyle Clark
See Also:
BasicSession, StandardSession, StandardSessionManager

Constructor Summary
BasicSessionHome(StandardSessionManager sessionMgr, com.lutris.util.Config config)
           
BasicSessionHome(StandardSessionManager sessionMgr, com.lutris.util.Config config, java.lang.ClassLoader loader)
           
 
Method Summary
 boolean containsKey(java.lang.String sessionKey)
          Specifies if a key is currently bound to a session.
 com.lutris.appserver.server.sessionEnhydra.StandardSession createSession(java.lang.String sessionKey)
          Creates and returns a new session instance.
protected  void debug(int level, java.lang.String msg)
          Prints debug information under Logger.DEBUG.
 com.lutris.appserver.server.sessionEnhydra.StandardSession getSession(java.lang.String sessionKey)
          Returns the session bound to the session key.
 com.lutris.appserver.server.sessionEnhydra.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
 

Constructor Detail

BasicSessionHome

public BasicSessionHome(StandardSessionManager sessionMgr,
                        com.lutris.util.Config config)
                 throws com.lutris.util.ConfigException
Parameters:
sessionMgr - The session manager associated with this session home.
config - Object parsed from configuration file. This should be for the section constaining the standard session home configuration.
Throws:
com.lutris.util.ConfigException - signifies a problem in the configuration file.

BasicSessionHome

public BasicSessionHome(StandardSessionManager sessionMgr,
                        com.lutris.util.Config config,
                        java.lang.ClassLoader loader)
                 throws com.lutris.util.ConfigException
Parameters:
sessionMgr - The session manager associated with this session home.
config - Object parsed from configuration file. This should be for the section constaining the standard session home configuration.
loader - The class load to use when load objects from persistent store.
Throws:
com.lutris.util.ConfigException - signifies a problem in the configuration file.
Method Detail

createSession

public com.lutris.appserver.server.sessionEnhydra.StandardSession createSession(java.lang.String sessionKey)
                                                                         throws com.lutris.appserver.server.sessionEnhydra.CreateSessionException,
                                                                                com.lutris.appserver.server.sessionEnhydra.DuplicateKeyException,
                                                                                com.lutris.appserver.server.session.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 com.lutris.appserver.server.sessionEnhydra.StandardSessionHome
Parameters:
sessionKey - the key to associate with the session.
Returns:
the newly created session.
Throws:
CreateSessionException - if the session cannot be created.
DuplicateKeyException - if the session cannot be created because the key is already in use.
com.lutris.appserver.server.session.SessionException - if an error occurs.
See Also:
passivateSession(java.lang.Thread, java.lang.String)

getSession

public com.lutris.appserver.server.sessionEnhydra.StandardSession getSession(java.lang.String sessionKey)
                                                                      throws com.lutris.appserver.server.session.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 com.lutris.appserver.server.sessionEnhydra.StandardSessionHome
Parameters:
sessionKey - the session key for the session. If the session doesn't exist or is not is not bound to the current thread then null is returned.
Returns:
the session.
Throws:
com.lutris.appserver.server.session.SessionException - if the session cannot be retrieved.
See Also:
getSession(Thread, String)

getSession

public com.lutris.appserver.server.sessionEnhydra.StandardSession getSession(java.lang.Thread thread,
                                                                             java.lang.String sessionKey)
                                                                      throws com.lutris.appserver.server.session.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 com.lutris.appserver.server.sessionEnhydra.StandardSessionHome
Parameters:
thread - the thread that should be associated with the session while it is in the active state. Only this thread can put the session back into the passive state.
sessionKey - the session key for the session that will be made 'active' and returned. If the session doesn't exist then null is returned.
Returns:
the session.
Throws:
com.lutris.appserver.server.session.SessionException - if the session cannot be retrieved.
See Also:
passivateSession(java.lang.Thread, java.lang.String)

removeSession

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

Specified by:
removeSession in interface com.lutris.appserver.server.sessionEnhydra.StandardSessionHome
Parameters:
sessionKey - the session key associated with the session.
Throws:
com.lutris.appserver.server.session.SessionException - if the session cannot be retrieved.

passivateSession

public void passivateSession(java.lang.Thread thread,
                             java.lang.String sessionKey)
                      throws com.lutris.appserver.server.session.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 com.lutris.appserver.server.sessionEnhydra.StandardSessionHome
Parameters:
thread - the thread that is currently associated with the session.
sessionKey - the session key for the session that will be made passive.
Throws:
com.lutris.appserver.server.session.SessionException - if the session cannot be retrieved.

containsKey

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

Specified by:
containsKey in interface com.lutris.appserver.server.sessionEnhydra.StandardSessionHome
Parameters:
sessionKey - the session key to be tested.
Returns:
true if the session key is in use.
Throws:
com.lutris.appserver.server.session.SessionException - if the existence of the key cannot be determined.

size

public int size()
         throws com.lutris.appserver.server.session.SessionException
Returns the current number of sessions.

Specified by:
size in interface com.lutris.appserver.server.sessionEnhydra.StandardSessionHome
Returns:
the 'active' session count.
Throws:
com.lutris.appserver.server.session.SessionException - if the size cannot be determined

pagedSize

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

Specified by:
pagedSize in interface com.lutris.appserver.server.sessionEnhydra.StandardSessionHome
Returns:
the 'paged' session count.
Throws:
com.lutris.appserver.server.session.SessionException - if the size cannot be determined

keys

public java.util.Enumeration keys()
                           throws com.lutris.appserver.server.session.SessionException
Returns an enumeration of the keys for all the sessions.

Specified by:
keys in interface com.lutris.appserver.server.sessionEnhydra.StandardSessionHome
Returns:
the enumeration of session keys.
Throws:
com.lutris.appserver.server.session.SessionException - if the session enumeration cannot be retrieved.

shutdown

public void shutdown()
Shuts dows the session home.

Specified by:
shutdown in interface com.lutris.appserver.server.sessionEnhydra.StandardSessionHome

debug

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

Parameters:
level - the debug level.
msg - the message to print.

EAF 7.4 Implementation