1/*2 * Copyright 2000-2002,2004 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */1617// package18packageorg.apache.jetspeed.services.statemanager;
1920// imports21import javax.servlet.http.HttpSession;
2223/***24* <p>The StateManagerService is a service that manages SessionState information.25* Each SessionState is identified by a unique key in this service. The SessionState26* is composed of name - value sets of attributes, stored under the key by the service.</p>27* <p>See the proposal: jakarta-jetspeed/proposals/StateManager.txt for more details.</p>28* <p>Attribute values placed into SessionStates may be automatically removed, for example when29* a SessionState expires in some way, or by means of some other automatic service. These value30* objects can be notified of their placement into and out of the SessionState. Objects that wish31* to receive this notification implement the SessionStateBindingListener interface. This is based32* on and similar to the HttpSessionBindingListener mechanism.</p>33* <p>To support the "current" routines; the ability to get a session state based34* on the current http session, this service must be installed properly into the35* procssing of each http request. At the start of the request, the HttpSession36* of the request must be passed into the setCurrentContext() method. At the end37* of the request, clearCurrentContext() is called. For Jetspeed, this is done in38* the JetspeedRunDataService, which is always going to be called by Turbine in this39* way.</p>40* @version $Revision: 1.5 $41* @see org.apache.jetspeed.services.statemanager.SessionState42* @see org.apache.jetspeed.services.statemanager.SessionStateBindingListener43* @author <a href="mailto:ggolden@apache.org">Glenn R. Golden</a>44*/45publicinterfaceStateManagerService46 {
47/*** The name used to find the service in the service manager. */48public String SERVICE_NAME = "StateManagerService";
4950/***51 * Access the named attribute of the keyed state.52 * @param key The state key.53 * @param name The attribute name.54 * @return The named attribute value of the keyed state.55 */56public Object getAttribute ( String key, String name );
5758/***59 * Set the named state attribute of the keyed state with the provided object.60 * @param key The state key.61 * @param name The attribute name.62 * @param value The new value of the attribute (any object type).63 */64publicvoid setAttribute( String key, String name, Object value );
6566/***67 * Remove the named state attribute of the keyed state, if it exists.68 * @param key The state key.69 * @param name The attribute name.70 */71publicvoid removeAttribute( String key, String name );
7273/***74 * Remove all state attribute of the keyed state.75 * @param key The state key.76 */77publicvoid clear( String key );
7879/***80 * Access an array of all names of attributes stored in the keyed state.81 * @param key The state key.82 * @return An array of all names of attributes stored in the keyed state.83 */84public String[] getAttributeNames( String key );
8586/***87 * Access an SessionState object with the given key.88 * @param key The SessionState key.89 * @return an SessionState object with the given key.90 */91publicSessionState getSessionState( String key );
9293/***94 * Access the SessionState object associated with the current request's http session.95 * The session id is used as the key.96 * @return an SessionState object associated with the current request's http session.97 */98publicSessionState getCurrentSessionState();
99100/***101 * Access the SessionState object associated with the current request's http session with the given key.102 * @param key The string to add to the session id to form the SessionState key.103 * @return an SessionState object associated with the current request's http session with the given key.104 */105publicSessionState getCurrentSessionState( String key );
106107/***108 * Retire, forget about and clean up all states that start with the given key.109 * @param keyStart The beginning of the key of the states to clean up.110 */111publicvoid retireState( String keyStart );
112113/***114 * Set the "current" context for this thread -115 * Call this at the start of each request, and call %%% at the end.116 * getCurrentSession() uses this for the session state key.117 * @param session the HttpSession of the current request.118 */119publicvoid setCurrentContext( HttpSession session );
120121/***122 * Clear the "current context for this thread -123 * Call at the end of each request, balanced with calls to setCurrentContext()124 */125publicvoid clearCurrentContext();
126127 } // interface StateManagerService128129/***********************************************************************************130*131* $Header: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/statemanager/StateManagerService.java,v 1.5 2004/02/23 03:38:28 jford Exp $132*133**********************************************************************************/134