Source Code Cross Referenced for DescriptorKey.java in  » 6.0-JDK-Core » management » javax » management » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » management » javax.management 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package javax.management;
027
028        import java.lang.annotation.*;
029
030        /**
031         * <p>Meta-annotation that describes how an annotation element relates
032         * to a field in a {@link Descriptor}.  This can be the Descriptor for
033         * an MBean, or for an attribute, operation, or constructor in an
034         * MBean, or for a parameter of an operation or constructor.</p>
035         *
036         * <p>Consider this annotation for example:</p>
037         *
038         * <pre>
039         * &#64;Documented
040         * &#64;Target(ElementType.METHOD)
041         * &#64;Retention(RetentionPolicy.RUNTIME)
042         * public &#64;interface Units {
043         *     <b>&#64;DescriptorKey("units")</b>
044         *     String value();
045         * }
046         * </pre>
047         *
048         * <p>and this use of the annotation:</p>
049         *
050         * <pre>
051         * public interface CacheControlMBean {
052         *     <b>&#64;Units("bytes")</b>
053         *     public long getCacheSize();
054         * }
055         * </pre>
056         *
057         * <p>When a Standard MBean is made from the {@code CacheControlMBean},
058         * the usual rules mean that it will have an attribute called
059         * {@code CacheSize} of type {@code long}.  The {@code @Units}
060         * attribute, given the above definition, will ensure that the
061         * {@link MBeanAttributeInfo} for this attribute will have a
062         * {@code Descriptor} that has a field called {@code units} with
063         * corresponding value {@code bytes}.</p>
064         *
065         * <p>Similarly, if the annotation looks like this:</p>
066         *
067         * <pre>
068         * &#64;Documented
069         * &#64;Target(ElementType.METHOD)
070         * &#64;Retention(RetentionPolicy.RUNTIME)
071         * public &#64;interface Units {
072         *     <b>&#64;DescriptorKey("units")</b>
073         *     String value();
074         *
075         *     <b>&#64;DescriptorKey("descriptionResourceKey")</b>
076         *     String resourceKey() default "";
077         *
078         *     <b>&#64;DescriptorKey("descriptionResourceBundleBaseName")</b>
079         *     String resourceBundleBaseName() default "";
080         * }
081         * </pre>
082         *
083         * <p>and it is used like this:</p>
084         *
085         * <pre>
086         * public interface CacheControlMBean {
087         *     <b>&#64;Units("bytes",
088         *            resourceKey="bytes.key",
089         *            resourceBundleBaseName="com.example.foo.MBeanResources")</b>
090         *     public long getCacheSize();
091         * }
092         * </pre>
093         *
094         * <p>then the resulting {@code Descriptor} will contain the following
095         * fields:</p>
096         *
097         * <table border="2">
098         * <tr><th>Name</th><th>Value</th></tr>
099         * <tr><td>units</td><td>"bytes"</td></tr>
100         * <tr><td>descriptionResourceKey</td><td>"bytes.key"</td></tr>
101         * <tr><td>descriptionResourceBundleBaseName</td>
102         *     <td>"com.example.foo.MBeanResources"</td></tr>
103         * </table>
104         *
105         * <p>An annotation such as {@code @Units} can be applied to:</p>
106         *
107         * <ul>
108         * <li>a Standard MBean or MXBean interface;
109         * <li>a method in such an interface;
110         * <li>a parameter of a method in a Standard MBean or MXBean interface
111         * when that method is an operation (not a getter or setter for an attribute);
112         * <li>a public constructor in the class that implements a Standard MBean
113         * or MXBean;
114         * <li>a parameter in such a constructor.
115         * </ul>
116         *
117         * <p>Other uses of the annotation are ignored.</p>
118         *
119         * <p>Interface annotations are checked only on the exact interface
120         * that defines the management interface of a Standard MBean or an
121         * MXBean, not on its parent interfaces.  Method annotations are
122         * checked only in the most specific interface in which the method
123         * appears; in other words, if a child interface overrides a method
124         * from a parent interface, only {@code @DescriptorKey} annotations in
125         * the method in the child interface are considered.
126         *
127         * <p>The Descriptor fields contributed in this way by different
128         * annotations on the same program element must be consistent.  That
129         * is, two different annotations, or two members of the same
130         * annotation, must not define a different value for the same
131         * Descriptor field.  Fields from annotations on a getter method must
132         * also be consistent with fields from annotations on the
133         * corresponding setter method.</p>
134         *
135         * <p>The Descriptor resulting from these annotations will be merged
136         * with any Descriptor fields provided by the implementation, such as
137         * the <a href="Descriptor.html#immutableInfo">{@code
138         * immutableInfo}</a> field for an MBean.  The fields from the annotations
139         * must be consistent with these fields provided by the implementation.</p>
140         *
141         * <p>An annotation element to be converted into a descriptor field
142         * can be of any type allowed by the Java language, except an annotation
143         * or an array of annotations.  The value of the field is derived from
144         * the value of the annotation element as follows:</p>
145         *
146         * <table border="2">
147         * <tr><th>Annotation element</th><th>Descriptor field</th></tr>
148         * <tr><td>Primitive value ({@code 5}, {@code false}, etc)</td>
149         *     <td>Wrapped value ({@code Integer.valueOf(5)},
150         *         {@code Boolean.FALSE}, etc)</td></tr>
151         * <tr><td>Class constant (e.g. {@code Thread.class})</td>
152         *     <td>Class name from {@link Class#getName()}
153         *         (e.g. {@code "java.lang.Thread"})</td></tr>
154         * <tr><td>Enum constant (e.g. {@link ElementType#FIELD})</td>
155         *     <td>Constant name from {@link Enum#name()}
156         *         (e.g. {@code "FIELD"})</td></tr>
157         * <tr><td>Array of class constants or enum constants</td>
158         *     <td>String array derived by applying these rules to each
159         *         element</td></tr>
160         * <tr><td>Value of any other type<br>
161         *         ({@code String}, {@code String[]}, {@code int[]}, etc)</td>
162         *     <td>The same value</td></tr>
163         * </table>
164         *
165         * @since 1.6
166         */
167        @Documented
168        @Retention(RetentionPolicy.RUNTIME)
169        @Target(ElementType.METHOD)
170        public @interface DescriptorKey {
171            String value();
172        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.