Debian Codegraph @

src/jakarta/annotation/Resource.java

raw symbols SCIP
1 /*
2 * Copyright (c) 2005, 2020 Oracle and/or its affiliates. All rights reserved.
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v. 2.0, which is available at
6 * http://www.eclipse.org/legal/epl-2.0.
7 *
8 * This Source Code may also be made available under the following Secondary
9 * Licenses when the conditions for such availability set forth in the
10 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11 * version 2 with the GNU Classpath Exception, which is available at
12 * https://www.gnu.org/software/classpath/license.html.
13 *
14 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15 */
16
17 package jakarta.annotation;
18
19 import java.lang.annotation.*;
20 import static java.lang.annotation.ElementType.*;
21 import static java.lang.annotation.RetentionPolicy.*;
22
23 /**
24 * The <code>Resource</code> annotation marks a resource that is needed
25 * by the application. This annotation may be applied to an
26 * application component class, or to fields or methods of the
27 * component class. When the annotation is applied to a
28 * field or method, the container will inject an instance
29 * of the requested resource into the application component
30 * when the component is initialized. If the annotation is
31 * applied to the component class, the annotation declares a
32 * resource that the application will look up at runtime.
33 * <p>
34 * Even though this annotation is not marked <code>Inherited</code>, deployment
35 * tools are required to examine all superclasses of any component
36 * class to discover all uses of this annotation in all superclasses.
37 * All such annotation instances specify resources that are needed
38 * by the application component. Note that this annotation may
39 * appear on private fields and methods of superclasses; the container
40 * is required to perform injection in these cases as well.</p>
41 *
42 * @since 1.6, Common Annotations 1.0
43 */
44 @Target({TYPE, FIELD, METHOD})
45 @Retention(RUNTIME)
46 @Repeatable(Resources.class)
47 public @interface Resource {
48 /**
49 * The JNDI name of the resource. For field annotations,
50 * the default is the field name. For method annotations,
51 * the default is the JavaBeans property name corresponding
52 * to the method. For class annotations, there is no default
53 * and this must be specified.
54 */
55 String name() default "";
56
57 /**
58 * The name of the resource that the reference points to. It can
59 * link to any compatible resource using the global JNDI names.
60 *
61 * @since 1.7, Common Annotations 1.1
62 */
63
64 String lookup() default "";
65
66 /**
67 * The Java type of the resource. For field annotations,
68 * the default is the type of the field. For method annotations,
69 * the default is the type of the JavaBeans property.
70 * For class annotations, there is no default and this must be
71 * specified.
72 */
73 Class<?> type() default java.lang.Object.class;
74
75 /**
76 * The two possible authentication types for a resource.
77 */
78 enum AuthenticationType {
79 CONTAINER,
80 APPLICATION
81 }
82
83 /**
84 * The authentication type to use for this resource.
85 * This may be specified for resources representing a
86 * connection factory of any supported type, and must
87 * not be specified for resources of other types.
88 */
89 AuthenticationType authenticationType() default AuthenticationType.CONTAINER;
90
91 /**
92 * Indicates whether this resource can be shared between
93 * this component and other components.
94 * This may be specified for resources representing a
95 * connection factory of any supported type, and must
96 * not be specified for resources of other types.
97 */
98 boolean shareable() default true;
99
100 /**
101 * A product-specific name that this resource should be mapped to.
102 * The <code>mappedName</code> element provides for mapping the
103 * resource reference to the name of a resource known to the
104 * applicaiton server. The mapped name could be of any form.
105 * <p>Application servers are not required to support any particular
106 * form or type of mapped name, nor the ability to use mapped names.
107 * The mapped name is product-dependent and often installation-dependent.
108 * No use of a mapped name is portable.</p>
109 */
110 String mappedName() default "";
111
112 /**
113 * Description of this resource. The description is expected
114 * to be in the default language of the system on which the
115 * application is deployed. The description can be presented
116 * to the Deployer to help in choosing the correct resource.
117 */
118 String description() default "";
119 }