src/java.management/share/classes/javax/management/DescriptorKey.java
author darcy
Wed, 23 Oct 2019 13:01:40 -0700
changeset 58766 54ffb15c4839
parent 47216 71c04702a3d5
permissions -rw-r--r--
8232442: Suppress warnings on non-serializable non-transient instance fields in java.management.* Reviewed-by: rriggs, mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
44858
7183899b064b 8179415: Update java.management and java.management.rmi to be HTML-5 friendly
ksrini
parents: 29927
diff changeset
     2
 * Copyright (c) 2005, 2017, 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
 *
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
    97
 * <table class="striped">
44858
7183899b064b 8179415: Update java.management and java.management.rmi to be HTML-5 friendly
ksrini
parents: 29927
diff changeset
    98
 * <caption style="display:none">Descriptor Fields</caption>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
    99
 * <thead>
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   100
 * <tr><th scope="col">Name</th><th scope="col">Value</th></tr>
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   101
 * </thead>
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   102
 * <tbody style="text-align:left">
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   103
 * <tr><th scope="row">units</th><td>"bytes"</td></tr>
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   104
 * <tr><th scope="row">descriptionResourceKey</th><td>"bytes.key"</td></tr>
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   105
 * <tr><th scope="row">descriptionResourceBundleBaseName</th>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 *     <td>"com.example.foo.MBeanResources"</td></tr>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   107
 * </tbody>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * <p>An annotation such as {@code @Units} can be applied to:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * <li>a Standard MBean or MXBean interface;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 * <li>a method in such an interface;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 * <li>a parameter of a method in a Standard MBean or MXBean interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 * when that method is an operation (not a getter or setter for an attribute);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * <li>a public constructor in the class that implements a Standard MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 * or MXBean;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 * <li>a parameter in such a constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 * <p>Other uses of the annotation are ignored.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 * <p>Interface annotations are checked only on the exact interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 * that defines the management interface of a Standard MBean or an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 * MXBean, not on its parent interfaces.  Method annotations are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 * checked only in the most specific interface in which the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 * appears; in other words, if a child interface overrides a method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 * from a parent interface, only {@code @DescriptorKey} annotations in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 * the method in the child interface are considered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 * <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
   133
 * 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
   134
 * 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
   135
 * 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
   136
 * 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
   137
 * 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
   138
 * corresponding setter method.</p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
 * <p>The Descriptor resulting from these annotations will be merged
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
 * with any Descriptor fields provided by the implementation, such as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
 * the <a href="Descriptor.html#immutableInfo">{@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
 * immutableInfo}</a> field for an MBean.  The fields from the annotations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 * must be consistent with these fields provided by the implementation.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
 * <p>An annotation element to be converted into a descriptor field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
 * can be of any type allowed by the Java language, except an annotation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
 * or an array of annotations.  The value of the field is derived from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
 * the value of the annotation element as follows:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
 *
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   151
 * <table class="striped">
44858
7183899b064b 8179415: Update java.management and java.management.rmi to be HTML-5 friendly
ksrini
parents: 29927
diff changeset
   152
 * <caption style="display:none">Descriptor Field Types</caption>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   153
 * <thead>
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   154
 * <tr><th scope="col">Annotation element</th><th scope="col">Descriptor field</th></tr>
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   155
 * </thead>
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   156
 * <tbody style="text-align:left">
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   157
 * <tr><th scope="row">Primitive value ({@code 5}, {@code false}, etc)</th>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 *     <td>Wrapped value ({@code Integer.valueOf(5)},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 *         {@code Boolean.FALSE}, etc)</td></tr>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   160
 * <tr><th scope="row">Class constant (e.g. {@code Thread.class})</th>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 *     <td>Class name from {@link Class#getName()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 *         (e.g. {@code "java.lang.Thread"})</td></tr>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   163
 * <tr><th scope="row">Enum constant (e.g. {@link ElementType#FIELD})</th>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
 *     <td>Constant name from {@link Enum#name()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
 *         (e.g. {@code "FIELD"})</td></tr>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   166
 * <tr><th scope="row">Array of class constants or enum constants</th>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
 *     <td>String array derived by applying these rules to each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
 *         element</td></tr>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   169
 * <tr><th scope="row">Value of any other type<br>
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   170
 *         ({@code String}, {@code String[]}, {@code int[]}, etc)</th>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
 *     <td>The same value</td></tr>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 44858
diff changeset
   172
 * </tbody>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
 * </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
 * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
@Documented
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
@Retention(RetentionPolicy.RUNTIME)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
@Target(ElementType.METHOD)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
public @interface DescriptorKey {
29927
9cc3e111a1d8 8077923: Add missing doclint in javax.management
darcy
parents: 25859
diff changeset
   181
    /**
9cc3e111a1d8 8077923: Add missing doclint in javax.management
darcy
parents: 25859
diff changeset
   182
     * Returns the descriptor key.
9cc3e111a1d8 8077923: Add missing doclint in javax.management
darcy
parents: 25859
diff changeset
   183
     * @return the descriptor key
9cc3e111a1d8 8077923: Add missing doclint in javax.management
darcy
parents: 25859
diff changeset
   184
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    String value();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
}