public abstract class ManagerBase extends LifecycleMBeanBase implements Manager
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ManagerBase.SessionTiming |
Lifecycle.SingleUse| Modifier and Type | Field and Description |
|---|---|
protected Container |
container
The Container with which this Manager is associated.
|
protected boolean |
distributable
Deprecated.
Ignored.
Context.getDistributable() always takes
precedence. Will be removed in Tomcat 9.0.x. |
protected int |
duplicates |
protected java.util.concurrent.atomic.AtomicLong |
expiredSessions
Number of sessions that have expired.
|
protected int |
maxActive |
protected int |
maxActiveSessions
The maximum number of active Sessions allowed, or -1 for no limit.
|
protected int |
maxInactiveInterval
Deprecated.
Ignored.
Context.getSessionTimeout() always takes
precedence. Will be removed in Tomcat 9.0.x. |
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 java.lang.String |
secureRandomAlgorithm
The name of the algorithm to use to create instances of
SecureRandom which are used to generate session IDs. |
protected java.lang.String |
secureRandomClass
The Java class name of the secure random number generator class to be
used when generating session identifiers.
|
protected java.lang.String |
secureRandomProvider
The name of the provider to use to create instances of
SecureRandom which are used to generate session IDs. |
protected static int |
SESSION_ID_LENGTH_UNSET |
protected long |
sessionCounter |
protected java.util.Deque<ManagerBase.SessionTiming> |
sessionCreationTiming |
protected java.util.Deque<ManagerBase.SessionTiming> |
sessionExpirationTiming |
protected SessionIdGenerator |
sessionIdGenerator |
protected java.lang.Class<? extends SessionIdGenerator> |
sessionIdGeneratorClass |
protected int |
sessionIdLength
The session id length of Sessions created by this Manager.
|
protected int |
sessionMaxAliveTime
The longest time (in seconds) that an expired session had been alive.
|
protected java.util.Map<java.lang.String,Session> |
sessions
The set of currently active Sessions for this Manager, keyed by
session identifier.
|
protected static StringManager |
sm
The string manager for this package.
|
protected java.beans.PropertyChangeSupport |
support
The property change support for this component.
|
protected static int |
TIMING_STATS_CACHE_SIZE |
mserverAFTER_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 and Description |
|---|
ManagerBase() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(Session session)
Add this Session to the set of active Sessions for this Manager.
|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a property change listener to this component.
|
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.
|
void |
changeSessionId(Session session)
Change the session ID of the current session to a new randomly generated
session ID.
|
Session |
createEmptySession()
Get a session from the recycled ones or create a new empty one.
|
Session |
createSession(java.lang.String sessionId)
Construct and return a new session object, based on the default
settings specified by this Manager's properties.
|
void |
expireSession(java.lang.String sessionId) |
Session |
findSession(java.lang.String id)
Return the active Session, associated with this Manager, with the
specified session id (if any); otherwise return
null. |
Session[] |
findSessions()
Return the set of active Sessions associated with this Manager.
|
protected java.lang.String |
generateSessionId()
Generate and return a new session identifier.
|
int |
getActiveSessions()
Gets the number of currently active sessions.
|
java.lang.String |
getClassName() |
Container |
getContainer()
Return the Container with which this Manager is associated.
|
java.lang.String |
getCreationTime(java.lang.String sessionId) |
long |
getCreationTimestamp(java.lang.String sessionId) |
boolean |
getDistributable()
Deprecated.
|
java.lang.String |
getDomainInternal()
Method implemented by sub-classes to identify the domain in which MBeans
should be registered.
|
int |
getDuplicates()
Number of duplicated session IDs generated by the random source.
|
Engine |
getEngine()
Retrieve the enclosing Engine for this Manager.
|
long |
getExpiredSessions()
Gets the number of sessions that have expired.
|
java.lang.String |
getInfo()
Deprecated.
|
java.lang.String |
getJvmRoute()
Retrieve the JvmRoute for the enclosing Engine.
|
java.lang.String |
getLastAccessedTime(java.lang.String sessionId) |
long |
getLastAccessedTimestamp(java.lang.String sessionId) |
int |
getMaxActive()
Gets the maximum number of sessions that have been active at the same
time.
|
int |
getMaxActiveSessions() |
int |
getMaxInactiveInterval()
Return the default maximum inactive interval (in seconds)
for Sessions created by this Manager.
|
java.lang.String |
getName() |
protected StandardSession |
getNewSession()
Get new session class to be used in the doLoad() method.
|
java.lang.String |
getObjectNameKeyProperties()
Allow sub-classes to specify the key properties component of the
ObjectName that will be used to register this component. |
int |
getProcessExpiresFrequency() |
long |
getProcessingTime() |
int |
getRejectedSessions()
Gets the number of sessions that were not created because the maximum
number of active sessions was reached.
|
java.lang.String |
getSecureRandomAlgorithm() |
java.lang.String |
getSecureRandomClass() |
java.lang.String |
getSecureRandomProvider() |
java.util.HashMap<java.lang.String,java.lang.String> |
getSession(java.lang.String sessionId)
Returns information about the session with the given session id.
|
java.lang.String |
getSessionAttribute(java.lang.String sessionId,
java.lang.String key)
For debugging.
|
java.lang.String |
getSessionAttributeNameFilter()
Obtain the regular expression used to filter session attribute based on
attribute name.
|
protected java.util.regex.Pattern |
getSessionAttributeNamePattern() |
java.lang.String |
getSessionAttributeValueClassNameFilter()
Obtain the regular expression used to filter session attribute based on
the implementation class of the value.
|
protected java.util.regex.Pattern |
getSessionAttributeValueClassNamePattern()
Provides
getSessionAttributeValueClassNameFilter() as a
pre-compiled regular expression pattern. |
int |
getSessionAverageAliveTime()
Gets the average time (in seconds) that expired sessions had been
alive.
|
long |
getSessionCounter()
Returns the total number of sessions created by this manager.
|
int |
getSessionCreateRate()
Gets the current rate of session creation (in session per minute).
|
int |
getSessionExpireRate()
Gets the current rate of session expiration (in session per minute).
|
SessionIdGenerator |
getSessionIdGenerator()
Gets the session id generator.
|
int |
getSessionIdLength()
Deprecated.
Use
SessionIdGenerator.getSessionIdLength().
This method will be removed in Tomcat 9 onwards. |
int |
getSessionMaxAliveTime()
Gets the longest time (in seconds) that an expired session had been
alive.
|
java.lang.String |
getThisAccessedTime(java.lang.String sessionId) |
long |
getThisAccessedTimestamp(java.lang.String sessionId) |
boolean |
getWarnOnSessionAttributeFilterFailure()
Should a warn level log message be generated if a session attribute is
not persisted / replicated / restored.
|
protected void |
initInternal()
Sub-classes wishing to perform additional initialization should override
this method, ensuring that super.initInternal() is the first call in the
overriding method.
|
java.lang.String |
listSessionIds()
For debugging.
|
void |
processExpires()
Invalidate all sessions that have expired.
|
void |
remove(Session session)
Remove this Session from the active Sessions for this Manager.
|
void |
remove(Session session,
boolean update)
Remove this Session from the active Sessions for this Manager.
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a property change listener from this component.
|
void |
setContainer(Container container)
Set the Container with which this Manager is associated.
|
void |
setDistributable(boolean distributable)
Deprecated.
|
void |
setDuplicates(int duplicates) |
void |
setExpiredSessions(long expiredSessions)
Sets the number of sessions that have expired.
|
void |
setMaxActive(int maxActive)
(Re)sets the maximum number of sessions that have been active at the
same time.
|
void |
setMaxActiveSessions(int max)
Set the maximum number of active Sessions allowed, or -1 for
no limit.
|
void |
setMaxInactiveInterval(int interval)
Deprecated.
|
void |
setProcessExpiresFrequency(int processExpiresFrequency)
Set the manager checks frequency.
|
void |
setProcessingTime(long processingTime) |
void |
setSecureRandomAlgorithm(java.lang.String secureRandomAlgorithm)
Set the secure random number generator algorithm name.
|
void |
setSecureRandomClass(java.lang.String secureRandomClass)
Set the secure random number generator class name.
|
void |
setSecureRandomProvider(java.lang.String secureRandomProvider)
Set the secure random number generator provider name.
|
void |
setSessionAttributeNameFilter(java.lang.String sessionAttributeNameFilter) |
void |
setSessionAttributeValueClassNameFilter(java.lang.String sessionAttributeValueClassNameFilter)
Set the regular expression to use to filter classes used for session
attributes.
|
void |
setSessionCounter(long sessionCounter)
Sets the total number of sessions created by this manager.
|
void |
setSessionIdGenerator(SessionIdGenerator sessionIdGenerator) |
void |
setSessionIdLength(int idLength)
Deprecated.
Use
SessionIdGenerator.setSessionIdLength(int).
This method will be removed in Tomcat 9 onwards. |
void |
setSessionMaxAliveTime(int sessionMaxAliveTime)
Sets the longest time (in seconds) that an expired session had been
alive.
|
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.
|
protected void |
startInternal()
Sub-classes must ensure that the state is changed to
LifecycleState.STARTING during the execution of this method. |
protected void |
stopInternal()
Sub-classes must ensure that the state is changed to
LifecycleState.STOPPING during the execution of this method. |
java.lang.String |
toString() |
void |
updateSessionMaxAliveTime(int sessionAliveTime)
Updates the sessionMaxAliveTime attribute if the candidate value is
larger than the current value.
|
boolean |
willAttributeDistribute(java.lang.String name,
java.lang.Object value)
Would the Manager distribute the given session attribute?
|
destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregisteraddLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, init, removeLifecycleListener, setState, setState, start, stopprotected Container container
@Deprecated protected boolean distributable
Context.getDistributable() always takes
precedence. Will be removed in Tomcat 9.0.x.true, any user attributes added to a
session controlled by this Manager must be Serializable.@Deprecated protected int maxInactiveInterval
Context.getSessionTimeout() always takes
precedence. Will be removed in Tomcat 9.0.x.protected static final int SESSION_ID_LENGTH_UNSET
protected int sessionIdLength
protected java.lang.String secureRandomClass
SecureRandom will be
generated.protected java.lang.String secureRandomAlgorithm
SecureRandom which are used to generate session IDs.
If no algorithm is specified, SHA1PRNG is 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.protected java.lang.String secureRandomProvider
SecureRandom which are used to generate session IDs.
If no algorithm is specified the of SHA1PRNG 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.protected SessionIdGenerator sessionIdGenerator
protected java.lang.Class<? extends SessionIdGenerator> sessionIdGeneratorClass
protected volatile int sessionMaxAliveTime
protected static final int TIMING_STATS_CACHE_SIZE
protected final java.util.Deque<ManagerBase.SessionTiming> sessionCreationTiming
protected final java.util.Deque<ManagerBase.SessionTiming> sessionExpirationTiming
protected final java.util.concurrent.atomic.AtomicLong expiredSessions
protected java.util.Map<java.lang.String,Session> sessions
protected long sessionCounter
protected volatile int maxActive
protected int maxActiveSessions
protected int rejectedSessions
protected volatile int duplicates
protected long processingTime
protected int processExpiresFrequency
protected static final StringManager sm
protected final java.beans.PropertyChangeSupport support
public java.lang.String getSessionAttributeNameFilter()
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.public void setSessionAttributeNameFilter(java.lang.String sessionAttributeNameFilter)
protected java.util.regex.Pattern getSessionAttributeNamePattern()
public java.lang.String getSessionAttributeValueClassNameFilter()
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.protected java.util.regex.Pattern getSessionAttributeValueClassNamePattern()
getSessionAttributeValueClassNameFilter() as a
pre-compiled regular expression pattern.null means
no filter is applied.public void setSessionAttributeValueClassNameFilter(java.lang.String sessionAttributeValueClassNameFilter)
throws java.util.regex.PatternSyntaxException
sessionAttributeValueClassNameFilter - 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.java.util.regex.PatternSyntaxException - If the expression is not validpublic boolean getWarnOnSessionAttributeFilterFailure()
true if a warn level log message should be generatedpublic void setWarnOnSessionAttributeFilterFailure(boolean warnOnSessionAttributeFilterFailure)
warnOnSessionAttributeFilterFailure - true if the
warn level message should be generatedpublic Container getContainer()
ManagergetContainer in interface Managerpublic void setContainer(Container container)
Managernull value) that the Manager is
associated with.setContainer in interface Managercontainer - The newly associated Containerpublic java.lang.String getClassName()
@Deprecated public boolean getDistributable()
ManagergetDistributable in interface Manager@Deprecated public void setDistributable(boolean distributable)
ManagersetDistributable in interface Managerdistributable - The new distributable flag@Deprecated public java.lang.String getInfo()
Manager<description>/<version>.public int getMaxInactiveInterval()
ManagergetMaxInactiveInterval in interface Manager@Deprecated public void setMaxInactiveInterval(int interval)
ManagersetMaxInactiveInterval in interface Managerinterval - The new default value@Deprecated public int getSessionIdLength()
SessionIdGenerator.getSessionIdLength().
This method will be removed in Tomcat 9 onwards.getSessionIdLength in interface Manager@Deprecated public void setSessionIdLength(int idLength)
SessionIdGenerator.setSessionIdLength(int).
This method will be removed in Tomcat 9 onwards.setSessionIdLength in interface ManageridLength - The session id lengthpublic SessionIdGenerator getSessionIdGenerator()
public void setSessionIdGenerator(SessionIdGenerator sessionIdGenerator)
public java.lang.String getName()
public java.lang.String getSecureRandomClass()
public void setSecureRandomClass(java.lang.String secureRandomClass)
secureRandomClass - The new secure random number generator class
namepublic java.lang.String getSecureRandomAlgorithm()
public void setSecureRandomAlgorithm(java.lang.String secureRandomAlgorithm)
secureRandomAlgorithm - The new secure random number generator
algorithm namepublic java.lang.String getSecureRandomProvider()
public void setSecureRandomProvider(java.lang.String secureRandomProvider)
secureRandomProvider - The new secure random number generator
provider namepublic int getRejectedSessions()
ManagergetRejectedSessions in interface Managerpublic long getExpiredSessions()
ManagergetExpiredSessions in interface Managerpublic void setExpiredSessions(long expiredSessions)
ManagersetExpiredSessions in interface ManagerexpiredSessions - Number of sessions that have expiredpublic long getProcessingTime()
public void setProcessingTime(long processingTime)
public int getProcessExpiresFrequency()
public void setProcessExpiresFrequency(int processExpiresFrequency)
processExpiresFrequency - the new manager checks frequencypublic void backgroundProcess()
Direct call to processExpires()
backgroundProcess in interface Managerpublic void processExpires()
protected void initInternal()
throws LifecycleException
LifecycleMBeanBaseinitInternal in class LifecycleMBeanBaseLifecycleExceptionprotected void startInternal()
throws LifecycleException
LifecycleBaseLifecycleState.STARTING during the execution of this method.
Changing state will trigger the Lifecycle.START_EVENT event.
If a component fails to start it may either throw a
LifecycleException which will cause it's parent to fail to start
or it can place itself in the error state in which case LifecycleBase.stop()
will be called on the failed component but the parent component will
continue to start normally.startInternal in class LifecycleBaseLifecycleExceptionprotected void stopInternal()
throws LifecycleException
LifecycleBaseLifecycleState.STOPPING during the execution of this method.
Changing state will trigger the Lifecycle.STOP_EVENT event.stopInternal in class LifecycleBaseLifecycleExceptionpublic void add(Session session)
Managerpublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
ManageraddPropertyChangeListener in interface Managerlistener - The listener to addpublic Session createSession(java.lang.String sessionId)
Managernull.createSession in interface ManagersessionId - 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.public Session createEmptySession()
ManagercreateEmptySession in interface Managerpublic Session findSession(java.lang.String id) throws java.io.IOException
Managernull.findSession in interface Managerid - The session id for the session to be returnedjava.io.IOException - if an input/output error occurs while
processing this requestpublic Session[] findSessions()
ManagerfindSessions in interface Managerpublic void remove(Session session)
Managerpublic void remove(Session session, boolean update)
Managerpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
ManagerremovePropertyChangeListener in interface Managerlistener - The listener to removepublic void changeSessionId(Session session)
ManagerchangeSessionId in interface Managersession - The session to change the session ID forpublic boolean willAttributeDistribute(java.lang.String name,
java.lang.Object value)
This implementation excludes session attributes from distribution if the:
getSessionAttributeNameFilter()willAttributeDistribute in interface Managername - The attribute namevalue - The attribute valuetrue if the Manager would distribute the given attribute
otherwise falseprotected StandardSession getNewSession()
protected java.lang.String generateSessionId()
public Engine getEngine()
public java.lang.String getJvmRoute()
public void setSessionCounter(long sessionCounter)
ManagersetSessionCounter in interface ManagersessionCounter - Total number of sessions created by this manager.public long getSessionCounter()
ManagergetSessionCounter in interface Managerpublic int getDuplicates()
public void setDuplicates(int duplicates)
public int getActiveSessions()
ManagergetActiveSessions in interface Managerpublic int getMaxActive()
ManagergetMaxActive in interface Managerpublic void setMaxActive(int maxActive)
ManagersetMaxActive in interface ManagermaxActive - Maximum number of sessions that have been active at
the same time.public int getMaxActiveSessions()
public void setMaxActiveSessions(int max)
max - The new maximum number of sessionspublic int getSessionMaxAliveTime()
ManagergetSessionMaxAliveTime in interface Managerpublic void setSessionMaxAliveTime(int sessionMaxAliveTime)
ManagersetSessionMaxAliveTime in interface ManagersessionMaxAliveTime - Longest time (in seconds) that an expired
session had been alive.public void updateSessionMaxAliveTime(int sessionAliveTime)
sessionAliveTime - The candidate value (in seconds) for the new
sessionMaxAliveTime value.public int getSessionAverageAliveTime()
Based on the last 100 sessions to expire. If less than 100 sessions have expired then all available data is used.
getSessionAverageAliveTime in interface Managerpublic int getSessionCreateRate()
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.
getSessionCreateRate in interface Managerpublic int getSessionExpireRate()
Based on the expiry time of the previous 100 sessions expired. If less than 100 sessions have expired then all available data is used.
getSessionExpireRate in interface Managerpublic java.lang.String listSessionIds()
public java.lang.String getSessionAttribute(java.lang.String sessionId,
java.lang.String key)
sessionId - The ID for the session of interestkey - The key for the attribute to obtainpublic java.util.HashMap<java.lang.String,java.lang.String> getSession(java.lang.String sessionId)
The session information is organized as a HashMap, mapping session attribute names to the String representation of their values.
sessionId - Session idpublic void expireSession(java.lang.String sessionId)
public long getThisAccessedTimestamp(java.lang.String sessionId)
public java.lang.String getThisAccessedTime(java.lang.String sessionId)
public long getLastAccessedTimestamp(java.lang.String sessionId)
public java.lang.String getLastAccessedTime(java.lang.String sessionId)
public java.lang.String getCreationTime(java.lang.String sessionId)
public long getCreationTimestamp(java.lang.String sessionId)
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String getObjectNameKeyProperties()
LifecycleMBeanBaseObjectName that will be used to register this component.getObjectNameKeyProperties in class LifecycleMBeanBaseObjectNamepublic java.lang.String getDomainInternal()
LifecycleMBeanBasegetDomainInternal in class LifecycleMBeanBaseCopyright © 2000-2019 Apache Software Foundation. All Rights Reserved.