01: package dalma;
02:
03: import static java.lang.annotation.ElementType.FIELD;
04: import static java.lang.annotation.ElementType.METHOD;
05: import java.lang.annotation.Retention;
06: import static java.lang.annotation.RetentionPolicy.RUNTIME;
07: import java.lang.annotation.Target;
08:
09: /**
10: * Identifies a field/method that needs to be injected by the dalma container.
11: *
12: * <p>
13: * A resource must be one of the following types:
14: *
15: * <ol>
16: * <li>{@link EndPoint}-derived type.
17: * The container will require the user to configure an endpoint and injects the
18: * configured endpoint.
19: * <li>{@link String}
20: * The container will inject a string that the user configured.
21: * <li>{@code boolean}
22: * The container will inject a true/false option that the user configured.
23: * <li>{@code int}
24: * The container will inject a number that the user configured.
25: * </ol>
26: *
27: * <p>
28: * ... and it must be either a public field of the form {@code public T xyz}
29: * or a public setter method of the form {@code public void setXyz(T)}.
30: *
31: * <p>
32: * The container uses these annotations to determine what configuration is needed
33: * by a program.
34: *
35: * @author Kohsuke Kawaguchi
36: */
37: @Retention(RUNTIME)
38: @Target({FIELD,METHOD})
39: public @interface Resource {
40: /**
41: * Human-readable message that explains what this resource is.
42: *
43: * This message is presented to the user in the configuration screen.
44: * For example, this could be something like
45: * "e-mail address that is connected to the daemon" (for e-mail endpoint)
46: * or maybe "the greeting message" (for a string resource.)
47: */
48: String description() default "";
49:
50: /**
51: * Flag that indicates if this resource can be absent.
52: *
53: * <p>
54: * If true, the user may choose not to set the value (in which case
55: * the VM-default value or null will be injected.) If false, which
56: * is the default, the resource must be configured by the user to
57: * a non-null value.
58: */
59: boolean optional() default false;
60: }
|