src/share/jaxws_classes/javax/annotation/Resource.java

changeset 286
f50545b5e2f1
child 368
0989ad8c0860
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/jaxws_classes/javax/annotation/Resource.java	Tue Mar 06 16:09:35 2012 -0800
     1.3 @@ -0,0 +1,132 @@
     1.4 +/*
     1.5 + * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package javax.annotation;
    1.30 +
    1.31 +import java.lang.annotation.*;
    1.32 +import static java.lang.annotation.ElementType.*;
    1.33 +import static java.lang.annotation.RetentionPolicy.*;
    1.34 +
    1.35 +/**
    1.36 + * The Resource annotation marks a resource that is needed
    1.37 + * by the application.  This annotation may be applied to an
    1.38 + * application component class, or to fields or methods of the
    1.39 + * component class.  When the annotation is applied to a
    1.40 + * field or method, the container will inject an instance
    1.41 + * of the requested resource into the application component
    1.42 + * when the component is initialized.  If the annotation is
    1.43 + * applied to the component class, the annotation declares a
    1.44 + * resource that the application will look up at runtime. <p>
    1.45 + *
    1.46 + * Even though this annotation is not marked Inherited, deployment
    1.47 + * tools are required to examine all superclasses of any component
    1.48 + * class to discover all uses of this annotation in all superclasses.
    1.49 + * All such annotation instances specify resources that are needed
    1.50 + * by the application component.  Note that this annotation may
    1.51 + * appear on private fields and methods of superclasses; the container
    1.52 + * is required to perform injection in these cases as well.
    1.53 + *
    1.54 + * @since Common Annotations 1.0
    1.55 + */
    1.56 +@Target({TYPE, FIELD, METHOD})
    1.57 +@Retention(RUNTIME)
    1.58 +public @interface Resource {
    1.59 +    /**
    1.60 +     * The JNDI name of the resource.  For field annotations,
    1.61 +     * the default is the field name.  For method annotations,
    1.62 +     * the default is the JavaBeans property name corresponding
    1.63 +     * to the method.  For class annotations, there is no default
    1.64 +     * and this must be specified.
    1.65 +     */
    1.66 +    String name() default "";
    1.67 +
    1.68 +    /**
    1.69 +     * The name of the resource that the reference points to. It can
    1.70 +     * link to any compatible resource using the global JNDI names.
    1.71 +     *
    1.72 +     * @since Common Annotations 1.1
    1.73 +     */
    1.74 +
    1.75 +    String lookup() default "";
    1.76 +
    1.77 +    /**
    1.78 +     * The Java type of the resource.  For field annotations,
    1.79 +     * the default is the type of the field.  For method annotations,
    1.80 +     * the default is the type of the JavaBeans property.
    1.81 +     * For class annotations, there is no default and this must be
    1.82 +     * specified.
    1.83 +     */
    1.84 +    Class type() default java.lang.Object.class;
    1.85 +
    1.86 +    /**
    1.87 +     * The two possible authentication types for a resource.
    1.88 +     */
    1.89 +    enum AuthenticationType {
    1.90 +            CONTAINER,
    1.91 +            APPLICATION
    1.92 +    }
    1.93 +
    1.94 +    /**
    1.95 +     * The authentication type to use for this resource.
    1.96 +     * This may be specified for resources representing a
    1.97 +     * connection factory of any supported type, and must
    1.98 +     * not be specified for resources of other types.
    1.99 +     */
   1.100 +    AuthenticationType authenticationType() default AuthenticationType.CONTAINER;
   1.101 +
   1.102 +    /**
   1.103 +     * Indicates whether this resource can be shared between
   1.104 +     * this component and other components.
   1.105 +     * This may be specified for resources representing a
   1.106 +     * connection factory of any supported type, and must
   1.107 +     * not be specified for resources of other types.
   1.108 +     */
   1.109 +    boolean shareable() default true;
   1.110 +
   1.111 +    /**
   1.112 +     * A product specific name that this resource should be mapped to.
   1.113 +     * The name of this resource, as defined by the <code>name</code>
   1.114 +     * element or defaulted, is a name that is local to the application
   1.115 +     * component using the resource.  (It's a name in the JNDI
   1.116 +     * <code>java:comp/env</code> namespace.)  Many application servers
   1.117 +     * provide a way to map these local names to names of resources
   1.118 +     * known to the application server.  This mapped name is often a
   1.119 +     * <i>global</i> JNDI name, but may be a name of any form. <p>
   1.120 +     *
   1.121 +     * Application servers are not required to support any particular
   1.122 +     * form or type of mapped name, nor the ability to use mapped names.
   1.123 +     * The mapped name is product-dependent and often installation-dependent.
   1.124 +     * No use of a mapped name is portable.
   1.125 +     */
   1.126 +    String mappedName() default "";
   1.127 +
   1.128 +    /**
   1.129 +     * Description of this resource.  The description is expected
   1.130 +     * to be in the default language of the system on which the
   1.131 +     * application is deployed.  The description can be presented
   1.132 +     * to the Deployer to help in choosing the correct resource.
   1.133 +     */
   1.134 +    String description() default "";
   1.135 +}

mercurial