Class CarbonTomcatSessionPersistentManager

java.lang.Object
org.apache.catalina.util.LifecycleBase
org.apache.catalina.util.LifecycleMBeanBase
org.apache.catalina.session.ManagerBase
org.apache.catalina.session.PersistentManagerBase
org.wso2.carbon.webapp.mgt.CarbonTomcatSessionPersistentManager
All Implemented Interfaces:
MBeanRegistration, org.apache.catalina.DistributedManager, org.apache.catalina.JmxEnabled, org.apache.catalina.Lifecycle, org.apache.catalina.Manager, org.apache.catalina.StoreManager

public class CarbonTomcatSessionPersistentManager extends org.apache.catalina.session.PersistentManagerBase
CarbonTomcatSessionPersistentManager which ensures that one tenant's sessions cannot be accessed by other tenants. Super tenant should be able to access all sessions

PersistentManager has the capability to swap active (but idle) sessions out to a persistent storage mechanism, as well as to save all sessions across a normal restart of Tomcat. The actual persistent storage mechanism used is selected by your choice of a Store element nested inside the Manager element - this is required for use of PersistentManager.

  • Nested Class Summary

    Nested classes/interfaces inherited from class org.apache.catalina.session.ManagerBase

    org.apache.catalina.session.ManagerBase.SessionTiming

    Nested classes/interfaces inherited from interface org.apache.catalina.Lifecycle

    org.apache.catalina.Lifecycle.SingleUse
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final String
    The descriptive name of this Manager implementation (for logging).

    Fields inherited from class org.apache.catalina.session.PersistentManagerBase

    maxIdleBackup, maxIdleSwap, minIdleSwap, saveOnRestart, store

    Fields inherited from class org.apache.catalina.session.ManagerBase

    duplicates, expiredSessions, maxActive, maxActiveSessions, processExpiresFrequency, processingTime, rejectedSessions, secureRandomAlgorithm, secureRandomClass, secureRandomProvider, sessionCounter, sessionCreationTiming, sessionExpirationTiming, sessionIdGenerator, sessionIdGeneratorClass, sessionMaxAliveTime, sessions, sm, support, TIMING_STATS_CACHE_SIZE

    Fields inherited from class org.apache.catalina.util.LifecycleMBeanBase

    mserver

    Fields inherited from interface org.apache.catalina.Lifecycle

    AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
  • Constructor Summary

    Constructors
    Constructor
    Description
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.catalina.Session
    Return the active Session, associated with this Manager, with the specified session id (if any); otherwise return null.
    org.apache.catalina.Session[]
    Return the set of active Sessions associated with this Manager.
    int
    Returns the number of active sessions
    long
    Gets the number of sessions that have expired.
    int
    Max number of concurrent active sessions
    Return the descriptive short name of this Manager implementation.
    int
    Returns the number of session creations that failed due to maxActiveSessions
    int
    Gets the average time (in seconds) that expired sessions had been alive.
    void
    setOwnerTenantId(int ownerTenantId)
    Sets the tenantID of the tenant who owns this Tomcat Session Manager
    void
    setSessionMaxAliveTime(int sessionMaxAliveTime)
    Sets the longest time (in seconds) that an expired session had been alive.

    Methods inherited from class org.apache.catalina.session.PersistentManagerBase

    clearStore, getActiveSessionsFull, getMaxIdleBackup, getMaxIdleSwap, getMinIdleSwap, getSaveOnRestart, getSessionIdsFull, getStore, isLoaded, load, processExpires, processMaxActiveSwaps, processMaxIdleBackups, processMaxIdleSwaps, processPersistenceChecks, remove, removeSession, removeSuper, setMaxIdleBackup, setMaxIdleSwap, setMinIdleSwap, setSaveOnRestart, setStore, startInternal, stopInternal, swapIn, swapOut, unload, writeSession

    Methods inherited from class org.apache.catalina.session.ManagerBase

    add, addPropertyChangeListener, backgroundProcess, changeSessionId, changeSessionId, changeSessionId, createEmptySession, createSession, expireSession, generateSessionId, getClassName, getContext, getCreationTime, getCreationTimestamp, getDomainInternal, getDuplicates, getEngine, getJvmRoute, getLastAccessedTime, getLastAccessedTimestamp, getMaxActiveSessions, getNewSession, getNotifyAttributeListenerOnUnchangedValue, getNotifyBindingListenerOnUnchangedValue, getObjectNameKeyProperties, getPersistAuthentication, getProcessExpiresFrequency, getProcessingTime, getSecureRandomAlgorithm, getSecureRandomClass, getSecureRandomProvider, getSession, getSessionAttribute, getSessionAttributeNameFilter, getSessionAttributeNamePattern, getSessionAttributeValueClassNameFilter, getSessionAttributeValueClassNamePattern, getSessionCounter, getSessionCreateRate, getSessionExpireRate, getSessionIdGenerator, getSessionMaxAliveTime, getThisAccessedTime, getThisAccessedTimestamp, getWarnOnSessionAttributeFilterFailure, initInternal, listSessionIds, remove, removePropertyChangeListener, rotateSessionId, setContext, setDuplicates, setExpiredSessions, setMaxActive, setMaxActiveSessions, setNotifyAttributeListenerOnUnchangedValue, setNotifyBindingListenerOnUnchangedValue, setPersistAuthentication, setProcessExpiresFrequency, setProcessingTime, setSecureRandomAlgorithm, setSecureRandomClass, setSecureRandomProvider, setSessionAttributeNameFilter, setSessionAttributeValueClassNameFilter, setSessionCounter, setSessionIdGenerator, setWarnOnSessionAttributeFilterFailure, toString, updateSessionMaxAliveTime, willAttributeDistribute

    Methods inherited from class org.apache.catalina.util.LifecycleMBeanBase

    destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregister

    Methods inherited from class org.apache.catalina.util.LifecycleBase

    addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • name

      protected static final String name
      The descriptive name of this Manager implementation (for logging).
      See Also:
  • Constructor Details

    • CarbonTomcatSessionPersistentManager

      public CarbonTomcatSessionPersistentManager()
    • CarbonTomcatSessionPersistentManager

      public CarbonTomcatSessionPersistentManager(int ownerTenantId)
  • Method Details

    • getName

      public String getName()
      Return the descriptive short name of this Manager implementation.
      Overrides:
      getName in class org.apache.catalina.session.PersistentManagerBase
    • getMaxActive

      public int getMaxActive()
      Max number of concurrent active sessions
      Specified by:
      getMaxActive in interface org.apache.catalina.Manager
      Overrides:
      getMaxActive in class org.apache.catalina.session.ManagerBase
      Returns:
      The highest number of concurrent active sessions
    • getActiveSessions

      public int getActiveSessions()
      Returns the number of active sessions
      Specified by:
      getActiveSessions in interface org.apache.catalina.Manager
      Overrides:
      getActiveSessions in class org.apache.catalina.session.ManagerBase
      Returns:
      number of sessions active
    • getExpiredSessions

      public long getExpiredSessions()
      Gets the number of sessions that have expired.
      Specified by:
      getExpiredSessions in interface org.apache.catalina.Manager
      Overrides:
      getExpiredSessions in class org.apache.catalina.session.ManagerBase
      Returns:
      Number of sessions that have expired
    • getRejectedSessions

      public int getRejectedSessions()
      Returns the number of session creations that failed due to maxActiveSessions
      Specified by:
      getRejectedSessions in interface org.apache.catalina.Manager
      Overrides:
      getRejectedSessions in class org.apache.catalina.session.ManagerBase
      Returns:
      rejected count
    • setSessionMaxAliveTime

      public void setSessionMaxAliveTime(int sessionMaxAliveTime)
      Sets the longest time (in seconds) that an expired session had been alive.
      Specified by:
      setSessionMaxAliveTime in interface org.apache.catalina.Manager
      Overrides:
      setSessionMaxAliveTime in class org.apache.catalina.session.ManagerBase
      Parameters:
      sessionMaxAliveTime - sessionMaxAliveTime Longest time (in seconds) that an expired session had been alive.
    • getSessionAverageAliveTime

      public int getSessionAverageAliveTime()
      Gets the average time (in seconds) that expired sessions had been alive.
      Specified by:
      getSessionAverageAliveTime in interface org.apache.catalina.Manager
      Overrides:
      getSessionAverageAliveTime in class org.apache.catalina.session.ManagerBase
      Returns:
      Average time (in seconds) that expired sessions had been alive.
    • findSessions

      public org.apache.catalina.Session[] findSessions()
      Return the set of active Sessions associated with this Manager. If this Manager has no active Sessions, a zero-length array is returned.
      Specified by:
      findSessions in interface org.apache.catalina.Manager
      Overrides:
      findSessions in class org.apache.catalina.session.ManagerBase
      Returns:
      Session objects associated with this Manager as a result set
    • findSession

      public org.apache.catalina.Session findSession(String id) throws IOException
      Return the active Session, associated with this Manager, with the specified session id (if any); otherwise return null.
      Specified by:
      findSession in interface org.apache.catalina.Manager
      Overrides:
      findSession in class org.apache.catalina.session.PersistentManagerBase
      Parameters:
      id - The session id for the session to be returned
      Returns:
      associated session
      Throws:
      IOException - if an input/output error occurs while processing this request
      IllegalStateException - if a new session cannot be instantiated for any reason
    • setOwnerTenantId

      public void setOwnerTenantId(int ownerTenantId)
      Sets the tenantID of the tenant who owns this Tomcat Session Manager
      Parameters:
      ownerTenantId - Relevant tenantID which is associated to CarbonTomcatSessionPersistentManager