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