aoqi@0: /* aoqi@0: * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package javax.annotation; aoqi@0: aoqi@0: import java.lang.annotation.*; aoqi@0: import static java.lang.annotation.ElementType.*; aoqi@0: import static java.lang.annotation.RetentionPolicy.*; aoqi@0: aoqi@0: /** aoqi@0: * The Resource annotation marks a resource that is needed aoqi@0: * by the application. This annotation may be applied to an aoqi@0: * application component class, or to fields or methods of the aoqi@0: * component class. When the annotation is applied to a aoqi@0: * field or method, the container will inject an instance aoqi@0: * of the requested resource into the application component aoqi@0: * when the component is initialized. If the annotation is aoqi@0: * applied to the component class, the annotation declares a aoqi@0: * resource that the application will look up at runtime.
aoqi@0: *
aoqi@0: * Even though this annotation is not marked Inherited, deployment
aoqi@0: * tools are required to examine all superclasses of any component
aoqi@0: * class to discover all uses of this annotation in all superclasses.
aoqi@0: * All such annotation instances specify resources that are needed
aoqi@0: * by the application component. Note that this annotation may
aoqi@0: * appear on private fields and methods of superclasses; the container
aoqi@0: * is required to perform injection in these cases as well.
aoqi@0: *
aoqi@0: * @since Common Annotations 1.0
aoqi@0: */
aoqi@0: @Target({TYPE, FIELD, METHOD})
aoqi@0: @Retention(RUNTIME)
aoqi@0: public @interface Resource {
aoqi@0: /**
aoqi@0: * The JNDI name of the resource. For field annotations,
aoqi@0: * the default is the field name. For method annotations,
aoqi@0: * the default is the JavaBeans property name corresponding
aoqi@0: * to the method. For class annotations, there is no default
aoqi@0: * and this must be specified.
aoqi@0: */
aoqi@0: String name() default "";
aoqi@0:
aoqi@0: /**
aoqi@0: * The name of the resource that the reference points to. It can
aoqi@0: * link to any compatible resource using the global JNDI names.
aoqi@0: *
aoqi@0: * @since Common Annotations 1.1
aoqi@0: */
aoqi@0:
aoqi@0: String lookup() default "";
aoqi@0:
aoqi@0: /**
aoqi@0: * The Java type of the resource. For field annotations,
aoqi@0: * the default is the type of the field. For method annotations,
aoqi@0: * the default is the type of the JavaBeans property.
aoqi@0: * For class annotations, there is no default and this must be
aoqi@0: * specified.
aoqi@0: */
aoqi@0: Class> type() default java.lang.Object.class;
aoqi@0:
aoqi@0: /**
aoqi@0: * The two possible authentication types for a resource.
aoqi@0: */
aoqi@0: enum AuthenticationType {
aoqi@0: CONTAINER,
aoqi@0: APPLICATION
aoqi@0: }
aoqi@0:
aoqi@0: /**
aoqi@0: * The authentication type to use for this resource.
aoqi@0: * This may be specified for resources representing a
aoqi@0: * connection factory of any supported type, and must
aoqi@0: * not be specified for resources of other types.
aoqi@0: */
aoqi@0: AuthenticationType authenticationType() default AuthenticationType.CONTAINER;
aoqi@0:
aoqi@0: /**
aoqi@0: * Indicates whether this resource can be shared between
aoqi@0: * this component and other components.
aoqi@0: * This may be specified for resources representing a
aoqi@0: * connection factory of any supported type, and must
aoqi@0: * not be specified for resources of other types.
aoqi@0: */
aoqi@0: boolean shareable() default true;
aoqi@0:
aoqi@0: /**
aoqi@0: * A product specific name that this resource should be mapped to.
aoqi@0: * The name of this resource, as defined by the name
aoqi@0: * element or defaulted, is a name that is local to the application
aoqi@0: * component using the resource. (It's a name in the JNDI
aoqi@0: * java:comp/env
namespace.) Many application servers
aoqi@0: * provide a way to map these local names to names of resources
aoqi@0: * known to the application server. This mapped name is often a
aoqi@0: * global JNDI name, but may be a name of any form.
aoqi@0: * aoqi@0: * Application servers are not required to support any particular aoqi@0: * form or type of mapped name, nor the ability to use mapped names. aoqi@0: * The mapped name is product-dependent and often installation-dependent. aoqi@0: * No use of a mapped name is portable. aoqi@0: */ aoqi@0: String mappedName() default ""; aoqi@0: aoqi@0: /** aoqi@0: * Description of this resource. The description is expected aoqi@0: * to be in the default language of the system on which the aoqi@0: * application is deployed. The description can be presented aoqi@0: * to the Deployer to help in choosing the correct resource. aoqi@0: */ aoqi@0: String description() default ""; aoqi@0: }