org.jboss.web.tomcat.tc5.session
Class JBossManagerCMP

java.lang.Object
  extended byStandardManager
      extended byorg.jboss.web.tomcat.tc5.session.JBossManagerCMP
All Implemented Interfaces:
AbstractJBossManager (src) , JBossManagerCMPMBean (src)

public class JBossManagerCMP
extends StandardManager
implements AbstractJBossManager (src) , JBossManagerCMPMBean (src)

Implementation of a clustered session manager for catalina.

See Also:
ClusteredHTTPSessionService (src) , Serialized Form

Field Summary
protected  int invalidateSessionPolicy
           
protected  ObjectName (src) objectName
          The objectname this Manager is associated with
protected  int replicationType
           
protected  boolean started
          Is the reaper-thread started?
 
Constructor Summary
JBossManagerCMP()
           
 
Method Summary
 void add(Session session)
          Add session to this Manager
 Session createSession()
          Create a new session
 Session findSession(java.lang.String id)
          Find the session for the given id
 java.lang.String getInfo()
          Get a informational string about this class
 int getInvalidateSessionPolicy()
          The session invalidation policy.
 java.lang.String getJvmRouteId(java.lang.String id)
          Generate new sessionid for a new jvmRoute - during failover
 java.lang.Integer getLocalActiveSessionCount()
           
 int getReplicationType()
           
 org.jboss.web.tomcat.tc5.session.ClusteredSession[] getSessions()
           
 void init(java.lang.String name, WebMetaData (src)  webMetaData, boolean useJK, boolean useLocalCache)
          Initialize the manager with the web metadata and
 boolean isUseLocalCache()
           
 void load()
          Load persisted sessions (NOT supported by this Manager)
protected  org.jboss.web.tomcat.tc5.session.ClusteredSessionCMP loadSession(java.lang.String id)
          Load a session from the distributed store
 void processExpires()
          Go through all sessions and look if they have expired
protected  void recycle(Session session)
           
 void remove(Session session)
          Removes a session from this Manager
 void removeLocal(Session session)
          Remove a session from the local store only
protected  void removeSession(java.lang.String id)
          Remove a session from the distributed store
 void run()
          Overloaded run()-method of the session-cleanup-thread.
 void setNewSessionCookie(java.lang.String sessionId, HttpServletResponse response)
          Sets a new cookie for the given session id and response
 void setSessionCookie(java.lang.String sessionId)
          Sets a new cookie for the given session id and response
 void start()
          Start this Manager
protected  void startManager()
          Prepare for the beginning of active use of the public methods of this component.
 void stop()
          Stop this Manager
protected  void stopManager()
          Gracefully terminate the active use of the public methods of this component.
 boolean storeSession(Session session)
          Store a session in the distributed store
 void unload()
          Load persisted sessions (NOT supported by this Manager)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.web.tomcat.tc5.session.AbstractJBossManager (src)
getJvmRoute
 

Field Detail

objectName

protected ObjectName (src)  objectName
The objectname this Manager is associated with


started

protected boolean started
Is the reaper-thread started?


invalidateSessionPolicy

protected int invalidateSessionPolicy

replicationType

protected int replicationType
Constructor Detail

JBossManagerCMP

public JBossManagerCMP()
Method Detail

init

public void init(java.lang.String name,
                 WebMetaData (src)  webMetaData,
                 boolean useJK,
                 boolean useLocalCache)
          throws ClusteringNotSupportedException (src) 
Description copied from interface: AbstractJBossManager (src)
Initialize the manager with the web metadata and

Specified by:
init in interface AbstractJBossManager (src)
Parameters:
name -
webMetaData -
useJK -
useLocalCache -
Throws:
ClusteringNotSupportedException (src)

isUseLocalCache

public boolean isUseLocalCache()

getLocalActiveSessionCount

public java.lang.Integer getLocalActiveSessionCount()
Specified by:
getLocalActiveSessionCount in interface JBossManagerCMPMBean (src)

getSessions

