01: // Copyright 2006, 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.annotations;
16:
17: import static java.lang.annotation.ElementType.FIELD;
18: import static java.lang.annotation.RetentionPolicy.RUNTIME;
19:
20: import java.lang.annotation.Documented;
21: import java.lang.annotation.Retention;
22: import java.lang.annotation.Target;
23:
24: import org.apache.tapestry.services.MetaDataLocator;
25: import org.apache.tapestry.services.Session;
26:
27: /**
28: * Identifies a field as persistent, meaning its value persists from one request to the next.
29: * Different strategies exist for how this is accomplished, the most common being the default,
30: * "session", which stores the field's value in the {@link Session}.
31: * <p>
32: * In most cases, the value will be omitted and will default to the empty string. This forces a
33: * search for the correct strategy. Starting with the component (or mixin) itself, a check is made
34: * for the {@link Meta meta data property} <code>tapestry.persistence-strategy</code>. If a value
35: * is found, it is used, otherwise the search continues up the inheritance hierarchy, towards the
36: * page. If not found, then the "session" strategy is used.
37: * <p>
38: * In this way, the session persistence strategy for a component and all of its sub-components can
39: * be controlled by the containing component.
40: *
41: * @see MetaDataLocator
42: */
43: @Target(FIELD)
44: @Documented
45: @Retention(RUNTIME)
46: public @interface Persist {
47:
48: /**
49: * The strategy used to persist the value. The default value, the empty string, allows
50: * persistence to be decided by the containing component and component hierarchy.
51: */
52: String value() default "";
53: }
|