Package org.apache.catalina
Interface Manager
- All Known Subinterfaces:
- ClusterManager
- All Known Implementing Classes:
- BackupManager,- ClusterManagerBase,- DeltaManager,- ManagerBase,- PersistentManager,- PersistentManagerBase,- StandardManager
public interface Manager
A Manager manages the pool of Sessions that are associated with a
 particular Context. Different Manager implementations may support
 value-added features such as the persistent storage of session data,
 as well as migrating sessions for distributable web applications.
 
 In order for a Manager implementation to successfully operate
 with a Context implementation that implements reloading, it
 must obey the following constraints:
 
- Must implement Lifecycleso that the Context can indicate that a restart is required.
- Must allow a call to stop()to be followed by a call tostart()on the sameManagerinstance.
- Author:
- Craig R. McClanahan
- 
Method SummaryModifier 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.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.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.intGets the number of currently active sessions.Get the Context with which this Manager is associated.longGets the number of sessions that have expired.intGets the maximum number of sessions that have been active at the same time.default 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?default 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)?intGets the number of sessions that were not created because the maximum number of active sessions was reached.default booleanIf this istrue, Tomcat will track the number of active requests for each session.intGets the average time (in seconds) that expired sessions had been alive.longReturns the total number of sessions created by this manager.intGets the current rate of session creation (in session per minute).intGets the current rate of session expiration (in session per minute).default 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.voidload()Load any currently active sessions that were previously unloaded to the appropriate persistence mechanism, if any.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.default StringrotateSessionId(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.voidsetExpiredSessions(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.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.voidsetSessionActivityCheck(boolean sessionActivityCheck) Configure if Tomcat will track the number of active requests for each session.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.voidunload()Save any currently active sessions in the appropriate persistence mechanism, if any.booleanwillAttributeDistribute(String name, Object value) Would the Manager distribute the given session attribute?
- 
Method Details- 
getContextContext getContext()Get the Context with which this Manager is associated.- Returns:
- The associated Context
 
- 
setContextSet 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.- Parameters:
- context- The newly associated Context
 
- 
getSessionIdGeneratorSessionIdGenerator getSessionIdGenerator()- Returns:
- the session id generator
 
- 
setSessionIdGeneratorSets the session id generator- Parameters:
- sessionIdGenerator- The session id generator
 
- 
getSessionCounterlong getSessionCounter()Returns the total number of sessions created by this manager.- Returns:
- Total number of sessions created by this manager.
 
- 
setSessionCountervoid setSessionCounter(long sessionCounter) Sets the total number of sessions created by this manager.- Parameters:
- sessionCounter- Total number of sessions created by this manager.
 
- 
getMaxActiveint getMaxActive()Gets the maximum number of sessions that have been active at the same time.- Returns:
- Maximum number of sessions that have been active at the same time
 
- 
setMaxActivevoid setMaxActive(int maxActive) (Re)sets the maximum number of sessions that have been active at the same time.- Parameters:
- maxActive- Maximum number of sessions that have been active at the same time.
 
- 
getActiveSessionsint getActiveSessions()Gets the number of currently active sessions.- Returns:
- Number of currently active sessions
 
- 
getExpiredSessionslong getExpiredSessions()Gets the number of sessions that have expired.- Returns:
- Number of sessions that have expired
 
- 
setExpiredSessionsvoid setExpiredSessions(long expiredSessions) Sets the number of sessions that have expired.- Parameters:
- expiredSessions- Number of sessions that have expired
 
- 
getRejectedSessionsint getRejectedSessions()Gets the number of sessions that were not created because the maximum number of active sessions was reached.- Returns:
- Number of rejected sessions
 
- 
getSessionMaxAliveTimeint getSessionMaxAliveTime()Gets the longest time (in seconds) that an expired session had been alive.- Returns:
- Longest time (in seconds) that an expired session had been alive.
 
- 
setSessionMaxAliveTimevoid setSessionMaxAliveTime(int sessionMaxAliveTime) Sets the longest time (in seconds) that an expired session had been alive.- Parameters:
- sessionMaxAliveTime- Longest time (in seconds) that an expired session had been alive.
 
- 
getSessionAverageAliveTimeint getSessionAverageAliveTime()Gets the average time (in seconds) that expired sessions had been alive. This may be based on sample data.- Returns:
- Average time (in seconds) that expired sessions had been alive.
 
- 
getSessionCreateRateint getSessionCreateRate()Gets the current rate of session creation (in session per minute). This may be based on sample data.- Returns:
- The current rate (in sessions per minute) of session creation
 
- 
getSessionExpireRateint getSessionExpireRate()Gets the current rate of session expiration (in session per minute). This may be based on sample data- Returns:
- The current rate (in sessions per minute) of session expiration
 
- 
addAdd this Session to the set of active Sessions for this Manager.- Parameters:
- session- Session to be added
 
- 
addPropertyChangeListenerAdd a property change listener to this component.- Parameters:
- listener- The listener to add
 
- 
rotateSessionIdChange the session ID of the current session to a new randomly generated session ID.- Parameters:
- session- The session to change the session ID for
- Returns:
- The new session ID
 
- 
changeSessionIdChange the session ID of the current session to a specified session ID.- Parameters:
- session- The session to change the session ID for
- newId- new session ID
 
- 
createEmptySessionSession createEmptySession()Get 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.- Returns:
- An empty Session object
 
- 
createSessionConstruct 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.- Parameters:
- sessionId- 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.
- Returns:
- An empty Session object with the given ID or a newly created session ID if none was specified
- Throws:
- IllegalStateException- if a new session cannot be instantiated for any reason
 
- 
findSessionReturn the active Session, associated with this Manager, with the specified session id (if any); otherwise returnnull.- 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:
- IllegalStateException- if a new session cannot be instantiated for any reason
- IOException- if an input/output error occurs while processing this request
 
- 
findSessionsSession[] findSessions()Return the set of active Sessions associated with this Manager. If this Manager has no active Sessions, a zero-length array is returned.- Returns:
- All the currently active sessions managed by this manager
 
- 
loadLoad any currently active sessions that were previously unloaded to the appropriate persistence mechanism, if any. If persistence is not supported, this method returns without doing anything.- Throws:
- ClassNotFoundException- if a serialized class cannot be found during the reload
- IOException- if an input/output error occurs
 
- 
removeRemove this Session from the active Sessions for this Manager.- Parameters:
- session- Session to be removed
 
- 
removeRemove this Session from the active Sessions for this Manager.- Parameters:
- session- Session to be removed
- update- Should the expiration statistics be updated
 
- 
removePropertyChangeListenerRemove a property change listener from this component.- Parameters:
- listener- The listener to remove
 
- 
unloadSave any currently active sessions in the appropriate persistence mechanism, if any. If persistence is not supported, this method returns without doing anything.- Throws:
- IOException- if an input/output error occurs
 
- 
backgroundProcessvoid 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.
- 
willAttributeDistributeWould the Manager distribute the given session attribute? Manager implementations may provide additional configuration options to control which attributes are distributable.- Parameters:
- name- The attribute name
- value- The attribute value
- Returns:
- trueif the Manager would distribute the given attribute otherwise- false
 
- 
getNotifyBindingListenerOnUnchangedValuedefault boolean getNotifyBindingListenerOnUnchangedValue()When 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.- Returns:
- trueif the listener will be notified,- falseif it will not
 
- 
setNotifyBindingListenerOnUnchangedValuevoid setNotifyBindingListenerOnUnchangedValue(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.- Parameters:
- notifyBindingListenerOnUnchangedValue-- truethe listener will be called,- falseit will not
 
- 
getNotifyAttributeListenerOnUnchangedValuedefault boolean getNotifyAttributeListenerOnUnchangedValue()When 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.- Returns:
- trueif the listener will be notified,- falseif it will not
 
- 
setNotifyAttributeListenerOnUnchangedValuevoid setNotifyAttributeListenerOnUnchangedValue(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.- Parameters:
- notifyAttributeListenerOnUnchangedValue-- truethe listener will be called,- falseit will not
 
- 
getSessionActivityCheckdefault boolean getSessionActivityCheck()If 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.- Returns:
- the flag value
 
- 
setSessionActivityCheckvoid setSessionActivityCheck(boolean sessionActivityCheck) Configure 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.- Parameters:
- sessionActivityCheck- the new flag value
 
- 
getSessionLastAccessAtStartdefault boolean getSessionLastAccessAtStart()If 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.- Returns:
- the flag value
 
- 
setSessionLastAccessAtStartvoid setSessionLastAccessAtStart(boolean sessionLastAccessAtStart) Configure 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.- Parameters:
- sessionLastAccessAtStart- the new flag value
 
 
-