2362N/A * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * <p>Meta-annotation that describes how an annotation element relates 0N/A * to a field in a {@link Descriptor}. This can be the Descriptor for 0N/A * an MBean, or for an attribute, operation, or constructor in an 0N/A * MBean, or for a parameter of an operation or constructor.</p> 0N/A * <p>Consider this annotation for example:</p> 0N/A * @Target(ElementType.METHOD) 0N/A * @Retention(RetentionPolicy.RUNTIME) 0N/A * public @interface Units { 0N/A * <b>@DescriptorKey("units")</b> 0N/A * <p>and this use of the annotation:</p> 0N/A * public interface CacheControlMBean { 0N/A * <b>@Units("bytes")</b> 0N/A * public long getCacheSize(); 0N/A * <p>When a Standard MBean is made from the {@code CacheControlMBean}, 0N/A * the usual rules mean that it will have an attribute called 0N/A * {@code CacheSize} of type {@code long}. The {@code @Units} 406N/A * annotation, given the above definition, will ensure that the 0N/A * {@link MBeanAttributeInfo} for this attribute will have a 0N/A * {@code Descriptor} that has a field called {@code units} with 0N/A * corresponding value {@code bytes}.</p> 0N/A * <p>Similarly, if the annotation looks like this:</p> 0N/A * @Target(ElementType.METHOD) 0N/A * @Retention(RetentionPolicy.RUNTIME) 0N/A * public @interface Units { 0N/A * <b>@DescriptorKey("units")</b> 0N/A * <b>@DescriptorKey("descriptionResourceKey")</b> 0N/A * String resourceKey() default ""; 0N/A * <b>@DescriptorKey("descriptionResourceBundleBaseName")</b> 0N/A * String resourceBundleBaseName() default ""; 0N/A * <p>and it is used like this:</p> 0N/A * public interface CacheControlMBean { 0N/A * <b>@Units("bytes", 0N/A * resourceKey="bytes.key", 0N/A * resourceBundleBaseName="com.example.foo.MBeanResources")</b> 0N/A * public long getCacheSize(); 0N/A * <p>then the resulting {@code Descriptor} will contain the following 0N/A * <table border="2"> 0N/A * <tr><th>Name</th><th>Value</th></tr> 0N/A * <tr><td>units</td><td>"bytes"</td></tr> 0N/A * <tr><td>descriptionResourceKey</td><td>"bytes.key"</td></tr> 0N/A * <tr><td>descriptionResourceBundleBaseName</td> 0N/A * <td>"com.example.foo.MBeanResources"</td></tr> 0N/A * <p>An annotation such as {@code @Units} can be applied to:</p> 0N/A * <li>a Standard MBean or MXBean interface; 0N/A * <li>a method in such an interface; 0N/A * <li>a parameter of a method in a Standard MBean or MXBean interface 0N/A * when that method is an operation (not a getter or setter for an attribute); 0N/A * <li>a public constructor in the class that implements a Standard MBean 0N/A * <li>a parameter in such a constructor. 0N/A * <p>Other uses of the annotation are ignored.</p> 0N/A * <p>Interface annotations are checked only on the exact interface 0N/A * that defines the management interface of a Standard MBean or an 0N/A * MXBean, not on its parent interfaces. Method annotations are 0N/A * checked only in the most specific interface in which the method 0N/A * appears; in other words, if a child interface overrides a method 0N/A * from a parent interface, only {@code @DescriptorKey} annotations in 0N/A * the method in the child interface are considered. 0N/A * <p>The Descriptor fields contributed in this way by different 1790N/A * annotations on the same program element must be consistent. That 1790N/A * is, two different annotations, or two members of the same 1790N/A * annotation, must not define a different value for the same 1790N/A * Descriptor field. Fields from annotations on a getter method must 1790N/A * also be consistent with fields from annotations on the 1790N/A * corresponding setter method.</p> 0N/A * <p>The Descriptor resulting from these annotations will be merged 0N/A * with any Descriptor fields provided by the implementation, such as 0N/A * immutableInfo}</a> field for an MBean. The fields from the annotations 0N/A * must be consistent with these fields provided by the implementation.</p> 0N/A * <p>An annotation element to be converted into a descriptor field 0N/A * can be of any type allowed by the Java language, except an annotation 0N/A * or an array of annotations. The value of the field is derived from 0N/A * the value of the annotation element as follows:</p> 0N/A * <table border="2"> 0N/A * <tr><th>Annotation element</th><th>Descriptor field</th></tr> 0N/A * <tr><td>Primitive value ({@code 5}, {@code false}, etc)</td> 0N/A * <td>Wrapped value ({@code Integer.valueOf(5)}, 0N/A * {@code Boolean.FALSE}, etc)</td></tr> 0N/A * <tr><td>Class constant (e.g. {@code Thread.class})</td> 0N/A * <td>Class name from {@link Class#getName()} 0N/A * (e.g. {@code "java.lang.Thread"})</td></tr> 0N/A * <tr><td>Enum constant (e.g. {@link ElementType#FIELD})</td> 0N/A * <td>Constant name from {@link Enum#name()} 0N/A * (e.g. {@code "FIELD"})</td></tr> 0N/A * <tr><td>Array of class constants or enum constants</td> 0N/A * <td>String array derived by applying these rules to each 0N/A * <tr><td>Value of any other type<br> 0N/A * ({@code String}, {@code String[]}, {@code int[]}, etc)</td> 0N/A * <td>The same value</td></tr>