Package org.apache.catalina.session
Class StandardManager
- java.lang.Object
-
- org.apache.catalina.session.ManagerBase
-
- org.apache.catalina.session.StandardManager
-
- All Implemented Interfaces:
PropertyChangeListener,EventListener,Lifecycle,Manager
- Direct Known Subclasses:
CookiePersistentManager
public class StandardManager extends ManagerBase implements Lifecycle, PropertyChangeListener
Standard implementation of the Manager interface that provides simple session persistence across restarts of this component (such as when the entire server is shut down and restarted, or when a particular web application is reloaded.IMPLEMENTATION NOTE: Correct behavior of session storing and reloading depends upon external calls to the
start()andstop()methods of this class at the correct times.- Version:
- $Revision: 1.14.6.2 $ $Date: 2008/04/17 18:37:20 $
- Author:
- Craig R. McClanahan, Jean-Francois Arcand
-
-
Field Summary
Fields Modifier and Type Field Description protected LifecycleSupportlifecycleThe lifecycle event support for this component.protected static StringnameThe descriptive name of this Manager implementation (for logging).-
Fields inherited from class org.apache.catalina.session.ManagerBase
container, debug, devRandomSource, distributable, domain, duplicates, entropy, expiredSessions, initialized, log, maxActive, maxActiveUpdateLock, maxInactiveInterval, oname, randomClass, randomIS, rb, rejectedSessions, sessionAverageAliveTime, sessionCounter, sessionIdLength, sessionLocker, sessionMaxAliveTime, sessions, support, uuidGenerator
-
Fields inherited from interface org.apache.catalina.Lifecycle
AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, INIT_EVENT, START_EVENT, STOP_EVENT
-
-
Constructor Summary
Constructors Constructor Description StandardManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLifecycleListener(LifecycleListener listener)Add a lifecycle event listener to this component.voidclearStore()SessioncreateSession()Construct and return a new session object, based on the default settings specified by this Manager's properties.SessioncreateSession(String sessionId)Construct and return a new session object, based on the default settings specified by this Manager's properties, using the specified session id.List<LifecycleListener>findLifecycleListeners()Gets the (possibly empty) list of lifecycle listeners associated with this StandardManager.StringgetInfo()Return descriptive information about this Manager implementation and the corresponding version number, in the format<description>/<version>.intgetMaxActiveSessions()Return the maximum number of active Sessions allowed, or -1 for no limit.StringgetName()Return the descriptive short name of this Manager implementation.StringgetPathname()Return the session persistence pathname, if any.longgetProcessingTime()voidload()Loads any currently active sessions that were previously unloaded to the appropriate persistence mechanism, if any.voidprocessExpires()Invalidate all sessions that have expired.voidpropertyChange(PropertyChangeEvent event)Process property change events from our associated Context.voidreadSessions(InputStream is)voidrelease()voidremoveLifecycleListener(LifecycleListener listener)Remove a lifecycle event listener from this component.voidsetContainer(Container container)Set the Container with which this Manager has been associated.voidsetMaxActiveSessions(int max)Set the maximum number of active Sessions allowed, or -1 for no limit.voidsetPathname(String pathname)Set the session persistence pathname to the specified value.voidsetProcessingTime(long processingTime)voidstart()Prepare for the beginning of active use of the public methods of this component.voidstop()Gracefully terminate the active use of the public methods of this component.voidstop(boolean isShutdown)Gracefully terminate the active use of the public methods of this component.voidunload()Save any currently active sessions in the appropriate persistence mechanism, if any.protected voidunload(boolean doExpire, boolean isShutdown)Save any currently active sessions in the appropriate persistence mechanism, if any.voidwriteSessions(OutputStream os)Writes all active sessions to the given output stream.voidwriteSessions(OutputStream os, boolean doExpire)-
Methods inherited from class org.apache.catalina.session.ManagerBase
add, addPropertyChangeListener, changeSessionId, checkSessionAttribute, clearSessions, createEmptySession, destroy, expireSession, findSession, findSession, findSession, findSessions, generateSessionId, generateSessionId, getActiveSessions, getClassName, getContainer, getDebug, getDistributable, getDomain, getDuplicates, getEngine, getEntropy, getExpiredSessions, getJvmRoute, getLastAccessedTimeMillis, getMaxActive, getMaxInactiveInterval, getMaxInactiveIntervalSeconds, getNewSession, getObjectName, getRandom, getRandomBytes, getRandomClass, getRandomFile, getRejectedSessions, getSessionAttribute, getSessionAverageAliveTime, getSessionAverageAliveTimeSeconds, getSessionCount, getSessionCounter, getSessionIdLength, getSessionMaxAliveTime, getSessionMaxAliveTimeSeconds, getUuidGenerator, init, isSessionVersioningSupported, listSessionIds, lockSession, log, log, postRequestDispatcherProcess, preRequestDispatcherProcess, remove, removePropertyChangeListener, resetRandom, setDebug, setDistributable, setDuplicates, setEntropy, setExpiredSessions, setMaxActive, setMaxInactiveInterval, setMaxInactiveIntervalSeconds, setRandomClass, setRandomFile, setRejectedSessions, setSessionAverageAliveTime, setSessionAverageAliveTimeSeconds, setSessionCount, setSessionCounter, setSessionIdLength, setSessionLocker, setSessionMaxAliveTime, setSessionMaxAliveTimeSeconds, setUuidGenerator, toCookie, unlockSession, update
-
-
-
-
Field Detail
-
lifecycle
protected LifecycleSupport lifecycle
The lifecycle event support for this component.
-
name
protected static final String name
The descriptive name of this Manager implementation (for logging).- See Also:
- Constant Field Values
-
-
Method Detail
-
setContainer
public void setContainer(Container container)
Set the Container with which this Manager has been associated. If it is a Context (the usual case), listen for changes to the session timeout property.- Specified by:
setContainerin interfaceManager- Overrides:
setContainerin classManagerBase- Parameters:
container- The associated Container
-
getInfo
public String getInfo()
Return descriptive information about this Manager implementation and the corresponding version number, in the format<description>/<version>.- Specified by:
getInfoin interfaceManager- Overrides:
getInfoin classManagerBase
-
getMaxActiveSessions
public int getMaxActiveSessions()
Return the maximum number of active Sessions allowed, or -1 for no limit.
-
getProcessingTime
public long getProcessingTime()
-
setProcessingTime
public void setProcessingTime(long processingTime)
-
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
-
getName
public String getName()
Return the descriptive short name of this Manager implementation.- Overrides:
getNamein classManagerBase
-
getPathname
public String getPathname()
Return the session persistence pathname, if any.
-
setPathname
public void setPathname(String pathname)
Set the session persistence pathname to the specified value. If no persistence support is desired, set the pathname tonull.- Parameters:
pathname- New session persistence pathname
-
createSession
public Session createSession()
Construct and return a new session object, based on the default settings specified by this Manager's properties. The session id will be assigned by this method, and available via the getId() method of the returned session. If a new session cannot be created for any reason, returnnull.- Specified by:
createSessionin interfaceManager- Overrides:
createSessionin classManagerBase- Throws:
IllegalStateException- if a new session cannot be instantiated for any reason
-
createSession
public Session createSession(String sessionId)
Construct and return a new session object, based on the default settings specified by this Manager's properties, using the specified session id. IMPLEMENTATION NOTE: This method must be kept in sync with the createSession method that takes no arguments.- Specified by:
createSessionin interfaceManager- Overrides:
createSessionin classManagerBase- Parameters:
sessionId- the session id to assign to the new session- Returns:
- the new session, or
nullif a session with the requested id already exists - Throws:
IllegalStateException- if a new session cannot be instantiated for any reason
-
release
public void release()
- Overrides:
releasein classManagerBase
-
clearStore
public void clearStore()
-
load
public void load() throws ClassNotFoundException, IOExceptionLoads 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.- Specified by:
loadin interfaceManager- Throws:
ClassNotFoundException- if a serialized class cannot be found during the reloadIOException- if a read error occurs
-
readSessions
public void readSessions(InputStream is) throws ClassNotFoundException, IOException
- Throws:
ClassNotFoundExceptionIOException
-
unload
public void unload() throws IOExceptionSave any currently active sessions in the appropriate persistence mechanism, if any. If persistence is not supported, this method returns without doing anything.- Specified by:
unloadin interfaceManager- Throws:
IOException- if an input/output error occurs
-
writeSessions
public void writeSessions(OutputStream os) throws IOException
Writes all active sessions to the given output stream.- Parameters:
os- the output stream to which to write- Throws:
IOException- if an input/output error occurs
-
unload
protected void unload(boolean doExpire, boolean isShutdown) throws IOExceptionSave any currently active sessions in the appropriate persistence mechanism, if any. If persistence is not supported, this method returns without doing anything.- Parameters:
isShutdown- true if this manager is being stopped as part of a domain shutdown (as opposed to an undeployment), and false otherwise- Throws:
IOException- if an input/output error occurs
-
writeSessions
public void writeSessions(OutputStream os, boolean doExpire) throws IOException
- Throws:
IOException
-
addLifecycleListener
public void addLifecycleListener(LifecycleListener listener)
Add a lifecycle event listener to this component.- Specified by:
addLifecycleListenerin interfaceLifecycle- Parameters:
listener- The listener to add
-
findLifecycleListeners
public List<LifecycleListener> findLifecycleListeners()
Gets the (possibly empty) list of lifecycle listeners associated with this StandardManager.- Specified by:
findLifecycleListenersin interfaceLifecycle
-
removeLifecycleListener
public void removeLifecycleListener(LifecycleListener listener)
Remove a lifecycle event listener from this component.- Specified by:
removeLifecycleListenerin interfaceLifecycle- Parameters:
listener- The listener to remove
-
start
public void start() throws LifecycleExceptionPrepare for the beginning of active use of the public methods of this component. This method should be called afterconfigure(), and before any of the public methods of the component are utilized.- Specified by:
startin interfaceLifecycle- Throws:
LifecycleException- if this component detects a fatal error that prevents this component from being used
-
stop
public void stop() throws LifecycleExceptionGracefully terminate the active use of the public methods of this component. This method should be the last one called on a given instance of this component.- Specified by:
stopin interfaceLifecycle- Throws:
LifecycleException- if this component detects a fatal error that needs to be reported
-
stop
public void stop(boolean isShutdown) throws LifecycleExceptionGracefully terminate the active use of the public methods of this component. This method should be the last one called on a given instance of this component.- Parameters:
isShutdown- true if this manager is being stopped as part of a domain shutdown (as opposed to an undeployment), and false otherwise- Throws:
LifecycleException- if this component detects a fatal error that needs to be reported
-
propertyChange
public void propertyChange(PropertyChangeEvent event)
Process property change events from our associated Context.- Specified by:
propertyChangein interfacePropertyChangeListener- Parameters:
event- The property change event that has occurred
-
processExpires
public void processExpires()
Invalidate all sessions that have expired.
-
-