public org.jboss.web.tomcat.tc5.session.ClusteredSession[] getSessions()

getInvalidateSessionPolicy

public int getInvalidateSessionPolicy()
Description copied from interface: AbstractJBossManager (src)
The session invalidation policy. One of: SESSION_INVALIDATE_ACCESS =0; SESSION_INVALIDATE_SET_AND_GET =1; SESSION_INVALIDATE_SET_AND_NON_PRIMITIVE_GET =2; SESSION_INVALIDATE_SET =3;

Specified by:
getInvalidateSessionPolicy in interface AbstractJBossManager (src)
Returns:
the invalidation policy constant

getReplicationType

public int getReplicationType()

createSession

public Session createSession()
Create a new session


getJvmRouteId

public java.lang.String getJvmRouteId(java.lang.String id)
Generate new sessionid for a new jvmRoute - during failover

Parameters:
id - The session id

setSessionCookie

public void setSessionCookie(java.lang.String sessionId)
Sets a new cookie for the given session id and response

Parameters:
sessionId - The session id

setNewSessionCookie

public void setNewSessionCookie(java.lang.String sessionId,
                                HttpServletResponse response)
Description copied from interface: AbstractJBossManager (src)
Sets a new cookie for the given session id and response

Specified by:
setNewSessionCookie in interface AbstractJBossManager (src)
Parameters:
sessionId - The session id

findSession

public Session findSession(java.lang.String id)
                    throws java.io.IOException
Find the session for the given id

Parameters:
id - The session id
Returns:
The session for the given id or null if not found in local or distributed store
Throws:
java.io.IOException

add

public void add(Session session)
Add session to this Manager

Parameters:
session - The session that wants to be added

remove

public void remove(Session session)
Removes a session from this Manager

Parameters:
session - that wants to be removed

removeLocal

public void removeLocal(Session session)
Remove a session from the local store only

Specified by:
removeLocal in interface AbstractJBossManager (src)
Parameters:
session - the session to be removed

recycle

protected void recycle(Session session)

getInfo

public java.lang.String getInfo()
Get a informational string about this class

Returns:
Information string

start

public void start()
           throws LifecycleException
Start this Manager

Throws:
LifecycleException

stop

public void stop()
          throws LifecycleException
Stop this Manager

Throws:
LifecycleException

startManager

protected void startManager()
                     throws LifecycleException
Prepare for the beginning of active use of the public methods of this component. This method should be called after configure(), and before any of the public methods of the component are utilized.

Throws:
java.lang.IllegalStateException - if this component has already been started
LifecycleException - if this component detects a fatal error that prevents this component from being used

stopManager

protected void stopManager()
                    throws LifecycleException
Gracefully terminate the active use of the public methods of this component. This method should be the last one called on a given instance of this component.

Throws:
java.lang.IllegalStateException - if this component has not been started
LifecycleException - if this component detects a fatal error that needs to be reported

load

public void load()
          throws java.lang.ClassNotFoundException,
                 java.io.IOException
Load persisted sessions (NOT supported by this Manager)

Throws:
java.lang.ClassNotFoundException
java.io.IOException

unload

public void unload()
            throws java.io.IOException
Load persisted sessions (NOT supported by this Manager)

Throws:
java.io.IOException

run

public void run()
Overloaded run()-method of the session-cleanup-thread. We have our own cleanup-code - so no code here


storeSession

public boolean storeSession(Session session)
Store a session in the distributed store

Specified by:
storeSession in interface AbstractJBossManager (src)
Parameters:
session - The session to store

loadSession

protected org.jboss.web.tomcat.tc5.session.ClusteredSessionCMP loadSession(java.lang.String id)
Load a session from the distributed store

Parameters:
id - The session-id for the session to load
Returns:
the session or null if the session cannot be found in the distributed store

removeSession

protected void removeSession(java.lang.String id)
Remove a session from the distributed store

Parameters:
id - The session-id for the session to remove

processExpires

public void processExpires()
Go through all sessions and look if they have expired