Class 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() and stop() 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 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
    • Constructor Detail

      • StandardManager

        public StandardManager()
    • 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:
        setContainer in interface Manager
        Overrides:
        setContainer in class ManagerBase
        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:
        getInfo in interface Manager
        Overrides:
        getInfo in class ManagerBase
      • 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:
        getName in class ManagerBase
      • 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 to null.
        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, return null.
        Specified by:
        createSession in interface Manager
        Overrides:
        createSession in class ManagerBase
        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:
        createSession in interface Manager
        Overrides:
        createSession in class ManagerBase
        Parameters:
        sessionId - the session id to assign to the new session
        Returns:
        the new session, or null if a session with the requested id already exists
        Throws:
        IllegalStateException - if a new session cannot be instantiated for any reason
      • clearStore

        public void clearStore()
      • load

        public void load()
                  throws ClassNotFoundException,
                         IOException
        Loads 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:
        load in interface Manager
        Throws:
        ClassNotFoundException - if a serialized class cannot be found during the reload
        IOException - if a read error occurs
      • unload

        public void unload()
                    throws IOException
        Save any currently active sessions in the appropriate persistence mechanism, if any. If persistence is not supported, this method returns without doing anything.
        Specified by:
        unload in interface Manager
        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 IOException
        Save 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
      • addLifecycleListener

        public void addLifecycleListener​(LifecycleListener listener)
        Add a lifecycle event listener to this component.
        Specified by:
        addLifecycleListener in interface Lifecycle
        Parameters:
        listener - The listener to add
      • removeLifecycleListener

        public void removeLifecycleListener​(LifecycleListener listener)
        Remove a lifecycle event listener from this component.
        Specified by:
        removeLifecycleListener in interface Lifecycle
        Parameters:
        listener - The listener to remove
      • start

        public void start()
                   throws LifecycleException
        Prepare for the beginning of active use of the public methods of this component. This method should be called after configure(), and before any of the public methods of the component are utilized.
        Specified by:
        start in interface Lifecycle
        Throws:
        LifecycleException - if this component detects a fatal error that prevents this component from being used
      • stop

        public void stop()
                  throws LifecycleException
        Gracefully 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:
        stop in interface Lifecycle
        Throws:
        LifecycleException - if this component detects a fatal error that needs to be reported
      • stop

        public void stop​(boolean isShutdown)
                  throws LifecycleException
        Gracefully 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
      • processExpires

        public void processExpires()
        Invalidate all sessions that have expired.