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

java.lang.Object
  extended byorg.jboss.web.tomcat.tc5.session.JBossManager
All Implemented Interfaces:
AbstractJBossManager (src) , java.util.EventListener, JBossManagerMBean (src) , java.beans.PropertyChangeListener
Direct Known Subclasses:
JBossCacheManager (src)

public abstract class JBossManager
extends java.lang.Object
implements AbstractJBossManager (src) , JBossManagerMBean (src) , java.beans.PropertyChangeListener

Base abstract implementation of Tomcat manager without the concept of session operations, e.g., add, remove, etc.


Field Summary
protected  int activeCounter_
           
protected  Container container_
          The Container with which this Manager is associated.
protected  int createdCounter_
           
protected  boolean distributable_
          /** The distributable flag for Sessions created by this Manager.
protected  int expiredCounter_
           
protected  int invalidateSessionPolicy_
          Policy to determine if a session is dirty
protected  LifecycleSupport lifecycle_
          The lifecycle_ event support for this component.
protected  Logger (src) log_
          The Log-object for this class
protected  int maxActive_
           
protected  int maxInactiveInterval_
          The default maximum inactive interval for Sessions created by this Manager.
protected  ObjectName (src) objectName_
          The objectname this Manager is associated with
protected  int rejectedCounter_
           
protected  int replicationGranularity_
          Replication granulairty.
protected  SessionIDGenerator (src) sessionIDGenerator_
           
protected  int sessionIdLength_
          The session id length of Sessions created by this Manager.
protected  java.util.Map sessions_
          Store the local sessions.
protected  boolean started_
          Has this component been started_ yet?
protected  ReplicationStatistics (src) stats_
           
protected  java.beans.PropertyChangeSupport support_
          The property change support for this component.
protected  long timeSinceLastReset_
           
protected  boolean useLocalCache_
          If set to true, it will not replicate the access time stamp unless attributes are dirty.
 
Constructor Summary
JBossManager()
           
 
Method Summary
 void addLifecycleListener(LifecycleListener listener)
           
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void backgroundProcess()
           
 LifecycleListener[] findLifecycleListeners()
           
abstract  org.jboss.web.tomcat.tc5.session.ClusteredSession findLocalSession(java.lang.String realId)
          Find in-memory sessions, if any.
abstract  org.jboss.web.tomcat.tc5.session.ClusteredSession[] findLocalSessions()
          Find in-memory sessions, if any.
 long getActiveSessionCount()
           
 int getActiveSessions()
           
 Container getContainer()
           
 long getCreatedSessionCount()
           
 boolean getDistributable()
           
 Engine getEngine()
          Retrieve the enclosing Engine for this Manager.
 long getExpiredSessionCount()
           
 int getExpiredSessions()
           
 java.lang.String getInfo()
           
 int getInvalidateSessionPolicy()
          The session invalidation policy.
 java.lang.String getJvmRoute()
          Retrieve the JvmRoute for the enclosing Engine.
 int getMaxActive()
           
 int getMaxInactiveInterval()
           
protected  java.lang.String getNextId()
          Get a new session-id from the distributed store
 long getRejectedSessionCount()
           
 int getRejectedSessions()
           
 ReplicationStatistics (src) getReplicationStatistics()
           
 int getSessionAverageAliveTime()
           
 int getSessionCounter()
           
 int getSessionIdLength()
           
 int getSessionMaxAliveTime()
           
 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()
           
protected  void processExpires()
          Go through all sessions and look if they have expired
 void propertyChange(java.beans.PropertyChangeEvent evt)
           
 void removeLifecycleListener(LifecycleListener listener)
           
abstract  void removeLocal(Session session)
          Remove the active session locally from the manager without replicating to the cluster.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 java.lang.String reportReplicationStatistics()
           
 void resetStats()
           
 void setContainer(Container container)
           
 void setDistributable(boolean distributable)
           
 void setExpiredSessions(int expiredSessions)
           
 void setMaxActive(int maxActive)
           
 void setMaxInactiveInterval(int interval)
           
 void setNewSessionCookie(java.lang.String sessionId, HttpServletResponse response)
          Sets a new cookie for the given session id and response
 void setRejectedSessions(int rejectedSessions)
           
 void setSessionAverageAliveTime(int sessionAverageAliveTime)
           
 void setSessionCookie(java.lang.String sessionId)
          Sets a new cookie for the given session id and response
 void setSessionCounter(int sessionCounter)
           
 void setSessionIdLength(int idLength)
           
 void setSessionMaxAliveTime(int sessionMaxAliveTime)
           
 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.
abstract  boolean storeSession(Session session)
          Store the modified session.
 long timeInSecondsSinceLastReset()
           
 void unload()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stats_

protected ReplicationStatistics (src)  stats_

invalidateSessionPolicy_

protected int invalidateSessionPolicy_
Policy to determine if a session is dirty


replicationGranularity_

protected int replicationGranularity_
Replication granulairty.


lifecycle_

protected LifecycleSupport lifecycle_
The lifecycle_ event support for this component.


started_

protected boolean started_
Has this component been started_ yet?


objectName_

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


log_

protected Logger (src)  log_
The Log-object for this class


container_

protected Container container_
The Container with which this Manager is associated.


distributable_

protected boolean distributable_
/** The distributable flag for Sessions created by this Manager. If this flag is set to true, any user attributes added to a session controlled by this Manager must be Serializable.


maxInactiveInterval_

protected int maxInactiveInterval_
The default maximum inactive interval for Sessions created by this Manager.


sessionIdLength_

protected int sessionIdLength_
The session id length of Sessions created by this Manager.


maxActive_

protected int maxActive_

createdCounter_

protected int createdCounter_

rejectedCounter_

protected int rejectedCounter_

activeCounter_

protected int activeCounter_

expiredCounter_

protected int expiredCounter_

timeSinceLastReset_

protected long timeSinceLastReset_

sessions_

protected java.util.Map sessions_
Store the local sessions.


useLocalCache_

protected boolean useLocalCache_
If set to true, it will not replicate the access time stamp unless attributes are dirty.


support_

protected java.beans.PropertyChangeSupport support_
The property change support for this component.


sessionIDGenerator_

protected SessionIDGenerator (src)  sessionIDGenerator_
Constructor Detail

JBossManager

public JBossManager()
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)

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

getEngine

public Engine getEngine()
Retrieve the enclosing Engine for this Manager.

Returns:
an Engine object (or null).

getJvmRoute

public java.lang.String getJvmRoute()
Retrieve the JvmRoute for the enclosing Engine.

Specified by:
getJvmRoute in interface AbstractJBossManager (src)
Returns:
the JvmRoute or null.

getNextId

protected java.lang.String getNextId()
Get a new session-id from the distributed store

Returns:
new session-id

isUseLocalCache

public boolean isUseLocalCache()

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

getReplicationStatistics

public ReplicationStatistics (src)  getReplicationStatistics()
Specified by:
getReplicationStatistics in interface JBossManagerMBean (src)

resetStats

public void resetStats()
Specified by:
resetStats in interface JBossManagerMBean (src)

timeInSecondsSinceLastReset

public long timeInSecondsSinceLastReset()
Specified by:
timeInSecondsSinceLastReset in interface JBossManagerMBean (src)

getActiveSessionCount

public long getActiveSessionCount()
Specified by:
getActiveSessionCount in interface JBossManagerMBean (src)

getCreatedSessionCount

public long getCreatedSessionCount()
Specified by:
getCreatedSessionCount in interface JBossManagerMBean (src)

getExpiredSessionCount

public long getExpiredSessionCount()
Specified by:
getExpiredSessionCount in interface JBossManagerMBean (src)

getRejectedSessionCount

public long getRejectedSessionCount()
Specified by:
getRejectedSessionCount in interface JBossManagerMBean (src)

getSessionMaxAliveTime

public int getSessionMaxAliveTime()

setSessionMaxAliveTime

public void setSessionMaxAliveTime(int sessionMaxAliveTime)

getSessionAverageAliveTime

public int getSessionAverageAliveTime()

setSessionAverageAliveTime

public void setSessionAverageAliveTime(int sessionAverageAliveTime)

reportReplicationStatistics

public java.lang.String reportReplicationStatistics()
Specified by:
reportReplicationStatistics in interface JBossManagerMBean (src)

addLifecycleListener

public void addLifecycleListener(LifecycleListener listener)

findLifecycleListeners

public LifecycleListener[] findLifecycleListeners()

removeLifecycleListener

public void removeLifecycleListener(LifecycleListener listener)

start

public void start()
           throws LifecycleException
Start this Manager

Throws:
org.apache.catalina.LifecycleException
LifecycleException

stop

public void stop()
          throws LifecycleException
Stop this Manager

Throws:
org.apache.catalina.LifecycleException
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_
org.apache.catalina.LifecycleException - if this component detects a fatal error that prevents this component from being used
LifecycleException

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_
org.apache.catalina.LifecycleException - if this component detects a fatal error that needs to be reported
LifecycleException

getContainer

public Container getContainer()

setContainer

public void setContainer(Container container)

getDistributable

public boolean getDistributable()

setDistributable

public void setDistributable(boolean distributable)

getInfo

public java.lang.String getInfo()

getMaxInactiveInterval

public int getMaxInactiveInterval()

setMaxInactiveInterval

public void setMaxInactiveInterval(int interval)

getSessionIdLength

public int getSessionIdLength()

setSessionIdLength

public void setSessionIdLength(int idLength)

getSessionCounter

public int getSessionCounter()

setSessionCounter

public void setSessionCounter(int sessionCounter)

getMaxActive

public int getMaxActive()

setMaxActive

public void setMaxActive(int maxActive)

getExpiredSessions

public int getExpiredSessions()

setExpiredSessions

public void setExpiredSessions(int expiredSessions)

getRejectedSessions

public int getRejectedSessions()

setRejectedSessions

public void setRejectedSessions(int rejectedSessions)

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)

removeLocal

public abstract void removeLocal(Session session)
Remove the active session locally from the manager without replicating to the cluster. This can be useful when the session is exipred, for example, where there is not need to propagate the expiration.

Specified by:
removeLocal in interface AbstractJBossManager (src)
Parameters:
session -

storeSession

public abstract boolean storeSession(Session session)
Store the modified session.

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

getActiveSessions

public int getActiveSessions()

load

public void load()
          throws java.lang.ClassNotFoundException,
                 java.io.IOException
Throws:
java.lang.ClassNotFoundException
java.io.IOException

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)

unload

public void unload()
            throws java.io.IOException
Throws:
java.io.IOException

backgroundProcess

public void backgroundProcess()

processExpires

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


propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

findLocalSessions

public abstract org.jboss.web.tomcat.tc5.session.ClusteredSession[] findLocalSessions()
Find in-memory sessions, if any.

Returns:
local session found. Sessions of size 0, if not found.

findLocalSession

public abstract org.jboss.web.tomcat.tc5.session.ClusteredSession findLocalSession(java.lang.String realId)
Find in-memory sessions, if any.

Parameters:
realId - the Session id without JvmRoute tag.
Returns:
local session found. Null if not found.