Package org.apache.catalina.session
Class ManagerBase
java.lang.Object
org.apache.catalina.util.LifecycleBase
org.apache.catalina.util.LifecycleMBeanBase
org.apache.catalina.session.ManagerBase
- All Implemented Interfaces:
MBeanRegistration,JmxEnabled,Lifecycle,Manager
- Direct Known Subclasses:
ClusterManagerBase,PersistentManagerBase,StandardManager
Minimal implementation of the Manager interface that supports no session persistence or distributable
capabilities. This class may be subclassed to create more sophisticated Manager implementations.
- Author:
- Craig R. McClanahan
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.apache.catalina.Lifecycle
Lifecycle.SingleUse -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intDeprecated.This will be removed in Tomcat 11protected final AtomicLongNumber of sessions that have expired.protected intprotected intThe maximum number of active Sessions allowed, or -1 for no limit.protected intFrequency of the session expiration, and related manager operations.protected longProcessing time during session expiration.protected intNumber of session creations that failed due to maxActiveSessions.protected StringThe name of the algorithm to use to create instances ofSecureRandomwhich are used to generate session IDs.protected StringThe Java class name of the secure random number generator class to be used when generating session identifiers.protected StringThe name of the provider to use to create instances ofSecureRandomwhich are used to generate session IDs.protected longDeprecated.This will be removed in Tomcat 11protected final Deque<ManagerBase.SessionTiming> protected final Deque<ManagerBase.SessionTiming> protected SessionIdGeneratorprotected Class<? extends SessionIdGenerator> protected intThe longest time (in seconds) that an expired session had been alive.The set of currently active Sessions for this Manager, keyed by session identifier.protected static final StringManagerThe string manager for this package.protected final PropertyChangeSupportThe property change support for this component.protected static final intFields 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 -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd this Session to the set of active Sessions for this Manager.voidAdd a property change listener to this component.voidThis method will be invoked by the context/container on a periodic basis and allows the manager to implement a method that executes periodic tasks, such as expiring sessions etc.voidchangeSessionId(Session session, String newId) Change the session ID of the current session to a specified session ID.protected voidchangeSessionId(Session session, String newId, boolean notifySessionListeners, boolean notifyContainerListeners) Get a session from the recycled ones or create a new empty one.createSession(String sessionId) Construct and return a new session object, based on the default settings specified by this Manager's properties.voidexpireSession(String sessionId) findSession(String id) Return the active Session, associated with this Manager, with the specified session id (if any); otherwise returnnull.Session[]Return the set of active Sessions associated with this Manager.protected StringGenerate and return a new session identifier.intGets the number of currently active sessions.Get the Context with which this Manager is associated.getCreationTime(String sessionId) longgetCreationTimestamp(String sessionId) Method implemented by sub-classes to identify the domain in which MBeans should be registered.intDeprecated.This will be removed in Tomcat 11Retrieve the enclosing Engine for this Manager.longGets the number of sessions that have expired.Retrieve the JvmRoute for the enclosing Engine.getLastAccessedTime(String sessionId) longgetLastAccessedTimestamp(String sessionId) intGets the maximum number of sessions that have been active at the same time.intgetName()protected StandardSessionGet new session class to be used in the doLoad() method.booleanWhen an attribute that is already present in the session is added again under the same name and aHttpSessionAttributeListeneris configured for the session shouldHttpSessionAttributeListener.attributeReplaced(jakarta.servlet.http.HttpSessionBindingEvent)be called?booleanWhen an attribute that is already present in the session is added again under the same name and the attribute implementsHttpSessionBindingListener, shouldHttpSessionBindingListener.valueUnbound(jakarta.servlet.http.HttpSessionBindingEvent)be called followed byHttpSessionBindingListener.valueBound(jakarta.servlet.http.HttpSessionBindingEvent)?Allow sub-classes to specify the key properties component of theObjectNamethat will be used to register this component.booleanReturn whether sessions managed by this manager shall persist authentication information or not.intlongintGets the number of sessions that were not created because the maximum number of active sessions was reached.getSession(String sessionId) Returns information about the session with the given session id.booleanIf this istrue, Tomcat will track the number of active requests for each session.getSessionAttribute(String sessionId, String key) For debugging.Obtain the regular expression used to filter session attribute based on attribute name.protected PatternProvidesgetSessionAttributeNameFilter()as a pre-compiled regular expression pattern.Obtain the regular expression used to filter session attribute based on the implementation class of the value.protected PatternProvidesgetSessionAttributeValueClassNameFilter()as a pre-compiled regular expression pattern.intGets the average time (in seconds) that expired sessions had been alive.longReturns the total number of sessions created by this manager, which is approximated as the number of active sessions plus the number of expired sessions.intGets the current rate of session creation (in session per minute).intGets the current rate of session expiration (in session per minute).booleanIf this istrue, the last accessed time for sessions will be calculated from the beginning of the previous request.intGets the longest time (in seconds) that an expired session had been alive.getThisAccessedTime(String sessionId) longgetThisAccessedTimestamp(String sessionId) booleanShould a warn level log message be generated if a session attribute is not persisted / replicated / restored.protected voidSub-classes implement this method to perform any instance initialisation required.For debugging.voidInvalidate all sessions that have expired.voidRemove this Session from the active Sessions for this Manager.voidRemove this Session from the active Sessions for this Manager.voidRemove a property change listener from this component.rotateSessionId(Session session) Change the session ID of the current session to a new randomly generated session ID.voidsetContext(Context context) Set the Context with which this Manager is associated.voidsetDuplicates(int duplicates) Deprecated.This will be removed in Tomcat 11voidsetExpiredSessions(long expiredSessions) Sets the number of sessions that have expired.voidsetMaxActive(int maxActive) (Re)sets the maximum number of sessions that have been active at the same time.voidsetMaxActiveSessions(int max) Set the maximum number of active Sessions allowed, or -1 for no limit.voidsetNotifyAttributeListenerOnUnchangedValue(boolean notifyAttributeListenerOnUnchangedValue) Configure ifHttpSessionAttributeListener.attributeReplaced(jakarta.servlet.http.HttpSessionBindingEvent)when an attribute that is already present in the session is added again under the same name and aHttpSessionAttributeListeneris configured for the session.voidsetNotifyBindingListenerOnUnchangedValue(boolean notifyBindingListenerOnUnchangedValue) Configure ifHttpSessionBindingListener.valueUnbound(jakarta.servlet.http.HttpSessionBindingEvent)be called followed byHttpSessionBindingListener.valueBound(jakarta.servlet.http.HttpSessionBindingEvent)when an attribute that is already present in the session is added again under the same name and the attribute implementsHttpSessionBindingListener.voidsetPersistAuthentication(boolean persistAuthentication) Set whether sessions managed by this manager shall persist authentication information or not.voidsetProcessExpiresFrequency(int processExpiresFrequency) Set the manager checks frequency.voidsetProcessingTime(long processingTime) voidsetSecureRandomAlgorithm(String secureRandomAlgorithm) Set the secure random number generator algorithm name.voidsetSecureRandomClass(String secureRandomClass) Set the secure random number generator class name.voidsetSecureRandomProvider(String secureRandomProvider) Set the secure random number generator provider name.voidsetSessionActivityCheck(boolean sessionActivityCheck) Configure if Tomcat will track the number of active requests for each session.voidsetSessionAttributeNameFilter(String sessionAttributeNameFilter) Set the regular expression to use to filter session attributes based on attribute name.voidsetSessionAttributeValueClassNameFilter(String sessionAttributeValueClassNameFilter) Set the regular expression to use to filter classes used for session attributes.voidsetSessionCounter(long sessionCounter) Sets the total number of sessions created by this manager.voidsetSessionIdGenerator(SessionIdGenerator sessionIdGenerator) Sets the session id generatorvoidsetSessionLastAccessAtStart(boolean sessionLastAccessAtStart) Configure if the last accessed time for sessions will be calculated from the beginning of the previous request.voidsetSessionMaxAliveTime(int sessionMaxAliveTime) Sets the longest time (in seconds) that an expired session had been alive.voidsetWarnOnSessionAttributeFilterFailure(boolean warnOnSessionAttributeFilterFailure) Configure whether or not a warn level log message should be generated if a session attribute is not persisted / replicated / restored.protected voidSub-classes must ensure that the state is changed toLifecycleState.STARTINGduring the execution of this method.protected voidSub-classes must ensure that the state is changed toLifecycleState.STOPPINGduring the execution of this method.toString()voidupdateSessionMaxAliveTime(int sessionAliveTime) Updates the sessionMaxAliveTime attribute if the candidate value is larger than the current value.booleanwillAttributeDistribute(String name, Object value) Would the Manager distribute the given session attribute?Methods inherited from class org.apache.catalina.util.LifecycleMBeanBase
destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregisterMethods inherited from class org.apache.catalina.util.LifecycleBase
addLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, getThrowOnFailure, init, removeLifecycleListener, setState, setState, setThrowOnFailure, start, stop
-
Field Details
-
secureRandomClass
The Java class name of the secure random number generator class to be used when generating session identifiers. The random number generator class must be self-seeding and have a zero-argument constructor. If not specified, an instance ofSecureRandomwill be generated. -
secureRandomAlgorithm
The name of the algorithm to use to create instances ofSecureRandomwhich are used to generate session IDs. If no algorithm is specified, SHA1PRNG is used. If SHA1PRNG is not available, the platform default will be used. To use the platform default (which may be SHA1PRNG), specify the empty string. If an invalid algorithm and/or provider is specified the SecureRandom instances will be created using the defaults. If that fails, the SecureRandom instances will be created using platform defaults. -
secureRandomProvider
The name of the provider to use to create instances ofSecureRandomwhich are used to generate session IDs. If no provider is specified the platform default is used. If an invalid algorithm and/or provider is specified the SecureRandom instances will be created using the defaults. If that fails, the SecureRandom instances will be created using platform defaults. -
sessionIdGenerator
-
sessionIdGeneratorClass
-
sessionMaxAliveTime
protected volatile int sessionMaxAliveTimeThe longest time (in seconds) that an expired session had been alive. -
TIMING_STATS_CACHE_SIZE
protected static final int TIMING_STATS_CACHE_SIZE- See Also:
-
sessionCreationTiming
-
sessionExpirationTiming
-
expiredSessions
Number of sessions that have expired. -
sessions
-
sessionCounter
Deprecated.This will be removed in Tomcat 11Number of sessions created by this manager. -
maxActive
protected volatile int maxActive -
maxActiveSessions
protected int maxActiveSessionsThe maximum number of active Sessions allowed, or -1 for no limit. -
rejectedSessions
protected int rejectedSessionsNumber of session creations that failed due to maxActiveSessions. -
duplicates
Deprecated.This will be removed in Tomcat 11Number of duplicated session ids, anything > 0 means we have problems. -
processingTime
protected long processingTimeProcessing time during session expiration. -
processExpiresFrequency
protected int processExpiresFrequencyFrequency of the session expiration, and related manager operations. Manager operations will be done once for the specified amount of backgroundProcess calls (ie, the lower the amount, the most often the checks will occur). -
sm
The string manager for this package. -
support
The property change support for this component.
-
-
Constructor Details
-
ManagerBase
public ManagerBase()
-
-
Method Details
-
getNotifyAttributeListenerOnUnchangedValue
public boolean getNotifyAttributeListenerOnUnchangedValue()Description copied from interface:ManagerWhen an attribute that is already present in the session is added again under the same name and aHttpSessionAttributeListeneris configured for the session shouldHttpSessionAttributeListener.attributeReplaced(jakarta.servlet.http.HttpSessionBindingEvent)be called?The default value is
true.- Specified by:
getNotifyAttributeListenerOnUnchangedValuein interfaceManager- Returns:
trueif the listener will be notified,falseif it will not
-
setNotifyAttributeListenerOnUnchangedValue
public void setNotifyAttributeListenerOnUnchangedValue(boolean notifyAttributeListenerOnUnchangedValue) Description copied from interface:ManagerConfigure ifHttpSessionAttributeListener.attributeReplaced(jakarta.servlet.http.HttpSessionBindingEvent)when an attribute that is already present in the session is added again under the same name and aHttpSessionAttributeListeneris configured for the session.- Specified by:
setNotifyAttributeListenerOnUnchangedValuein interfaceManager- Parameters:
notifyAttributeListenerOnUnchangedValue-truethe listener will be called,falseit will not
-
getNotifyBindingListenerOnUnchangedValue
public boolean getNotifyBindingListenerOnUnchangedValue()Description copied from interface:ManagerWhen an attribute that is already present in the session is added again under the same name and the attribute implementsHttpSessionBindingListener, shouldHttpSessionBindingListener.valueUnbound(jakarta.servlet.http.HttpSessionBindingEvent)be called followed byHttpSessionBindingListener.valueBound(jakarta.servlet.http.HttpSessionBindingEvent)?The default value is
false.- Specified by:
getNotifyBindingListenerOnUnchangedValuein interfaceManager- Returns:
trueif the listener will be notified,falseif it will not
-
setNotifyBindingListenerOnUnchangedValue
public void setNotifyBindingListenerOnUnchangedValue(boolean notifyBindingListenerOnUnchangedValue) Description copied from interface:ManagerConfigure ifHttpSessionBindingListener.valueUnbound(jakarta.servlet.http.HttpSessionBindingEvent)be called followed byHttpSessionBindingListener.valueBound(jakarta.servlet.http.HttpSessionBindingEvent)when an attribute that is already present in the session is added again under the same name and the attribute implementsHttpSessionBindingListener.- Specified by:
setNotifyBindingListenerOnUnchangedValuein interfaceManager- Parameters:
notifyBindingListenerOnUnchangedValue-truethe listener will be called,falseit will not
-
getSessionActivityCheck
public boolean getSessionActivityCheck()Description copied from interface:ManagerIf this istrue, Tomcat will track the number of active requests for each session. When determining if a session is valid, any session with at least one active request will always be considered valid. Iforg.apache.catalina.STRICT_SERVLET_COMPLIANCEis set totrue, the default of this setting will betrue, else the default value will befalse.- Specified by:
getSessionActivityCheckin interfaceManager- Returns:
- the flag value
-
setSessionActivityCheck
public void setSessionActivityCheck(boolean sessionActivityCheck) Description copied from interface:ManagerConfigure if Tomcat will track the number of active requests for each session. When determining if a session is valid, any session with at least one active request will always be considered valid.- Specified by:
setSessionActivityCheckin interfaceManager- Parameters:
sessionActivityCheck- the new flag value
-
getSessionLastAccessAtStart
public boolean getSessionLastAccessAtStart()Description copied from interface:ManagerIf this istrue, the last accessed time for sessions will be calculated from the beginning of the previous request. Iffalse, the last accessed time for sessions will be calculated from the end of the previous request. This also affects how the idle time is calculated. Iforg.apache.catalina.STRICT_SERVLET_COMPLIANCEis set totrue, the default of this setting will betrue, else the default value will befalse.- Specified by:
getSessionLastAccessAtStartin interfaceManager- Returns:
- the flag value
-
setSessionLastAccessAtStart
public void setSessionLastAccessAtStart(boolean sessionLastAccessAtStart) Description copied from interface:ManagerConfigure if the last accessed time for sessions will be calculated from the beginning of the previous request. Iffalse, the last accessed time for sessions will be calculated from the end of the previous request. This also affects how the idle time is calculated.- Specified by:
setSessionLastAccessAtStartin interfaceManager- Parameters:
sessionLastAccessAtStart- the new flag value
-
getSessionAttributeNameFilter
Obtain the regular expression used to filter session attribute based on attribute name. The regular expression is anchored so it must match the entire name- Returns:
- The regular expression currently used to filter attribute names.
nullmeans no filter is applied. If an empty string is specified then no names will match the filter and all attributes will be blocked.
-
setSessionAttributeNameFilter
public void setSessionAttributeNameFilter(String sessionAttributeNameFilter) throws PatternSyntaxException Set the regular expression to use to filter session attributes based on attribute name. The regular expression is anchored so it must match the entire name.- Parameters:
sessionAttributeNameFilter- The regular expression to use to filter session attributes based on attribute name. Usenullif no filtering is required. If an empty string is specified then no names will match the filter and all attributes will be blocked.- Throws:
PatternSyntaxException- If the expression is not valid
-
getSessionAttributeNamePattern
ProvidesgetSessionAttributeNameFilter()as a pre-compiled regular expression pattern.- Returns:
- The pre-compiled pattern used to filter session attributes based on attribute name.
nullmeans no filter is applied.
-
getSessionAttributeValueClassNameFilter
Obtain the regular expression used to filter session attribute based on the implementation class of the value. The regular expression is anchored and must match the fully qualified class name.- Returns:
- The regular expression currently used to filter class names.
nullmeans no filter is applied. If an empty string is specified then no names will match the filter and all attributes will be blocked.
-
getSessionAttributeValueClassNamePattern
ProvidesgetSessionAttributeValueClassNameFilter()as a pre-compiled regular expression pattern.- Returns:
- The pre-compiled pattern used to filter session attributes based on the implementation class name of the
value.
nullmeans no filter is applied.
-
setSessionAttributeValueClassNameFilter
public void setSessionAttributeValueClassNameFilter(String sessionAttributeValueClassNameFilter) throws PatternSyntaxException Set the regular expression to use to filter classes used for session attributes. The regular expression is anchored and must match the fully qualified class name.- Parameters:
sessionAttributeValueClassNameFilter- The regular expression to use to filter session attributes based on class name. Usenullif no filtering is required. If an empty string is specified then no names will match the filter and all attributes will be blocked.- Throws:
PatternSyntaxException- If the expression is not valid
-
getWarnOnSessionAttributeFilterFailure
public boolean getWarnOnSessionAttributeFilterFailure()Should a warn level log message be generated if a session attribute is not persisted / replicated / restored.- Returns:
trueif a warn level log message should be generated
-
setWarnOnSessionAttributeFilterFailure
public void setWarnOnSessionAttributeFilterFailure(boolean warnOnSessionAttributeFilterFailure) Configure whether or not a warn level log message should be generated if a session attribute is not persisted / replicated / restored.- Parameters:
warnOnSessionAttributeFilterFailure-trueif the warn level message should be generated
-
getContext
Description copied from interface:ManagerGet the Context with which this Manager is associated.- Specified by:
getContextin interfaceManager- Returns:
- The associated Context
-
setContext
Description copied from interface:ManagerSet the Context with which this Manager is associated. The Context must be set to a non-null value before the Manager is first used. Multiple calls to this method before first use are permitted. Once the Manager has been used, this method may not be used to change the Context (including setting anullvalue) that the Manager is associated with.- Specified by:
setContextin interfaceManager- Parameters:
context- The newly associated Context
-
getClassName
- Returns:
- The name of the implementation class.
-
getSessionIdGenerator
- Specified by:
getSessionIdGeneratorin interfaceManager- Returns:
- the session id generator
-
setSessionIdGenerator
Description copied from interface:ManagerSets the session id generator- Specified by:
setSessionIdGeneratorin interfaceManager- Parameters:
sessionIdGenerator- The session id generator
-
getName
- Returns:
- The descriptive short name of this Manager implementation.
-
getSecureRandomClass
- Returns:
- The secure random number generator class name.
-
setSecureRandomClass
Set the secure random number generator class name.- Parameters:
secureRandomClass- The new secure random number generator class name
-
getSecureRandomAlgorithm
- Returns:
- The secure random number generator algorithm name.
-
setSecureRandomAlgorithm
Set the secure random number generator algorithm name.- Parameters:
secureRandomAlgorithm- The new secure random number generator algorithm name
-
getSecureRandomProvider
- Returns:
- The secure random number generator provider name.
-
setSecureRandomProvider
Set the secure random number generator provider name.- Parameters:
secureRandomProvider- The new secure random number generator provider name
-
getRejectedSessions
public int getRejectedSessions()Description copied from interface:ManagerGets the number of sessions that were not created because the maximum number of active sessions was reached.- Specified by:
getRejectedSessionsin interfaceManager- Returns:
- Number of rejected sessions
-
getExpiredSessions
public long getExpiredSessions()Description copied from interface:ManagerGets the number of sessions that have expired.- Specified by:
getExpiredSessionsin interfaceManager- Returns:
- Number of sessions that have expired
-
setExpiredSessions
public void setExpiredSessions(long expiredSessions) Description copied from interface:ManagerSets the number of sessions that have expired.- Specified by:
setExpiredSessionsin interfaceManager- Parameters:
expiredSessions- Number of sessions that have expired
-
getProcessingTime
public long getProcessingTime() -
setProcessingTime
public void setProcessingTime(long processingTime) -
getProcessExpiresFrequency
public int getProcessExpiresFrequency()- Returns:
- The frequency of manager checks.
-
setProcessExpiresFrequency
public void setProcessExpiresFrequency(int processExpiresFrequency) Set the manager checks frequency.- Parameters:
processExpiresFrequency- the new manager checks frequency
-
getPersistAuthentication
public boolean getPersistAuthentication()Return whether sessions managed by this manager shall persist authentication information or not.- Returns:
true, sessions managed by this manager shall persist authentication information;falseotherwise
-
setPersistAuthentication
public void setPersistAuthentication(boolean persistAuthentication) Set whether sessions managed by this manager shall persist authentication information or not.- Parameters:
persistAuthentication- iftrue, sessions managed by this manager shall persist authentication information
-
backgroundProcess
public void backgroundProcess()This method will be invoked by the context/container on a periodic basis and allows the manager to implement a method that executes periodic tasks, such as expiring sessions etc.Direct call to
processExpires()- Specified by:
backgroundProcessin interfaceManager
-
processExpires
public void processExpires()Invalidate all sessions that have expired. -
initInternal
Description copied from class:LifecycleBaseSub-classes implement this method to perform any instance initialisation required.- Overrides:
initInternalin classLifecycleMBeanBase- Throws:
LifecycleException- If the initialisation fails
-
startInternal
Description copied from class:LifecycleBaseSub-classes must ensure that the state is changed toLifecycleState.STARTINGduring the execution of this method. Changing state will trigger theLifecycle.START_EVENTevent. If a component fails to start it may either throw aLifecycleExceptionwhich will cause it's parent to fail to start or it can place itself in the error state in which caseLifecycleBase.stop()will be called on the failed component but the parent component will continue to start normally.- Specified by:
startInternalin classLifecycleBase- Throws:
LifecycleException- Start error occurred
-
stopInternal
Description copied from class:LifecycleBaseSub-classes must ensure that the state is changed toLifecycleState.STOPPINGduring the execution of this method. Changing state will trigger theLifecycle.STOP_EVENTevent.- Specified by:
stopInternalin classLifecycleBase- Throws:
LifecycleException- Stop error occurred
-
add
-
addPropertyChangeListener
Description copied from interface:ManagerAdd a property change listener to this component.- Specified by:
addPropertyChangeListenerin interfaceManager- Parameters:
listener- The listener to add
-
createSession
Description copied from interface:ManagerConstruct and return a new session object, based on the default settings specified by this Manager's properties. The session id specified will be used as the session id. If a new session cannot be created for any reason, returnnull.- Specified by:
createSessionin interfaceManager- Parameters:
sessionId- The session id which should be used to create the new session; ifnull, the session id will be assigned by this method, and available via the getId() method of the returned session.- Returns:
- An empty Session object with the given ID or a newly created session ID if none was specified
-
createEmptySession
Description copied from interface:ManagerGet a session from the recycled ones or create a new empty one. The PersistentManager manager does not need to create session data because it reads it from the Store.- Specified by:
createEmptySessionin interfaceManager- Returns:
- An empty Session object
-
findSession
Description copied from interface:ManagerReturn the active Session, associated with this Manager, with the specified session id (if any); otherwise returnnull.- Specified by:
findSessionin interfaceManager- Parameters:
id- The session id for the session to be returned- Returns:
- the request session or
nullif a session with the requested ID could not be found - Throws:
IOException- if an input/output error occurs while processing this request
-
findSessions
Description copied from interface:ManagerReturn the set of active Sessions associated with this Manager. If this Manager has no active Sessions, a zero-length array is returned.- Specified by:
findSessionsin interfaceManager- Returns:
- All the currently active sessions managed by this manager
-
remove
-
remove
-
removePropertyChangeListener
Description copied from interface:ManagerRemove a property change listener from this component.- Specified by:
removePropertyChangeListenerin interfaceManager- Parameters:
listener- The listener to remove
-
rotateSessionId
Description copied from interface:ManagerChange the session ID of the current session to a new randomly generated session ID.- Specified by:
rotateSessionIdin interfaceManager- Parameters:
session- The session to change the session ID for- Returns:
- The new session ID
-
changeSessionId
Description copied from interface:ManagerChange the session ID of the current session to a specified session ID.- Specified by:
changeSessionIdin interfaceManager- Parameters:
session- The session to change the session ID fornewId- new session ID
-
changeSessionId
-
willAttributeDistribute
Would the Manager distribute the given session attribute? Manager implementations may provide additional configuration options to control which attributes are distributable.This implementation excludes session attributes from distribution if the:
- attribute name matches
getSessionAttributeNameFilter()
- Specified by:
willAttributeDistributein interfaceManager- Parameters:
name- The attribute namevalue- The attribute value- Returns:
trueif the Manager would distribute the given attribute otherwisefalse
- attribute name matches
-
getNewSession
Get new session class to be used in the doLoad() method.- Returns:
- a new session for use with this manager
-
generateSessionId
Generate and return a new session identifier.- Returns:
- a new session id
-
getEngine
Retrieve the enclosing Engine for this Manager.- Returns:
- an Engine object (or null).
-
getJvmRoute
Retrieve the JvmRoute for the enclosing Engine.- Returns:
- the JvmRoute or null.
-
setSessionCounter
public void setSessionCounter(long sessionCounter) Description copied from interface:ManagerSets the total number of sessions created by this manager.- Specified by:
setSessionCounterin interfaceManager- Parameters:
sessionCounter- Total number of sessions created by this manager.
-
getSessionCounter
public long getSessionCounter()Description copied from interface:ManagerReturns the total number of sessions created by this manager, which is approximated as the number of active sessions plus the number of expired sessions.- Specified by:
getSessionCounterin interfaceManager- Returns:
- Total number of sessions created by this manager.
-
getDuplicates
Deprecated.This will be removed in Tomcat 11Number of duplicated session IDs generated by the random source. Anything bigger than 0 means problems.- Returns:
- The count of duplicates
-
setDuplicates
Deprecated.This will be removed in Tomcat 11Set duplicates count.- Parameters:
duplicates- the new duplicates count
-
getActiveSessions
public int getActiveSessions()Description copied from interface:ManagerGets the number of currently active sessions.- Specified by:
getActiveSessionsin interfaceManager- Returns:
- Number of currently active sessions
-
getMaxActive
public int getMaxActive()Description copied from interface:ManagerGets the maximum number of sessions that have been active at the same time.- Specified by:
getMaxActivein interfaceManager- Returns:
- Maximum number of sessions that have been active at the same time
-
setMaxActive
public void setMaxActive(int maxActive) Description copied from interface:Manager(Re)sets the maximum number of sessions that have been active at the same time.- Specified by:
setMaxActivein interfaceManager- Parameters:
maxActive- Maximum number of sessions that have been active at the same time.
-
getMaxActiveSessions
public int getMaxActiveSessions()- Returns:
- The maximum number of active Sessions allowed, or -1 for no limit.
-
setMaxActiveSessions
public void setMaxActiveSessions(int max) Set the maximum number of active Sessions allowed, or -1 for no limit.- Parameters:
max- The new maximum number of sessions
-
getSessionMaxAliveTime
public int getSessionMaxAliveTime()Description copied from interface:ManagerGets the longest time (in seconds) that an expired session had been alive.- Specified by:
getSessionMaxAliveTimein interfaceManager- Returns:
- Longest time (in seconds) that an expired session had been alive.
-
setSessionMaxAliveTime
public void setSessionMaxAliveTime(int sessionMaxAliveTime) Description copied from interface:ManagerSets the longest time (in seconds) that an expired session had been alive.- Specified by:
setSessionMaxAliveTimein interfaceManager- Parameters:
sessionMaxAliveTime- Longest time (in seconds) that an expired session had been alive.
-
updateSessionMaxAliveTime
public void updateSessionMaxAliveTime(int sessionAliveTime) Updates the sessionMaxAliveTime attribute if the candidate value is larger than the current value.- Parameters:
sessionAliveTime- The candidate value (in seconds) for the new sessionMaxAliveTime value.
-
getSessionAverageAliveTime
public int getSessionAverageAliveTime()Gets the average time (in seconds) that expired sessions had been alive. This may be based on sample data.Based on the last 100 sessions to expire. If less than 100 sessions have expired then all available data is used.
- Specified by:
getSessionAverageAliveTimein interfaceManager- Returns:
- Average time (in seconds) that expired sessions had been alive.
-
getSessionCreateRate
public int getSessionCreateRate()Gets the current rate of session creation (in session per minute). This may be based on sample data.Based on the creation time of the previous 100 sessions created. If less than 100 sessions have been created then all available data is used.
- Specified by:
getSessionCreateRatein interfaceManager- Returns:
- The current rate (in sessions per minute) of session creation
-
getSessionExpireRate
public int getSessionExpireRate()Gets the current rate of session expiration (in session per minute). This may be based on sample dataBased on the expiry time of the previous 100 sessions expired. If less than 100 sessions have expired then all available data is used.
- Specified by:
getSessionExpireRatein interfaceManager- Returns:
- The current rate (in sessions per minute) of session expiration
-
listSessionIds
For debugging.- Returns:
- A space separated list of all session IDs currently active
-
getSessionAttribute
-
getSession
Returns information about the session with the given session id.The session information is organized as a HashMap, mapping session attribute names to the String representation of their values.
- Parameters:
sessionId- Session id- Returns:
- HashMap mapping session attribute names to the String representation of their values, or null if no session with the specified id exists, or if the session does not have any attributes
-
expireSession
-
getThisAccessedTimestamp
-
getThisAccessedTime
-
getLastAccessedTimestamp
-
getLastAccessedTime
-
getCreationTime
-
getCreationTimestamp
-
toString
-
getObjectNameKeyProperties
Description copied from class:LifecycleMBeanBaseAllow sub-classes to specify the key properties component of theObjectNamethat will be used to register this component.- Specified by:
getObjectNameKeyPropertiesin classLifecycleMBeanBase- Returns:
- The string representation of the key properties component of the
desired
ObjectName
-
getDomainInternal
Description copied from class:LifecycleMBeanBaseMethod implemented by sub-classes to identify the domain in which MBeans should be registered.- Specified by:
getDomainInternalin classLifecycleMBeanBase- Returns:
- The name of the domain to use to register MBeans.
-