Top Description Inners Fields Constructors Methods
org.apache.catalina.session

public abstract Class ManagerBase

extends LifecycleMBeanBase
implements Manager
Class Inheritance
All Implemented Interfaces
org.apache.catalina.Manager
Known Direct Subclasses
org.apache.catalina.session.PersistentManagerBase, org.apache.catalina.session.StandardManager
Imports
java.beans.PropertyChangeListener, .PropertyChangeSupport, java.io.IOException, java.util.ArrayList, .Date, .Deque, .Enumeration, .HashMap, .LinkedList, .List, .Map, java.util.concurrent.ConcurrentHashMap, java.util.concurrent.atomic.AtomicLong, java.util.regex.Pattern, .PatternSyntaxException, org.apache.catalina.Container, .Context, .Engine, .Globals, .Lifecycle, .LifecycleException, .LifecycleState, .Manager, .Session, .SessionIdGenerator, org.apache.catalina.util.LifecycleMBeanBase, .SessionIdGeneratorBase, .StandardSessionIdGenerator, .ToStringUtil, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.util.res.StringManager

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 and Inner Type Summary

Modifier and TypeClass and Description
protected static class

Field Summary

Modifier and TypeField and Description
private Context
context

The Context with which this Manager is associated.

private int
count

Iteration count for background processing.

protected volatile int
protected final AtomicLong
expiredSessions

Number of sessions that have expired.

private final Log
protected volatile int
protected int
maxActiveSessions

The maximum number of active Sessions allowed, or -1 for no limit.

private final Object
private static final String
name

The descriptive name of this Manager implementation (for logging).

private boolean
private boolean
private boolean
persistAuthentication

Determines whether sessions managed by this manager shall persist (serialize) authentication information or not.

protected int
processExpiresFrequency

Frequency of the session expiration, and related manager operations.

protected long
processingTime

Processing time during session expiration.

protected int
rejectedSessions

Number of session creations that failed due to maxActiveSessions.

protected String
secureRandomAlgorithm

The name of the algorithm to use to create instances of java.security.SecureRandom which are used to generate session IDs.

protected String
secureRandomClass

The Java class name of the secure random number generator class to be used when generating session identifiers.

protected String
secureRandomProvider

The name of the provider to use to create instances of java.security.SecureRandom which are used to generate session IDs.

private boolean
private Pattern
private Pattern
protected long
protected final Deque<ManagerBase.SessionTiming>
protected final Deque<ManagerBase.SessionTiming>
protected SessionIdGenerator
protected Class<? extends SessionIdGenerator>
private boolean
protected volatile int
sessionMaxAliveTime

The longest time (in seconds) that an expired session had been alive.

private final Object
protected Map<String, Session>
sessions

The set of currently active Sessions for this Manager, keyed by session identifier.

protected static final StringManager
sm

Hides org.apache.catalina.util.LifecycleMBeanBase.sm.

The string manager for this package.
protected final PropertyChangeSupport
support

The property change support for this component.

protected static final int
private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
add(Session
Session to be added
session
)

Implements org.apache.catalina.Manager.add.

Add this Session to the set of active Sessions for this Manager.

public void
addPropertyChangeListener(PropertyChangeListener
The listener to add
listener
)

Implements org.apache.catalina.Manager.addPropertyChangeListener.

Add a property change listener to this component.

public void
backgroundProcess()

Implements org.apache.catalina.Manager.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()

private static int
public void
changeSessionId(Session
The session to change the session ID for
session
,
String
new session ID
newId
)

Implements org.apache.catalina.Manager.changeSessionId.

Change the session ID of the current session to a specified session ID.

protected void
changeSessionId(Session session, String newId, boolean notifySessionListeners, boolean notifyContainerListeners)

public Session
createEmptySession()

Implements org.apache.catalina.Manager.createEmptySession.

Get a session from the recycled ones or create a new empty one.

public Session
createSession(String
The session id which should be used to create the new session; if null, the session id will be assigned by this method, and available via the getId() method of the returned session.
sessionId
)

Implements org.apache.catalina.Manager.createSession.

Construct and return a new session object, based on the default settings specified by this Manager's properties.

public void
expireSession(String sessionId)

