author | mkos |
Sun, 30 Dec 2012 00:00:00 +0100 | |
changeset 22678 | ac1ea46be942 |
parent 12009 | 4abb694f273a |
permissions | -rw-r--r-- |
12009 | 1 |
/* |
22678
ac1ea46be942
8029237: Update copyright year to match last edit in jaxws repository for 2012
mkos
parents:
12009
diff
changeset
|
2 |
* Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. |
12009 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
||
27 |
||
28 |
package com.sun.org.glassfish.gmbal; |
|
29 |
||
30 |
import java.lang.annotation.Documented; |
|
31 |
import java.lang.annotation.ElementType; |
|
32 |
import java.lang.annotation.Inherited; |
|
33 |
import java.lang.annotation.Retention; |
|
34 |
import java.lang.annotation.RetentionPolicy; |
|
35 |
import java.lang.annotation.Target; |
|
36 |
||
37 |
/** This is taken directly from JDK 7 in order to support this feature in |
|
38 |
* JDK 5. |
|
39 |
* |
|
40 |
* <p>Annotation that adds fields to a Descriptor. This can be the |
|
41 |
* Descriptor for an MBean, or for an attribute, operation, or constructor |
|
42 |
* in an MBean, or for a parameter of an operation or constructor.</p> |
|
43 |
* |
|
44 |
* <p>Consider this Standard MBean interface, for example:</p> |
|
45 |
* |
|
46 |
* <pre> |
|
47 |
* public interface CacheControlMBean { |
|
48 |
* <b>@DescriptorFields("units=bytes")</b> |
|
49 |
* public long getCacheSize(); |
|
50 |
* } |
|
51 |
* </pre> |
|
52 |
* |
|
53 |
* <p>When a Standard MBean is made using this interface, the usual rules |
|
54 |
* mean that it will have an attribute called {@code CacheSize} of type |
|
55 |
* {@code long}. The {@code DescriptorFields} annotation will ensure |
|
56 |
* that the MBeanAttributeInfo for this attribute will have a |
|
57 |
* {@code Descriptor} that has a field called {@code units} with |
|
58 |
* corresponding value {@code bytes}.</p> |
|
59 |
* |
|
60 |
* <p>Similarly, if the interface looks like this:</p> |
|
61 |
* |
|
62 |
* <pre> |
|
63 |
* public interface CacheControlMBean { |
|
64 |
* <b>@DescriptorFields({"units=bytes", "since=1.5"})</b> |
|
65 |
* public long getCacheSize(); |
|
66 |
* } |
|
67 |
* </pre> |
|
68 |
* |
|
69 |
* <p>then the resulting {@code Descriptor} will contain the following |
|
70 |
* fields:</p> |
|
71 |
* |
|
72 |
* <table border="2"> |
|
73 |
* <tr><th>Name</th><th>Value</th></tr> |
|
74 |
* <tr><td>units</td><td>"bytes"</td></tr> |
|
75 |
* <tr><td>since</td><td>"1.5"</td></tr> |
|
76 |
* </table> |
|
77 |
* |
|
78 |
* <p>The {@code @DescriptorFields} annotation can be applied to:</p> |
|
79 |
* |
|
80 |
* <ul> |
|
81 |
* <li>a Standard MBean or MXBean interface; |
|
82 |
* <li>a method in such an interface; |
|
83 |
* <li>a parameter of a method in a Standard MBean or MXBean interface |
|
84 |
* when that method is an operation (not a getter or setter for an attribute); |
|
85 |
* <li>a public constructor in the class that implements a Standard MBean |
|
86 |
* or MXBean; |
|
87 |
* <li>a parameter in such a constructor. |
|
88 |
* </ul> |
|
89 |
* |
|
90 |
* <p>Other uses of the annotation will either fail to compile or be |
|
91 |
* ignored.</p> |
|
92 |
* |
|
93 |
* <p>Interface annotations are checked only on the exact interface |
|
94 |
* that defines the management interface of a Standard MBean or an |
|
95 |
* MXBean, not on its parent interfaces. Method annotations are |
|
96 |
* checked only in the most specific interface in which the method |
|
97 |
* appears; in other words, if a child interface overrides a method |
|
98 |
* from a parent interface, only {@code @DescriptorFields} annotations in |
|
99 |
* the method in the child interface are considered. |
|
100 |
* |
|
101 |
* <p>The Descriptor fields contributed in this way must be consistent |
|
102 |
* with each other and with any fields contributed by |
|
103 |
* DescriptorKey annotations. That is, two |
|
104 |
* different annotations, or two members of the same annotation, must |
|
105 |
* not define a different value for the same Descriptor field. Fields |
|
106 |
* from annotations on a getter method must also be consistent with |
|
107 |
* fields from annotations on the corresponding setter method.</p> |
|
108 |
* |
|
109 |
* <p>The Descriptor resulting from these annotations will be merged |
|
110 |
* with any Descriptor fields provided by the implementation, such as |
|
111 |
* the <a href="Descriptor.html#immutableInfo">{@code |
|
112 |
* immutableInfo}</a> field for an MBean. The fields from the annotations |
|
113 |
* must be consistent with these fields provided by the implementation.</p> |
|
114 |
* |
|
115 |
* <h4>{@literal @DescriptorFields and @DescriptorKey}</h4> |
|
116 |
* |
|
117 |
* <p>The DescriptorKey annotation provides |
|
118 |
* another way to use annotations to define Descriptor fields. |
|
119 |
* <code>@DescriptorKey</code> requires more work but is also more |
|
120 |
* robust, because there is less risk of mistakes such as misspelling |
|
121 |
* the name of the field or giving an invalid value. |
|
122 |
* <code>@DescriptorFields</code> is more convenient but includes |
|
123 |
* those risks. <code>@DescriptorFields</code> is more |
|
124 |
* appropriate for occasional use, but for a Descriptor field that you |
|
125 |
* add in many places, you should consider a purpose-built annotation |
|
126 |
* using <code>@DescriptorKey</code>. |
|
127 |
* |
|
128 |
* @since 1.7 |
|
129 |
*/ |
|
130 |
@Documented |
|
131 |
@Inherited // for @MBean and @MXBean classes |
|
132 |
@Target({ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.FIELD, |
|
133 |
ElementType.PARAMETER, ElementType.TYPE}) |
|
134 |
@Retention(RetentionPolicy.RUNTIME) |
|
135 |
public @interface DescriptorFields { |
|
136 |
/** |
|
137 |
* <p>The descriptor fields. Each element of the string looks like |
|
138 |
* {@code "name=value"}.</p> |
|
139 |
*/ |
|
140 |
public String[] value(); |
|
141 |
} |