1 /*
2 * Copyright 2011 FatWire Corporation. All Rights Reserved.
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 at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * 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 and
14 * limitations under the License.
15 */
16 package tools.gsf.config.inject;
17
18 import java.lang.annotation.ElementType;
19 import java.lang.annotation.Retention;
20 import java.lang.annotation.RetentionPolicy;
21 import java.lang.annotation.Target;
22
23 /**
24 * Annotation to bind variables to the Action.
25 * <pre>
26 *
27 * class MyAction implements Action {
28 *
29 * {@literal @}Bind String rendermode;
30 * {@literal @}Bind("myVar") String theVariable;
31 * {@literal @}Bind(scope="session") ShoppingCart cart;
32 *
33 * public void handleRequest(ICS ics){
34 * if("live".equals(rendermode){
35 * // do something when rendermode=live
36 * }
37 * }
38 *
39 * }
40 *
41 * </pre>
42 *
43 * @author Dolf.Dijkstra
44 * @since 12 mei 2012
45 */
46
47 @Retention(RetentionPolicy.RUNTIME)
48 @Target(ElementType.FIELD)
49 public @interface Bind {
50
51 public enum Scope {
52 ics, request, session
53 }
54
55 /**
56 * @return the key name of the variable to bind
57 */
58 String value() default "";
59
60 /**
61 * @return the match argument from render:lookup tag
62 */
63 Scope scope() default Scope.ics;
64 }