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
015package org.apache.tapestry.engine.state;
016
017/**
018 * Interface for an object that manages a single application state object. Represents the named
019 * intersection of a {@link org.apache.tapestry.engine.state.StateObjectPersistenceManager}for
020 * storing the state object between request cycles, and a
021 * {@link org.apache.tapestry.engine.state.StateObjectFactory}to create the object in the first
022 * place.
023 * 
024 * @author Howard M. Lewis Ship
025 * @since 4.0
026 */
027public interface StateObjectManager
028{
029    /**
030     * Returns true if the application state object exists (i.e., a value has been stored).
031     */
032    public boolean exists();
033
034    /**
035     * Gets or creates the application state object.
036     */
037
038    public Object get();
039
040    /**
041     * Stores (if necessary) the object back into persistent storage. This is not application to all
042     * storage scopes.
043     * 
044     * @param stateObject
045     *            the application state object previously obtained from {@link #get()}.
046     */
047
048    public void store(Object stateObject);
049}