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