public abstract class ManagerBase extends LifecycleMBeanBase implements Manager, PropertyChangeListener
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ManagerBase.SessionTiming |
| Modifier and Type | Field and Description |
|---|---|
protected Container |
container
The Container with which this Manager is associated.
|
protected boolean |
distributable
The distributable flag for Sessions created by this Manager.
|
protected int |
duplicates |
protected 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
The default maximum inactive interval for Sessions created by
this Manager.
|
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
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
SecureRandom which are used to generate session IDs. |
protected long |
sessionCounter |
protected Deque<ManagerBase.SessionTiming> |
sessionCreationTiming |
protected Deque<ManagerBase.SessionTiming> |
sessionExpirationTiming |
protected SessionIdGenerator |
sessionIdGenerator |
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 Map<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 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(PropertyChangeListener listener)
Add a property change listener to this component.
|
void |
backgroundProcess()
Implements the Manager interface, direct call to processExpires
|
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(String sessionId)
Construct and return a new session object, based on the default
settings specified by this Manager's properties.
|
void |
expireSession(String sessionId) |
Session |
findSession(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 String |
generateSessionId()
Generate and return a new session identifier.
|
int |
getActiveSessions()
Returns the number of active sessions
|
String |
getClassName()
Returns the name of the implementation class.
|
Container |
getContainer()
Return the Container with which this Manager is associated.
|
String |
getCreationTime(String sessionId) |
long |
getCreationTimestamp(String sessionId) |
boolean |
getDistributable()
Return the distributable flag for the sessions supported by
this Manager.
|
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.
|
String |
getInfo()
Return descriptive information about this Manager implementation and
the corresponding version number, in the format
<description>/<version>. |
String |
getJvmRoute()
Retrieve the JvmRoute for the enclosing Engine.
|
String |
getLastAccessedTime(String sessionId) |
long |
getLastAccessedTimestamp(String sessionId) |
int |
getMaxActive()
Max number of concurrent active sessions
|
int |
getMaxActiveSessions()
Return the maximum number of active Sessions allowed, or -1 for
no limit.
|
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.
|
protected StandardSession |
getNewSession()
Get new session class to be used in the doLoad() method.
|
String |
getObjectNameKeyProperties()
Allow sub-classes to specify the key properties component of the
ObjectName that will be used to register this component. |
int |
getProcessExpiresFrequency()
Return the frequency of manager checks.
|
long |
getProcessingTime() |
int |
getRejectedSessions()
Number of session creations that failed due to maxActiveSessions
|
String |
getSecureRandomAlgorithm()
Return the secure random number generator algorithm name.
|
String |
getSecureRandomClass()
Return the secure random number generator class name.
|
String |
getSecureRandomProvider()
Return the secure random number generator provider name.
|
HashMap<String,String> |
getSession(String sessionId)
Returns information about the session with the given session id.
|
String |
getSessionAttribute(String sessionId,
String key)
For debugging: get a session attribute
|
int |
getSessionAverageAliveTime()
Gets the average time (in seconds) that expired sessions had been
alive based on the last 100 sessions to expire.
|
long |
getSessionCounter()
Total sessions created by this manager.
|
int |
getSessionCreateRate()
Gets the current rate of session creation (in session per minute) based
on the creation time of the previous 100 sessions created.
|
int |
getSessionExpireRate()
Gets the current rate of session expiration (in session per minute) based
on the expiry time of the previous 100 sessions expired.
|
int |
getSessionIdLength()
Gets the session id length (in bytes) of Sessions created by
this Manager.
|
int |
getSessionMaxAliveTime()
Gets the longest time (in seconds) that an expired session had been
alive.
|
String |
getThisAccessedTime(String sessionId) |
long |
getThisAccessedTimestamp(String sessionId) |
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.
|
String |
listSessionIds()
For debugging: return a list of all session ids currently active
|
void |
processExpires()
Invalidate all sessions that have expired.
|
void |
propertyChange(PropertyChangeEvent event)
Process property change events from our associated Context.
|
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(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)
Set the distributable flag for the sessions supported by this
Manager.
|
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)
Set the default maximum inactive interval (in seconds)
for Sessions created by this Manager.
|
void |
setProcessExpiresFrequency(int processExpiresFrequency)
Set the manager checks frequency.
|
void |
setProcessingTime(long processingTime) |
void |
setSecureRandomAlgorithm(String secureRandomAlgorithm)
Set the secure random number generator algorithm name.
|
void |
setSecureRandomClass(String secureRandomClass)
Set the secure random number generator class name.
|
void |
setSecureRandomProvider(String secureRandomProvider)
Set the secure random number generator provider name.
|
void |
setSessionCounter(long sessionCounter)
Sets the total number of sessions created by this manager.
|
void |
setSessionIdLength(int idLength)
Sets the session id length (in bytes) for Sessions created by this
Manager.
|
void |
setSessionMaxAliveTime(int sessionMaxAliveTime)
Sets the longest time (in seconds) that an expired session had been
alive.
|
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. |
String |
toString()
Return a String rendering of this object.
|
void |
updateSessionMaxAliveTime(int sessionAliveTime)
Updates the sessionMaxAliveTime attribute if the candidate value is
larger than the current value.
|
destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregisteraddLifecycleListener, destroy, findLifecycleListeners, fireLifecycleEvent, getState, getStateName, init, removeLifecycleListener, setState, setState, start, stopprotected Container container
protected boolean distributable
true, any user attributes added to a
session controlled by this Manager must be Serializable.protected int maxInactiveInterval
protected int sessionIdLength
protected String secureRandomClass
SecureRandom will be
generated.protected 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 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 volatile int sessionMaxAliveTime
protected static final int TIMING_STATS_CACHE_SIZE
protected final Deque<ManagerBase.SessionTiming> sessionCreationTiming
protected final Deque<ManagerBase.SessionTiming> sessionExpirationTiming
protected final AtomicLong expiredSessions
protected Map<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 PropertyChangeSupport support
public Container getContainer()
getContainer in interface Managerpublic void setContainer(Container container)
setContainer in interface Managercontainer - The newly associated Containerpublic String getClassName()
public boolean getDistributable()
getDistributable in interface Managerpublic void setDistributable(boolean distributable)
setDistributable in interface Managerdistributable - The new distributable flagpublic String getInfo()
<description>/<version>.public int getMaxInactiveInterval()
getMaxInactiveInterval in interface Managerpublic void setMaxInactiveInterval(int interval)
setMaxInactiveInterval in interface Managerinterval - The new default valuepublic int getSessionIdLength()
getSessionIdLength in interface Managerpublic void setSessionIdLength(int idLength)
setSessionIdLength in interface ManageridLength - The session id lengthpublic String getName()
public String getSecureRandomClass()
public void setSecureRandomClass(String secureRandomClass)
secureRandomClass - The new secure random number generator class
namepublic String getSecureRandomAlgorithm()
public void setSecureRandomAlgorithm(String secureRandomAlgorithm)
secureRandomAlgorithm - The new secure random number generator
algorithm namepublic String getSecureRandomProvider()
public void setSecureRandomProvider(String secureRandomProvider)
secureRandomProvider - The new secure random number generator
provider namepublic int getRejectedSessions()
getRejectedSessions in interface Managerpublic long getExpiredSessions()
getExpiredSessions in interface Managerpublic void setExpiredSessions(long expiredSessions)
setExpiredSessions 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()
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)
public void addPropertyChangeListener(PropertyChangeListener listener)
addPropertyChangeListener in interface Managerlistener - The listener to addpublic Session createSession(String sessionId)
null.createSession in interface ManagersessionId - The session id which should be used to create the
new session; if null, a new session id will be
generatedIllegalStateException - if a new session cannot be
instantiated for any reasonpublic Session createEmptySession()
createEmptySession in interface Managerpublic Session findSession(String id) throws IOException
null.findSession in interface Managerid - The session id for the session to be returnedIllegalStateException - if a new session cannot be
instantiated for any reasonIOException - if an input/output error occurs while
processing this requestpublic Session[] findSessions()
findSessions in interface Managerpublic void remove(Session session)
public void remove(Session session, boolean update)
public void removePropertyChangeListener(PropertyChangeListener listener)
removePropertyChangeListener in interface Managerlistener - The listener to removepublic void changeSessionId(Session session)
changeSessionId in interface Managersession - The session to change the session ID forprotected StandardSession getNewSession()
protected String generateSessionId()
public Engine getEngine()
public String getJvmRoute()
public void setSessionCounter(long sessionCounter)
ManagersetSessionCounter in interface ManagersessionCounter - Total number of sessions created by this manager.public long getSessionCounter()
getSessionCounter in interface Managerpublic int getDuplicates()
public void setDuplicates(int duplicates)
public int getActiveSessions()
getActiveSessions in interface Managerpublic int getMaxActive()
getMaxActive 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()
getSessionMaxAliveTime in interface Managerpublic void setSessionMaxAliveTime(int sessionMaxAliveTime)
setSessionMaxAliveTime 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()
getSessionAverageAliveTime in interface Managerpublic int getSessionCreateRate()
getSessionCreateRate in interface Managerpublic int getSessionExpireRate()
getSessionExpireRate in interface Managerpublic String listSessionIds()
public String getSessionAttribute(String sessionId, String key)
sessionId - key - public HashMap<String,String> getSession(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(String sessionId)
public long getThisAccessedTimestamp(String sessionId)
public long getLastAccessedTimestamp(String sessionId)
public long getCreationTimestamp(String sessionId)
public String toString()
public String getObjectNameKeyProperties()
LifecycleMBeanBaseObjectName that will be used to register this component.getObjectNameKeyProperties in class LifecycleMBeanBaseObjectNamepublic String getDomainInternal()
LifecycleMBeanBasegetDomainInternal in class LifecycleMBeanBasepublic void propertyChange(PropertyChangeEvent event)
propertyChange in interface PropertyChangeListenerevent - The property change event that has occurredCopyright © 2000-2013 Apache Software Foundation. All Rights Reserved.