jdk/src/java.management/share/classes/javax/management/DescriptorKey.java
author darcy
Thu, 16 Apr 2015 09:51:29 -0700
changeset 29927 9cc3e111a1d8
parent 25859 3317bb8137f4
child 44858 7183899b064b
permissions -rw-r--r--
8077923: Add missing doclint in javax.management Reviewed-by: dfuchs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
29927
9cc3e111a1d8 8077923: Add missing doclint in javax.management
darcy
parents: 25859
diff changeset
     2
 * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.management;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.lang.annotation.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * <p>Meta-annotation that describes how an annotation element relates
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * to a field in a {@link Descriptor}.  This can be the Descriptor for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * an MBean, or for an attribute, operation, or constructor in an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * MBean, or for a parameter of an operation or constructor.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * <p>Consider this annotation for example:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * &#64;Documented
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * &#64;Target(ElementType.METHOD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * &#64;Retention(RetentionPolicy.RUNTIME)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * public &#64;interface Units {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *     <b>&#64;DescriptorKey("units")</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *     String value();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * <p>and this use of the annotation:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * public interface CacheControlMBean {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *     <b>&#64;Units("bytes")</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *     public long getCacheSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * <p>When a Standard MBean is made from the {@code CacheControlMBean},
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * the usual rules mean that it will have an attribute called
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * {@code CacheSize} of type {@code long}.  The {@code @Units}
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 2
diff changeset
    60
 * annotation, given the above definition, will ensure that the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * {@link MBeanAttributeInfo} for this attribute will have a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * {@code Descriptor} that has a field called {@code units} with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * corresponding value {@code bytes}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * <p>Similarly, if the annotation looks like this:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * &#64;Documented
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * &#64;Target(ElementType.METHOD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * &#64;Retention(RetentionPolicy.RUNTIME)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * public &#64;interface Units {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *     <b>&#64;DescriptorKey("units")</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *     String value();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *     <b>&#64;DescriptorKey("descriptionResourceKey")</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *     String resourceKey() default "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *     <b>&#64;DescriptorKey("descriptionResourceBundleBaseName")</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 *     String resourceBundleBaseName() default "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * <p>and it is used like this:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * public interface CacheControlMBean {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 *     <b>&#64;Units("bytes",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 *            resourceKey="bytes.key",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 *            resourceBundleBaseName="com.example.foo.MBeanResources")</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 *     public long getCacheSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * <p>then the resulting {@code Descriptor} will contain the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * fields:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 *
21656
d4c777ccb1db 8028014: Doclint warning/error cleanup in javax.management
rriggs
parents: 5506
diff changeset
    97
 * <table border="2" summary="Descriptor Fields">
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * <tr><th>Name</th><th>Value</th></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * <tr><td>units</td><td>"bytes"</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * <tr><td>descriptionResourceKey</td><td>"bytes.key"</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * <tr><td>descriptionResourceBundleBaseName</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 *     <td>"com.example.foo.MBeanResources"</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * <p>An annotation such as {@code @Units} can be applied to:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * <li>a Standard MBean or MXBean interface;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * <li>a method in such an interface;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * <li>a parameter of a method in a Standard MBean or MXBean interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * when that method is an operation (not a getter or setter for an attribute);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * <li>a public constructor in the class that implements a Standard MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * or MXBean;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 * <li>a parameter in such a constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * <p>Other uses of the annotation are ignored.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 * <p>Interface annotations are checked only on the exact interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 * that defines the management interface of a Standard MBean or an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 * MXBean, not on its parent interfaces.  Method annotations are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 * checked only in the most specific interface in which the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 * appears; in other words, if a child interface overrides a method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 * from a parent interface, only {@code @DescriptorKey} annotations in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 * the method in the child interface are considered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 * <p>The Descriptor fields contributed in this way by different
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1247
diff changeset
   128
 * annotations on the same program element must be consistent.  That
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1247
diff changeset
   129
 * is, two different annotations, or two members of the same
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1247
diff changeset
   130
 * annotation, must not define a different value for the same
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1247
diff changeset
   131
 * Descriptor field.  Fields from annotations on a getter method must
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1247
diff changeset
   132
 * also be consistent with fields from annotations on the
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1247
diff changeset
   133
 * corresponding setter method.</p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 * <p>The Descriptor resulting from these annotations will be merged
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 * with any Descriptor fields provided by the implementation, such as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 * the <a href="Descriptor.html#immutableInfo">{@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
 * immutableInfo}</a> field for an MBean.  The fields from the annotations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
 * must be consistent with these fields provided by the implementation.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
 * <p>An annotation element to be converted into a descriptor field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
 * can be of any type allowed by the Java language, except an annotation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
 * or an array of annotations.  The value of the field is derived from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 * the value of the annotation element as follows:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
 *
21656
d4c777ccb1db 8028014: Doclint warning/error cleanup in javax.management
rriggs
parents: 5506
diff changeset
   146
 * <table border="2" summary="Descriptor Field Types">
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
 * <tr><th>Annotation element</th><th>Descriptor field</th></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
 * <tr><td>Primitive value ({@code 5}, {@code false}, etc)</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
 *     <td>Wrapped value ({@code Integer.valueOf(5)},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
 *         {@code Boolean.FALSE}, etc)</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
 * <tr><td>Class constant (e.g. {@code Thread.class})</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
 *     <td>Class name from {@link Class#getName()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
 *         (e.g. {@code "java.lang.Thread"})</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
 * <tr><td>Enum constant (e.g. {@link ElementType#FIELD})</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
 *     <td>Constant name from {@link Enum#name()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 *         (e.g. {@code "FIELD"})</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 * <tr><td>Array of class constants or enum constants</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 *     <td>String array derived by applying these rules to each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 *         element</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
 * <tr><td>Value of any other type<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 *         ({@code String}, {@code String[]}, {@code int[]}, etc)</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 *     <td>The same value</td></tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
 * </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
 * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
@Documented
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
@Retention(RetentionPolicy.RUNTIME)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
@Target(ElementType.METHOD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
public @interface DescriptorKey {
29927
9cc3e111a1d8 8077923: Add missing doclint in javax.management
darcy
parents: 25859
diff changeset
   171
    /**
9cc3e111a1d8 8077923: Add missing doclint in javax.management
darcy
parents: 25859
diff changeset
   172
     * Returns the descriptor key.
9cc3e111a1d8 8077923: Add missing doclint in javax.management
darcy
parents: 25859
diff changeset
   173
     * @return the descriptor key
9cc3e111a1d8 8077923: Add missing doclint in javax.management
darcy
parents: 25859
diff changeset
   174
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    String value();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
}