01: // Copyright 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.services;
16:
17: /**
18: * Responsible for managing <em>application state objects</em>, objects which persist between
19: * requests, but are not tied to any individual page or component. ASOs are also created on demand.
20: * ASOs are typically stored in the session, so that they are specific to a particular client.
21: */
22: public interface ApplicationStateManager {
23: /**
24: * For a given class, find the ASO for the class, creating it if necessary. The manager has a
25: * configuration that determines how an instance is stored and created as needed. A requested
26: * ASO not in the configuration is assumed to be created via a no-args constructor, and stored
27: * in the session.
28: *
29: * @param <T>
30: * @param asoClass
31: * identifies the ASO to access or create
32: * @return the ASO instance
33: */
34: <T> T get(Class<T> asoClass);
35:
36: /**
37: * Returns true if the ASO already exists, false if it has not yet been created.
38: *
39: * @param asoClass
40: * used to select the ASO
41: * @return true if ASO exists, false if null
42: */
43: <T> boolean exists(Class<T> asoClass);
44:
45: /**
46: * Stores a new ASO, replacing the existing ASO (if any). Storing the value null will delete the
47: * ASO so that it may be re-created later.
48: *
49: * @param <T>
50: * @param asoClass
51: * the type of ASO
52: * @param aso
53: * the ASO instance
54: */
55: <T> void set(Class<T> asoClass, T aso);
56: }
|