/* * 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; import java.beans.PropertyChangeListener; import java.io.IOException; /** * 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:
*
Lifecycle so that the Context can indicate
* that a restart is required.
* stop() to be followed by a call to
* start() on the same Manager instance.
* null.
*
* @param 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.
* @exception IllegalStateException if a new session cannot be
* instantiated for any reason
*
* @return An empty Session object with the given ID or a newly created
* session ID if none was specified
*/
public Session createSession(String sessionId);
/**
* Return the active Session, associated with this Manager, with the
* specified session id (if any); otherwise return null.
*
* @param id The session id for the session to be returned
*
* @exception IllegalStateException if a new session cannot be
* instantiated for any reason
* @exception IOException if an input/output error occurs while
* processing this request
*
* @return the request session or {@code null} if a session with the
* requested ID could not be found
*/
public Session findSession(String id) throws IOException;
/**
* Return the set of active Sessions associated with this Manager.
* If this Manager has no active Sessions, a zero-length array is returned.
*
* @return All the currently active sessions managed by this manager
*/
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.
*
* @exception ClassNotFoundException if a serialized class cannot be
* found during the reload
* @exception IOException if an input/output error occurs
*/
public void load() throws ClassNotFoundException, IOException;
/**
* Remove this Session from the active Sessions for this Manager.
*
* @param session Session to be removed
*/
public void remove(Session session);
/**
* Remove this Session from the active Sessions for this Manager.
*
* @param session Session to be removed
* @param update Should the expiration statistics be updated
*/
public void remove(Session session, boolean update);
/**
* Remove a property change listener from this component.
*
* @param 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.
*
* @exception 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();
/**
* Would the Manager distribute the given session attribute? Manager
* implementations may provide additional configuration options to control
* which attributes are distributable.
*
* @param name The attribute name
* @param value The attribute value
*
* @return {@code true} if the Manager would distribute the given attribute
* otherwise {@code false}
*/
public boolean willAttributeDistribute(String name, Object value);
}