org.wso2.carbon.webapp.mgt

## 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.Lifecycle, org.apache.catalina.Manager

      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 and Description
    --- | ---
    `protected static String` | `name` 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

      `container, distributable, duplicates, expiredSessions, maxActive, maxActiveSessions, maxInactiveInterval, processExpiresFrequency, processingTime, rejectedSessions, secureRandomAlgorithm, secureRandomClass, secureRandomProvider, SESSION_ID_LENGTH_UNSET, sessionCounter, sessionCreationTiming, sessionExpirationTiming, sessionIdGenerator, sessionIdGeneratorClass, sessionIdLength, 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 and Description
    `CarbonTomcatSessionPersistentManager()`
    `CarbonTomcatSessionPersistentManager(int ownerTenantId)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `org.apache.catalina.Session` | `findSession(String id)` Return the active Session, associated with this Manager, with the specified session id (if any); otherwise return `null`.
    `org.apache.catalina.Session[]` | `findSessions()` Return the set of active Sessions associated with this Manager.
    `int` | `getActiveSessions()` Returns the number of active sessions
    `long` | `getExpiredSessions()` Gets the number of sessions that have expired.
    `String` | `getInfo()` Return descriptive information about this Manager implementation and the corresponding version number, in the format `description/version`.
    `int` | `getMaxActive()` Max number of concurrent active sessions
    `int` | `getMaxInactiveInterval()` Return the default maximum inactive interval (in seconds) for Sessions created by this Manager.
    `String` | `getName()` Return the descriptive short name of this Manager implementation.
    `int` | `getRejectedSessions()` Returns the number of session creations that failed due to maxActiveSessions
    `int` | `getSessionAverageAliveTime()` 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, createEmptySession, createSession, expireSession, generateSessionId, getClassName, getContainer, getCreationTime, getCreationTimestamp, getDistributable, getDomainInternal, getDuplicates, getEngine, getJvmRoute, getLastAccessedTime, getLastAccessedTimestamp, getMaxActiveSessions, getNewSession, getObjectNameKeyProperties, getProcessExpiresFrequency, getProcessingTime, getSecureRandomAlgorithm, getSecureRandomClass, getSecureRandomProvider, getSession, getSessionAttribute, getSessionAttributeNameFilter, getSessionAttributeNamePattern, getSessionAttributeValueClassNameFilter, getSessionAttributeValueClassNamePattern, getSessionCounter, getSessionCreateRate, getSessionExpireRate, getSessionIdGenerator, getSessionIdLength, getSessionMaxAliveTime, getThisAccessedTime, getThisAccessedTimestamp, getWarnOnSessionAttributeFilterFailure, initInternal, listSessionIds, remove, removePropertyChangeListener, setContainer, setDistributable, setDuplicates, setExpiredSessions, setMaxActive, setMaxActiveSessions, setMaxInactiveInterval, setProcessExpiresFrequency, setProcessingTime, setSecureRandomAlgorithm, setSecureRandomClass, setSecureRandomProvider, setSessionAttributeNameFilter, setSessionAttributeValueClassNameFilter, setSessionCounter, setSessionIdGenerator, setSessionIdLength, setWarnOnSessionAttributeFilterFailure, toString, updateSessionMaxAliveTime, willAttributeDistribute`

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

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

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

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

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### name

          protected static final String name

      The descriptive name of this Manager implementation (for logging).
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### CarbonTomcatSessionPersistentManager

          public CarbonTomcatSessionPersistentManager()

    - #### CarbonTomcatSessionPersistentManager

          public CarbonTomcatSessionPersistentManager(int ownerTenantId)

  - ### Method Detail

    - #### getInfo

          public String getInfo()

      Return descriptive information about this Manager implementation and the corresponding version number, in the format `description/version`.
      Specified by:
        `getInfo` in interface `org.apache.catalina.Manager`
      Overrides:
        `getInfo` in class `org.apache.catalina.session.PersistentManagerBase`

    - #### 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

    - #### getMaxInactiveInterval

          public int getMaxInactiveInterval()

      Return the default maximum inactive interval (in seconds) for Sessions created by this Manager.
      Specified by:
        `getMaxInactiveInterval` in interface `org.apache.catalina.Manager`
      Overrides:
        `getMaxInactiveInterval` in class `org.apache.catalina.session.ManagerBase`
      Returns:
        Inactive time in minutes

    - #### 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

Copyright © 2017 WSO2. All rights reserved.