8
|
1 |
/*
|
|
2 |
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation. Sun designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Sun in the LICENSE file that accompanied this code.
|
|
10 |
*
|
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
15 |
* accompanied this code).
|
|
16 |
*
|
|
17 |
* You should have received a copy of the GNU General Public License version
|
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 |
*
|
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
* have any questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
//Copyright Sun Microsystems Inc. 2004 - 2005.
|
|
27 |
|
|
28 |
package javax.annotation;
|
|
29 |
|
|
30 |
import java.lang.annotation.*;
|
|
31 |
import static java.lang.annotation.ElementType.*;
|
|
32 |
import static java.lang.annotation.RetentionPolicy.*;
|
|
33 |
|
|
34 |
/**
|
|
35 |
* The Resource annotation marks a resource that is needed
|
|
36 |
* by the application. This annotation may be applied to an
|
|
37 |
* application component class, or to fields or methods of the
|
|
38 |
* component class. When the annotation is applied to a
|
|
39 |
* field or method, the container will inject an instance
|
|
40 |
* of the requested resource into the application component
|
|
41 |
* when the component is initialized. If the annotation is
|
|
42 |
* applied to the component class, the annotation declares a
|
|
43 |
* resource that the application will look up at runtime. <p>
|
|
44 |
*
|
|
45 |
* Even though this annotation is not marked Inherited, deployment
|
|
46 |
* tools are required to examine all superclasses of any component
|
|
47 |
* class to discover all uses of this annotation in all superclasses.
|
|
48 |
* All such annotation instances specify resources that are needed
|
|
49 |
* by the application component. Note that this annotation may
|
|
50 |
* appear on private fields and methods of superclasses; the container
|
|
51 |
* is required to perform injection in these cases as well.
|
|
52 |
*
|
|
53 |
* @since Common Annotations 1.0
|
|
54 |
*/
|
|
55 |
@Target({TYPE, FIELD, METHOD})
|
|
56 |
@Retention(RUNTIME)
|
|
57 |
public @interface Resource {
|
|
58 |
/**
|
|
59 |
* The JNDI name of the resource. For field annotations,
|
|
60 |
* the default is the field name. For method annotations,
|
|
61 |
* the default is the JavaBeans property name corresponding
|
|
62 |
* to the method. For class annotations, there is no default
|
|
63 |
* and this must be specified.
|
|
64 |
*/
|
|
65 |
String name() default "";
|
|
66 |
|
|
67 |
/**
|
|
68 |
* The Java type of the resource. For field annotations,
|
|
69 |
* the default is the type of the field. For method annotations,
|
|
70 |
* the default is the type of the JavaBeans property.
|
|
71 |
* For class annotations, there is no default and this must be
|
|
72 |
* specified.
|
|
73 |
*/
|
|
74 |
Class type() default java.lang.Object.class;
|
|
75 |
|
|
76 |
/**
|
|
77 |
* The two possible authentication types for a resource.
|
|
78 |
*/
|
|
79 |
enum AuthenticationType {
|
|
80 |
CONTAINER,
|
|
81 |
APPLICATION
|
|
82 |
}
|
|
83 |
|
|
84 |
/**
|
|
85 |
* The authentication type to use for this resource.
|
|
86 |
* This may be specified for resources representing a
|
|
87 |
* connection factory of any supported type, and must
|
|
88 |
* not be specified for resources of other types.
|
|
89 |
*/
|
|
90 |
AuthenticationType authenticationType() default AuthenticationType.CONTAINER;
|
|
91 |
|
|
92 |
/**
|
|
93 |
* Indicates whether this resource can be shared between
|
|
94 |
* this component and other components.
|
|
95 |
* This may be specified for resources representing a
|
|
96 |
* connection factory of any supported type, and must
|
|
97 |
* not be specified for resources of other types.
|
|
98 |
*/
|
|
99 |
boolean shareable() default true;
|
|
100 |
|
|
101 |
/**
|
|
102 |
* A product specific name that this resource should be mapped to.
|
|
103 |
* The name of this resource, as defined by the <code>name</code>
|
|
104 |
* element or defaulted, is a name that is local to the application
|
|
105 |
* component using the resource. (It's a name in the JNDI
|
|
106 |
* <code>java:comp/env</code> namespace.) Many application servers
|
|
107 |
* provide a way to map these local names to names of resources
|
|
108 |
* known to the application server. This mapped name is often a
|
|
109 |
* <i>global</i> JNDI name, but may be a name of any form. <p>
|
|
110 |
*
|
|
111 |
* Application servers are not required to support any particular
|
|
112 |
* form or type of mapped name, nor the ability to use mapped names.
|
|
113 |
* The mapped name is product-dependent and often installation-dependent.
|
|
114 |
* No use of a mapped name is portable.
|
|
115 |
*/
|
|
116 |
String mappedName() default "";
|
|
117 |
|
|
118 |
/**
|
|
119 |
* Description of this resource. The description is expected
|
|
120 |
* to be in the default language of the system on which the
|
|
121 |
* application is deployed. The description can be presented
|
|
122 |
* to the Deployer to help in choosing the correct resource.
|
|
123 |
*/
|
|
124 |
String description() default "";
|
|
125 |
}
|