1    /*
2     * Copyright 2010 :torweg free software group
3     *
4     * This program is free software: you can redistribute it and/or modify
5     * it under the terms of the GNU General Public License as published by
6     * the Free Software Foundation, either version 3 of the License, or
7     * (at your option) any later version.
8     * 
9     * This program is distributed in the hope that it will be useful,
10    * but WITHOUT ANY WARRANTY; without even the implied warranty of
11    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    * GNU General Public License for more details.
13    * 
14    * You should have received a copy of the GNU General Public License
15    * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16    *
17    */
18   package org.torweg.pulse.annotations;
19   
20   import java.lang.annotation.Documented;
21   import java.lang.annotation.ElementType;
22   import java.lang.annotation.Retention;
23   import java.lang.annotation.RetentionPolicy;
24   import java.lang.annotation.Target;
25   
26   /**
27    * used for annotation based processing of the {@code Parameter}s of the {@code
28    * Command}.
29    * <p>
30    * A parameter of a method annotated with either {@link Action} or
31    * {@link AnyAction} that is annotated with this annotation can have values
32    * injected based on {@link org.torweg.pulse.service.request.Command#getParameters()}.
33    * </p>
34    * <p>
35    * The injection is controlled by the {@link org.torweg.pulse.annotations.RequestBean.Parameter} annotation.
36    * </p>
37    * 
38    * @author Thomas Weber
39    * @version $Revision: 1822 $
40    */
41   @Documented
42   @Retention(RetentionPolicy.RUNTIME)
43   @Target( { ElementType.PARAMETER })
44   public @interface RequestBean {
45   
46       /**
47        * marks either fields or methods to be injected with a parameter.
48        * <p>
49        * Methods annotated with {@code @RequestBean.Parameter} must take exactly
50        * one argument of one of the <em>acceptable types</em>.<br/>
51        * Fields annotated with {@code @RequestBean.Parameter} must be of one of
52        * the <em>acceptable types</em>.<br/>
53        * The <em>acceptable types</em> are:<br/>
54        * {@code String}, {@code String[]}, {@code Collection<String>}, {@code
55        * Set<String>}, {@code List<String>} or {@code Parameter}.
56        * </p>
57        * 
58        * <p>
59        * Please take not that using {@code Set}s as the destination type will
60        * eliminate duplicate values as this is the contract established by
61        * {@link java.util.Set}.
62        * </p>
63        */
64       @Documented
65       @Retention(RetentionPolicy.RUNTIME)
66       @Target( { ElementType.FIELD, ElementType.METHOD })
67       public @interface Parameter {
68   
69           /**
70            * the name of the {@code Parameter} to be used for injecting the value.
71            * 
72            * @see org.torweg.pulse.service.request.Command
73            */
74           String value();
75       }
76   
77       /**
78        * marks either fields or methods to be injected with the current {@code
79        * ServiceRequest}.
80        * <p>
81        * Methods annotated with {@code @RequestBean.ServiceRequest} must take
82        * exactly one argument of the following type: {@code ServiceRequest}.<br/>
83        * Fields annotated with {@code @RequestBean.ServiceRequest} must be of the
84        * following type: {@code ServiceRequest}.
85        * </p>
86        */
87       @Documented
88       @Retention(RetentionPolicy.RUNTIME)
89       @Target( { ElementType.FIELD, ElementType.METHOD })
90       public @interface ServiceRequest {
91   
92       }
93   
94       /**
95        * marks either fields or methods to be injected with the current {@code
96        * Bundle}.
97        * <p>
98        * Methods annotated with {@code @RequestBean.Bundle} must take exactly one
99        * argument of the following type: {@code Bundle}.<br/>
100       * Fields annotated with {@code @RequestBean.Bundle} must be of the
101       * following type: {@code Bundle}.
102       * </p>
103       */
104      @Documented
105      @Retention(RetentionPolicy.RUNTIME)
106      @Target( { ElementType.FIELD, ElementType.METHOD })
107      public @interface Bundle {
108  
109      }
110  
111  }
112