001    // Copyright 2005 The Apache Software Foundation
002    //
003    // Licensed under the Apache License, Version 2.0 (the "License");
004    // you may not use this file except in compliance with the License.
005    // You may obtain a copy of the License at
006    //
007    //     http://www.apache.org/licenses/LICENSE-2.0
008    //
009    // Unless required by applicable law or agreed to in writing, software
010    // distributed under the License is distributed on an "AS IS" BASIS,
011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012    // See the License for the specific language governing permissions and
013    // limitations under the License.
014    
015    package org.apache.tapestry.engine.state;
016    
017    /**
018     * @author Howard M. Lewis Ship
019     * @since 4.0
020     */
021    public interface ApplicationStateManager
022    {
023        /**
024         * Checks to see if the named object exists.
025         * 
026         * @param objectName
027         *            the name of the application state object
028         * @return True if the object with the specified name exists, false otherwise.
029         * 
030         * @throws org.apache.hivemind.ApplicationRuntimeException
031         *          If no such object is declared
032         */
033        boolean exists(String objectName);
034    
035        /**
036         * Gets the named application state object, creating it if necessary.
037         * 
038         * @param objectName
039         *            the name of the application state object
040         * @return the object
041         * @throws org.apache.hivemind.ApplicationRuntimeException
042         *             if no such object is declared
043         */
044        Object get(String objectName);
045        
046        /**
047         * Stores a new state object, replacing the old one. The
048         * new object may be null.
049         * 
050         * @param objectName the name of the object to store
051         * @param stateObject the new object, possibly null
052         * @throws org.apache.hivemind.ApplicationRuntimeException
053         *             if no such object is declared
054         */
055        
056        void store(String objectName, Object stateObject);
057    
058        /**
059         * Asks each {@link StateObjectManager} to store each object obtained.
060         */
061    
062        void flush();
063    }