Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one or more
   * contributor license agreements.  See the NOTICE file distributed with
   * this work for additional information regarding copyright ownership.
   * The ASF licenses this file to You under the Apache License, Version 2.0
   * (the "License"); you may not use this file except in compliance with
   * the License.  You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 
 package org.apache.catalina;
 
 
A Manager manages the pool of Sessions that are associated with a particular Container. 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 Lifecycle so that the Context can indicate that a restart is required.
  • Must allow a call to stop() to be followed by a call to start() on the same Manager instance.

Author(s):
Craig R. McClanahan
Version:
$Revision: 1579 $ $Date: 2010-11-19 17:06:19 +0100 (Fri, 19 Nov 2010) $
 
 
 public interface Manager {
 
 
     // ------------------------------------------------------------- Properties
 

    
Return the Container with which this Manager is associated.
 
     public Container getContainer();


    
Set the Container with which this Manager is associated.

Parameters:
container The newly associated Container
 
     public void setContainer(Container container);


    
Return the distributable flag for the sessions supported by this Manager.
 
     public boolean getDistributable();


    
Set the distributable flag for the sessions supported by this Manager. If this flag is set, all user data objects added to sessions associated with this manager must implement Serializable.

Parameters:
distributable The new distributable flag
 
     public void setDistributable(boolean distributable);


    
Return descriptive information about this Manager implementation and the corresponding version number, in the format <description>/<version>.
 
     public String getInfo();


    
Return the default maximum inactive interval (in seconds) for Sessions created by this Manager.
 
     public int getMaxInactiveInterval();


    
Set the default maximum inactive interval (in seconds) for Sessions created by this Manager.

Parameters:
interval The new default value
    public void setMaxInactiveInterval(int interval);


    
Gets the session id length (in bytes) of Sessions created by this Manager.

Returns:
The session id length
    public int getSessionIdLength();


    
Sets the session id length (in bytes) for Sessions created by this Manager.

Parameters:
idLength The session id length
    public void setSessionIdLength(int idLength);


    
Returns the total number of sessions created by this manager.

Returns:
Total number of sessions created by this manager.
    public int getSessionCounter();


    
Sets the total number of sessions created by this manager.

Parameters:
sessionCounter Total number of sessions created by this manager.
    public void setSessionCounter(int sessionCounter);


    
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
    public int getMaxActive();


    
(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.
    public void setMaxActive(int maxActive);


    
Gets the number of currently active sessions.

Returns:
Number of currently active sessions
    public int getActiveSessions();


    
Gets the number of sessions that have expired.

Returns:
Number of sessions that have expired
    public int getExpiredSessions();


    
Sets the number of sessions that have expired.

Parameters:
expiredSessions Number of sessions that have expired
    public void setExpiredSessions(int expiredSessions);


    
Gets the number of sessions that were not created because the maximum number of active sessions was reached.

Returns:
Number of rejected sessions
    public int getRejectedSessions();


    
Sets the number of sessions that were not created because the maximum number of active sessions was reached.

Parameters:
rejectedSessions Number of rejected sessions
    public void setRejectedSessions(int rejectedSessions);


    
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.
    public int getSessionMaxAliveTime();


    
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.
    public void setSessionMaxAliveTime(int sessionMaxAliveTime);


    
Gets the average time (in seconds) that expired sessions had been alive.

Returns:
Average time (in seconds) that expired sessions had been alive.
    public int getSessionAverageAliveTime();


    
Sets the average time (in seconds) that expired sessions had been alive.

Parameters:
sessionAverageAliveTime Average time (in seconds) that expired sessions had been alive.
    public void setSessionAverageAliveTime(int sessionAverageAliveTime);
    // --------------------------------------------------------- Public Methods


    
Add this Session to the set of active Sessions for this Manager.

Parameters:
session Session to be added
    public void add(Session session);


    
Add a property change listener to this component.

Parameters:
listener The listener to add
    public void addPropertyChangeListener(PropertyChangeListener listener);


    
Change the session ID of the current session to a new randomly generated session ID.

Parameters:
session The session to change the session ID for
    public void changeSessionId(Session sessionRandom random);


    
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.
                                                                         
    public Session createEmptySession();


    
Construct 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, return null.

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.
Throws:
java.lang.IllegalStateException if a new session cannot be instantiated for any reason
    public Session createSession(String sessionIdRandom random);


    
Return the active Session, associated with this Manager, with the specified session id (if any); otherwise return null.

Parameters:
id The session id for the session to be returned
Throws:
java.lang.IllegalStateException if a new session cannot be instantiated for any reason
java.io.IOException if an input/output error occurs while processing this request
    public Session findSession(String idthrows IOException;


    
Return the set of active Sessions associated with this Manager. If this Manager has no active Sessions, a zero-length array is returned.
    public Session[] findSessions();


    
Load 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:
java.lang.ClassNotFoundException if a serialized class cannot be found during the reload
java.io.IOException if an input/output error occurs
    public void load() throws ClassNotFoundExceptionIOException;


    
Remove this Session from the active Sessions for this Manager.

Parameters:
session Session to be removed
    public void remove(Session session);


    
Remove a property change listener from this component.

Parameters:
listener The listener to remove
    public void removePropertyChangeListener(PropertyChangeListener listener);


    
Save any currently active sessions in the appropriate persistence mechanism, if any. If persistence is not supported, this method returns without doing anything.

Throws:
java.io.IOException if an input/output error occurs
    public void unload() throws IOException;
    
     
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.
     public void backgroundProcess();
New to GrepCode? Check out our FAQ X