Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxws/src/share/jaxws_classes/javax/annotation/Resource.java
38877 views
/*1* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.annotation;2627import java.lang.annotation.*;28import static java.lang.annotation.ElementType.*;29import static java.lang.annotation.RetentionPolicy.*;3031/**32* The Resource annotation marks a resource that is needed33* by the application. This annotation may be applied to an34* application component class, or to fields or methods of the35* component class. When the annotation is applied to a36* field or method, the container will inject an instance37* of the requested resource into the application component38* when the component is initialized. If the annotation is39* applied to the component class, the annotation declares a40* resource that the application will look up at runtime. <p>41*42* Even though this annotation is not marked Inherited, deployment43* tools are required to examine all superclasses of any component44* class to discover all uses of this annotation in all superclasses.45* All such annotation instances specify resources that are needed46* by the application component. Note that this annotation may47* appear on private fields and methods of superclasses; the container48* is required to perform injection in these cases as well.49*50* @since Common Annotations 1.051*/52@Target({TYPE, FIELD, METHOD})53@Retention(RUNTIME)54public @interface Resource {55/**56* The JNDI name of the resource. For field annotations,57* the default is the field name. For method annotations,58* the default is the JavaBeans property name corresponding59* to the method. For class annotations, there is no default60* and this must be specified.61*/62String name() default "";6364/**65* The name of the resource that the reference points to. It can66* link to any compatible resource using the global JNDI names.67*68* @since Common Annotations 1.169*/7071String lookup() default "";7273/**74* The Java type of the resource. For field annotations,75* the default is the type of the field. For method annotations,76* the default is the type of the JavaBeans property.77* For class annotations, there is no default and this must be78* specified.79*/80Class<?> type() default java.lang.Object.class;8182/**83* The two possible authentication types for a resource.84*/85enum AuthenticationType {86CONTAINER,87APPLICATION88}8990/**91* The authentication type to use for this resource.92* This may be specified for resources representing a93* connection factory of any supported type, and must94* not be specified for resources of other types.95*/96AuthenticationType authenticationType() default AuthenticationType.CONTAINER;9798/**99* Indicates whether this resource can be shared between100* this component and other components.101* This may be specified for resources representing a102* connection factory of any supported type, and must103* not be specified for resources of other types.104*/105boolean shareable() default true;106107/**108* A product specific name that this resource should be mapped to.109* The name of this resource, as defined by the <code>name</code>110* element or defaulted, is a name that is local to the application111* component using the resource. (It's a name in the JNDI112* <code>java:comp/env</code> namespace.) Many application servers113* provide a way to map these local names to names of resources114* known to the application server. This mapped name is often a115* <i>global</i> JNDI name, but may be a name of any form. <p>116*117* Application servers are not required to support any particular118* form or type of mapped name, nor the ability to use mapped names.119* The mapped name is product-dependent and often installation-dependent.120* No use of a mapped name is portable.121*/122String mappedName() default "";123124/**125* Description of this resource. The description is expected126* to be in the default language of the system on which the127* application is deployed. The description can be presented128* to the Deployer to help in choosing the correct resource.129*/130String description() default "";131}132133134