public Session
findSession(String
The session id for the session to be returned
id
)

Implements org.apache.catalina.Manager.findSession.

Return the active Session, associated with this Manager, with the specified session id (if any); otherwise return null.

public Session[]
findSessions()

Implements org.apache.catalina.Manager.findSessions.

Return the set of active Sessions associated with this Manager.

protected String

Returns:

a new session id
generateSessionId
()

Generate and return a new session identifier.

public int
getActiveSessions()

Implements org.apache.catalina.Manager.getActiveSessions.

Gets the number of currently active sessions.

public String

Returns:

The name of the implementation class.
getClassName
()

public Context
getContext()

Implements org.apache.catalina.Manager.getContext.

Get the Context with which this Manager is associated.

public String
public long
public String
getDomainInternal()

Implements abstract org.apache.catalina.util.LifecycleMBeanBase.getDomainInternal.

Method implemented by sub-classes to identify the domain in which MBeans should be registered.

public int

Returns:

The count of duplicates
getDuplicates
()

Number of duplicated session IDs generated by the random source.

public Engine

Returns:

an Engine object (or null).
getEngine
()

Retrieve the enclosing Engine for this Manager.

public long
getExpiredSessions()

Implements org.apache.catalina.Manager.getExpiredSessions.

Gets the number of sessions that have expired.

public String

Returns:

the JvmRoute or null.
getJvmRoute
()

Retrieve the JvmRoute for the enclosing Engine.

public String
public long
public int
getMaxActive()

Implements org.apache.catalina.Manager.getMaxActive.

Gets the maximum number of sessions that have been active at the same time.

public int

Returns:

The maximum number of active Sessions allowed, or -1 for no limit.
getMaxActiveSessions
()

public String

Returns:

The descriptive short name of this Manager implementation.
getName
()

protected StandardSession

Returns:

a new session for use with this manager
getNewSession
()

Get new session class to be used in the doLoad() method.

public boolean
public boolean
public String
getObjectNameKeyProperties()

Implements abstract org.apache.catalina.util.LifecycleMBeanBase.getObjectNameKeyProperties.

Allow sub-classes to specify the key properties component of the ObjectName that will be used to register this component.

public boolean

Returns:

true, sessions managed by this manager shall persist authentication information; false otherwise
getPersistAuthentication
()

Return whether sessions managed by this manager shall persist authentication information or not.

public int

Returns:

The frequency of manager checks.
getProcessExpiresFrequency
()

public long
public int
getRejectedSessions()

Implements org.apache.catalina.Manager.getRejectedSessions.

Gets the number of sessions that were not created because the maximum number of active sessions was reached.

public String

Returns:

The secure random number generator algorithm name.
getSecureRandomAlgorithm
()

public String

Returns:

The secure random number generator class name.
getSecureRandomClass
()

public String

Returns:

The secure random number generator provider name.
getSecureRandomProvider
()

public HashMap<String, String>

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
getSession
(String
Session id
sessionId
)

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.

public boolean
getSessionActivityCheck()

Overrides default org.apache.catalina.Manager.getSessionActivityCheck.

If this is true, Tomcat will track the number of active requests for each session.

public String

Returns:

The attribute value for the specified session, if found, null otherwise
getSessionAttribute
(String
The ID for the session of interest
sessionId
,
String
The key for the attribute to obtain
key
)

For debugging.

public String

Returns:

The regular expression currently used to filter attribute names. null means no filter is applied. If an empty string is specified then no names will match the filter and all attributes will be blocked.
getSessionAttributeNameFilter
()

Obtain the regular expression used to filter session attribute based on attribute name.

protected Pattern

Returns:

The pre-compiled pattern used to filter session attributes based on attribute name. null means no filter is applied.
getSessionAttributeNamePattern
()

Provides getSessionAttributeNameFilter() as a pre-compiled regular expression pattern.

public String

Returns:

The regular expression currently used to filter class names. null means no filter is applied. If an empty string is specified then no names will match the filter and all attributes will be blocked.
getSessionAttributeValueClassNameFilter
()

Obtain the regular expression used to filter session attribute based on the implementation class of the value.

protected Pattern

Returns:

