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 com.fatwire.gst.foundation.controller.annotation;
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 *
25 * Annotation to bind variables to the Action.
26 * <p>
27 *
28 * <pre>
29 * {@code
30 * class MyAction implements Action {
31 *
32 * {@literal @}Bind String rendermode;
33 * {@literal @}Bind("myVar") String theVariable;
34 * {@literal @}Bind(scope="session") ShoppingCart cart;
35 *
36 * public void handleRequest(ICS ics){
37 * if("live".equals(rendermode){
38 * // do something when rendermode=live
39 * }
40 * }
41 *
42 * }
43 * }
44 * </pre>
45 * @author Dolf.Dijkstra
46 * @since 12 mei 2012
47 *
48 */
49
50 @Retention(RetentionPolicy.RUNTIME)
51 @Target(ElementType.FIELD)
52 public @interface Bind {
53 public enum Scope {
54 ics, request, session
55 }
56
57 /**
58 * @return the key name of the variable to bind
59 */
60 String value() default "";
61
62 /**
63 * @return the match argument from render:lookup tag
64 */
65 Scope scope() default Scope.ics;
66 }