The pre-compiled pattern used to filter session attributes based on the implementation class name of the value. null means no filter is applied.
getSessionAttributeValueClassNamePattern
()

Provides getSessionAttributeValueClassNameFilter() as a pre-compiled regular expression pattern.

public int
getSessionAverageAliveTime()

Implements org.apache.catalina.Manager.getSessionAverageAliveTime.

Gets the average time (in seconds) that expired sessions had been alive.

public long
getSessionCounter()

Implements org.apache.catalina.Manager.getSessionCounter.

Returns the total number of sessions created by this manager.

public int
getSessionCreateRate()

Implements org.apache.catalina.Manager.getSessionCreateRate.

Gets the current rate of session creation (in session per minute).

public int

Returns:

The current rate (in sessions per minute) of session expiration
getSessionExpireRate
()

Implements org.apache.catalina.Manager.getSessionExpireRate.

Gets the current rate of session expiration (in session per minute).

public SessionIdGenerator
public boolean
getSessionLastAccessAtStart()

Overrides default org.apache.catalina.Manager.getSessionLastAccessAtStart.

If this is true, the last accessed time for sessions will be calculated from the beginning of the previous request.

public int
getSessionMaxAliveTime()

Implements org.apache.catalina.Manager.getSessionMaxAliveTime.

Gets the longest time (in seconds) that an expired session had been alive.

public String
public long
public boolean

Returns:

true if a warn level log message should be generated
getWarnOnSessionAttributeFilterFailure
()

Should a warn level log message be generated if a session attribute is not persisted / replicated / restored.

protected void
initInternal()

Overrides org.apache.catalina.util.LifecycleMBeanBase.initInternal.

Sub-classes wishing to perform additional initialization should override this method, ensuring that super.initInternal() is the first call in the overriding method.

public String

Returns:

A space separated list of all session IDs currently active
listSessionIds
()

For debugging.

public void
processExpires()

Invalidate all sessions that have expired.

public void
remove(Session
Session to be removed
session
)

Implements org.apache.catalina.Manager.remove.

Remove this Session from the active Sessions for this Manager.

public void
remove(Session
Session to be removed
session
,
boolean
Should the expiration statistics be updated
update
)

Implements org.apache.catalina.Manager.remove.

Remove this Session from the active Sessions for this Manager.

public void
removePropertyChangeListener(PropertyChangeListener
The listener to remove
listener
)

Implements org.apache.catalina.Manager.removePropertyChangeListener.

Remove a property change listener from this component.

public String
rotateSessionId(Session
The session to change the session ID for
session
)

Overrides default org.apache.catalina.Manager.rotateSessionId.

Change the session ID of the current session to a new randomly generated session ID.

public void
setContext(Context
The newly associated Context
context
)

Implements org.apache.catalina.Manager.setContext.

Set the Context with which this Manager is associated.

public void
setDuplicates(int duplicates)

public void
setExpiredSessions(long
Number of sessions that have expired
expiredSessions
)

Implements org.apache.catalina.Manager.setExpiredSessions.

Sets the number of sessions that have expired.

public void
setMaxActive(int
Maximum number of sessions that have been active at the same time.
maxActive
)

Implements org.apache.catalina.Manager.setMaxActive.

(Re)sets the maximum number of sessions that have been active at the same time.

public void
setMaxActiveSessions(int
The new maximum number of sessions
max
)

Set the maximum number of active Sessions allowed, or -1 for no limit.

public void
setNotifyAttributeListenerOnUnchangedValue(boolean
true the listener will be called, false it will not
notifyAttributeListenerOnUnchangedValue
)

Implements org.apache.catalina.Manager.setNotifyAttributeListenerOnUnchangedValue.

Configure if jakarta.servlet.http.HttpSessionAttributeListener#attributeReplaced(jakarta.servlet.http.HttpSessionBindingEvent) when an attribute that is already present in the session is added again under the same name and a jakarta.servlet.http.HttpSessionAttributeListener is configured for the session.

public void
setNotifyBindingListenerOnUnchangedValue(boolean
true the listener will be called, false it will not
notifyBindingListenerOnUnchangedValue
)

Implements org.apache.catalina.Manager.setNotifyBindingListenerOnUnchangedValue.

Configure if jakarta.servlet.http.HttpSessionBindingListener#valueUnbound(jakarta.servlet.http.HttpSessionBindingEvent) be called followed by jakarta.servlet.http.HttpSessionBindingListener#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 implements jakarta.servlet.http.HttpSessionBindingListener.

public void
setPersistAuthentication(boolean
if true, sessions managed by this manager shall persist authentication information
persistAuthentication
)

Set whether sessions managed by this manager shall persist authentication information or not.

public void
setProcessExpiresFrequency(int
the new manager checks frequency
processExpiresFrequency
)

Set the manager checks frequency.

public void
setProcessingTime(long processingTime)

public void
setSecureRandomAlgorithm(String
The new secure random number generator algorithm name
secureRandomAlgorithm
)

Set the secure random number generator algorithm name.

public void
setSecureRandomClass(String
The new secure random number generator class name
secureRandomClass
)

Set the secure random number generator class name.

public void
setSecureRandomProvider(String
The new secure random number generator provider name
secureRandomProvider
)

Set the secure random number generator provider name.

public void
setSessionActivityCheck(boolean
the new flag value
sessionActivityCheck
)

Implements org.apache.catalina.Manager.setSessionActivityCheck.

Configure if Tomcat will track the number of active requests for each session.

public void
setSessionAttributeNameFilter(String
The regular expression to use to filter session attributes based on attribute name. Use null if no filtering is required. If an empty string is specified then no names will match the filter and all attributes will be blocked.
sessionAttributeNameFilter
)

Set the regular expression to use to filter session attributes based on attribute name.

public void
setSessionAttributeValueClassNameFilter(String
The regular expression to use to filter session attributes based on class name. Use null if no filtering is required. If an empty string is specified then no names will match the filter and all attributes will be blocked.
sessionAttributeValueClassNameFilter
)

Set the regular expression to use to filter classes used for session attributes.

public void
setSessionCounter(long
Total number of sessions created by this manager.
sessionCounter
)

Implements org.apache.catalina.Manager.setSessionCounter.

Sets the total number of sessions created by this manager.

public void
setSessionIdGenerator(SessionIdGenerator
The session id generator
sessionIdGenerator
)

Implements org.apache.catalina.Manager.setSessionIdGenerator.

Sets the session id generator

public void
setSessionLastAccessAtStart(boolean
the new flag value
sessionLastAccessAtStart
)

Implements org.apache.catalina.Manager.setSessionLastAccessAtStart.

Configure if the last accessed time for sessions will be calculated from the beginning of the previous request.

public void
setSessionMaxAliveTime(int
Longest time (in seconds) that an expired session had been alive.
sessionMaxAliveTime
)

Implements org.apache.catalina.Manager.setSessionMaxAliveTime.

Sets the longest time (in seconds) that an expired session had been alive.

public void
setWarnOnSessionAttributeFilterFailure(boolean
true if the warn level message should be generated
warnOnSessionAttributeFilterFailure
)

Configure whether or not a warn level log message should be generated if a session attribute is not persisted / replicated / restored.

protected void
startInternal()

Implements abstract org.apache.catalina.util.LifecycleBase.startInternal.

Sub-classes must ensure that the state is changed to LifecycleState#STARTING during the execution of this method.

protected void
stopInternal()

Implements abstract org.apache.catalina.util.LifecycleBase.stopInternal.

Sub-classes must ensure that the state is changed to LifecycleState#STOPPING during the execution of this method.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public void
updateSessionMaxAliveTime(int
The candidate value (in seconds) for the new sessionMaxAliveTime value.
sessionAliveTime
)

Updates the sessionMaxAliveTime attribute if the candidate value is larger than the current value.

public boolean
willAttributeDistribute(String
The attribute name
name
,
Object
The attribute value
value
)

Implements org.apache.catalina.Manager.willAttributeDistribute.

Would the Manager distribute the given session attribute?

Inherited from org.apache.catalina.util.LifecycleMBeanBase:
destroyInternalgetDomaingetObjectNamepostDeregisterpostRegisterpreDeregisterpreRegisterregistersetDomainunregisterunregister