author | emcmanus |
Wed, 09 Jul 2008 10:36:07 +0200 | |
changeset 833 | bfa2bef7517c |
parent 687 | 874e25a9844a |
child 834 | dc74d4ddc28e |
permissions | -rw-r--r-- |
2 | 1 |
/* |
2 |
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. |
|
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. Sun designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 |
* have any questions. |
|
24 |
*/ |
|
25 |
||
26 |
package com.sun.jmx.mbeanserver; |
|
27 |
||
28 |
||
29 |
import static com.sun.jmx.mbeanserver.Util.*; |
|
30 |
||
31 |
import java.lang.ref.WeakReference; |
|
32 |
import java.lang.reflect.Array; |
|
33 |
import java.lang.reflect.Constructor; |
|
34 |
import java.lang.reflect.InvocationTargetException; |
|
35 |
import java.lang.reflect.Method; |
|
36 |
import java.lang.reflect.Type; |
|
287 | 37 |
import java.util.Arrays; |
2 | 38 |
import java.util.List; |
833
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
39 |
import java.util.Map; |
2 | 40 |
import java.util.WeakHashMap; |
833
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
41 |
import javax.management.Description; |
2 | 42 |
|
43 |
import javax.management.Descriptor; |
|
44 |
import javax.management.ImmutableDescriptor; |
|
687 | 45 |
import javax.management.IntrospectionException; |
2 | 46 |
import javax.management.InvalidAttributeValueException; |
833
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
47 |
import javax.management.MBean; |
2 | 48 |
import javax.management.MBeanAttributeInfo; |
49 |
import javax.management.MBeanConstructorInfo; |
|
50 |
import javax.management.MBeanException; |
|
51 |
import javax.management.MBeanInfo; |
|
52 |
import javax.management.MBeanNotificationInfo; |
|
53 |
import javax.management.MBeanOperationInfo; |
|
833
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
54 |
import javax.management.MXBean; |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
55 |
import javax.management.ManagedAttribute; |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
56 |
import javax.management.ManagedOperation; |
2 | 57 |
import javax.management.NotCompliantMBeanException; |
58 |
import javax.management.NotificationBroadcaster; |
|
833
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
59 |
import javax.management.NotificationInfo; |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
60 |
import javax.management.NotificationInfos; |
2 | 61 |
import javax.management.ReflectionException; |
62 |
||
63 |
/** |
|
64 |
* An introspector for MBeans of a certain type. There is one instance |
|
687 | 65 |
* of this class for Standard MBeans, and one for every MXBeanMappingFactory; |
66 |
* these two cases correspond to the two concrete subclasses of this abstract |
|
67 |
* class. |
|
2 | 68 |
* |
69 |
* @param <M> the representation of methods for this kind of MBean: |
|
70 |
* Method for Standard MBeans, ConvertingMethod for MXBeans. |
|
71 |
* |
|
72 |
* @since 1.6 |
|
73 |
*/ |
|
74 |
/* |
|
75 |
* Using a type parameter <M> allows us to deal with the fact that |
|
76 |
* Method and ConvertingMethod have no useful common ancestor, on |
|
77 |
* which we could call getName, getGenericReturnType, etc. A simpler approach |
|
78 |
* would be to wrap every Method in an object that does have a common |
|
79 |
* ancestor with ConvertingMethod. But that would mean an extra object |
|
80 |
* for every Method in every Standard MBean interface. |
|
81 |
*/ |
|
82 |
abstract class MBeanIntrospector<M> { |
|
83 |
static final class PerInterfaceMap<M> |
|
84 |
extends WeakHashMap<Class<?>, WeakReference<PerInterface<M>>> {} |
|
85 |
||
86 |
/** The map from interface to PerInterface for this type of MBean. */ |
|
87 |
abstract PerInterfaceMap<M> getPerInterfaceMap(); |
|
88 |
/** |
|
89 |
* The map from concrete implementation class and interface to |
|
90 |
* MBeanInfo for this type of MBean. |
|
91 |
*/ |
|
92 |
abstract MBeanInfoMap getMBeanInfoMap(); |
|
93 |
||
94 |
/** Make an interface analyzer for this type of MBean. */ |
|
95 |
abstract MBeanAnalyzer<M> getAnalyzer(Class<?> mbeanInterface) |
|
96 |
throws NotCompliantMBeanException; |
|
97 |
||
98 |
/** True if MBeans with this kind of introspector are MXBeans. */ |
|
99 |
abstract boolean isMXBean(); |
|
100 |
||
101 |
/** Find the M corresponding to the given Method. */ |
|
102 |
abstract M mFrom(Method m); |
|
103 |
||
104 |
/** Get the name of this method. */ |
|
105 |
abstract String getName(M m); |
|
106 |
||
107 |
/** |
|
108 |
* Get the return type of this method. This is the return type |
|
109 |
* of a method in a Java interface, so for MXBeans it is the |
|
110 |
* declared Java type, not the mapped Open Type. |
|
111 |
*/ |
|
112 |
abstract Type getGenericReturnType(M m); |
|
113 |
||
114 |
/** |
|
115 |
* Get the parameter types of this method in the Java interface |
|
116 |
* it came from. |
|
117 |
*/ |
|
118 |
abstract Type[] getGenericParameterTypes(M m); |
|
119 |
||
120 |
/** |
|
121 |
* Get the signature of this method as a caller would have to supply |
|
122 |
* it in MBeanServer.invoke. For MXBeans, the named types will be |
|
123 |
* the mapped Open Types for the parameters. |
|
124 |
*/ |
|
125 |
abstract String[] getSignature(M m); |
|
126 |
||
127 |
/** |
|
128 |
* Check that this method is valid. For example, a method in an |
|
129 |
* MXBean interface is not valid if one of its parameters cannot be |
|
130 |
* mapped to an Open Type. |
|
131 |
*/ |
|
687 | 132 |
abstract void checkMethod(M m); |
2 | 133 |
|
134 |
/** |
|
135 |
* Invoke the method with the given target and arguments. |
|
136 |
* |
|
137 |
* @param cookie Additional information about the target. For an |
|
138 |
* MXBean, this is the MXBeanLookup associated with the MXBean. |
|
139 |
*/ |
|
140 |
/* |
|
141 |
* It would be cleaner if the type of the cookie were a |
|
142 |
* type parameter to this class, but that would involve a lot of |
|
143 |
* messy type parameter propagation just to avoid a couple of casts. |
|
144 |
*/ |
|
145 |
abstract Object invokeM2(M m, Object target, Object[] args, Object cookie) |
|
146 |
throws InvocationTargetException, IllegalAccessException, |
|
147 |
MBeanException; |
|
148 |
||
149 |
/** |
|
150 |
* Test whether the given value is valid for the given parameter of this |
|
151 |
* M. |
|
152 |
*/ |
|
153 |
abstract boolean validParameter(M m, Object value, int paramNo, |
|
154 |
Object cookie); |
|
155 |
||
156 |
/** |
|
157 |
* Construct an MBeanAttributeInfo for the given attribute based on the |
|
158 |
* given getter and setter. One but not both of the getter and setter |
|
159 |
* may be null. |
|
160 |
*/ |
|
161 |
abstract MBeanAttributeInfo getMBeanAttributeInfo(String attributeName, |
|
687 | 162 |
M getter, M setter) throws IntrospectionException; |
163 |
||
833
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
164 |
final String getAttributeDescription( |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
165 |
String attributeName, String defaultDescription, |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
166 |
Method getter, Method setter) throws IntrospectionException { |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
167 |
String g = Introspector.descriptionForElement(getter); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
168 |
String s = Introspector.descriptionForElement(setter); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
169 |
if (g == null) { |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
170 |
if (s == null) |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
171 |
return defaultDescription; |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
172 |
else |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
173 |
return s; |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
174 |
} else if (s == null || g.equals(s)) { |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
175 |
return g; |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
176 |
} else { |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
177 |
throw new IntrospectionException( |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
178 |
"Inconsistent @Description on getter and setter for " + |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
179 |
"attribute " + attributeName); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
180 |
} |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
181 |
} |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
182 |
|
2 | 183 |
/** |
184 |
* Construct an MBeanOperationInfo for the given operation based on |
|
185 |
* the M it was derived from. |
|
186 |
*/ |
|
187 |
abstract MBeanOperationInfo getMBeanOperationInfo(String operationName, |
|
188 |
M operation); |
|
189 |
||
190 |
/** |
|
191 |
* Get a Descriptor containing fields that MBeans of this kind will |
|
192 |
* always have. For example, MXBeans will always have "mxbean=true". |
|
193 |
*/ |
|
194 |
abstract Descriptor getBasicMBeanDescriptor(); |
|
195 |
||
196 |
/** |
|
197 |
* Get a Descriptor containing additional fields beyond the ones |
|
198 |
* from getBasicMBeanDescriptor that MBeans whose concrete class |
|
199 |
* is resourceClass will always have. |
|
200 |
*/ |
|
201 |
abstract Descriptor getMBeanDescriptor(Class<?> resourceClass); |
|
202 |
||
687 | 203 |
/** |
204 |
* Get any additional Descriptor entries for this introspector instance. |
|
205 |
* If there is a non-default MXBeanMappingFactory, it will appear in |
|
206 |
* this Descriptor. |
|
207 |
* @return Additional Descriptor entries, or an empty Descriptor if none. |
|
208 |
*/ |
|
209 |
Descriptor getSpecificMBeanDescriptor() { |
|
210 |
return ImmutableDescriptor.EMPTY_DESCRIPTOR; |
|
211 |
} |
|
212 |
||
287 | 213 |
void checkCompliance(Class<?> mbeanType) throws NotCompliantMBeanException { |
833
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
214 |
if (!mbeanType.isInterface() && |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
215 |
!mbeanType.isAnnotationPresent(MBean.class) && |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
216 |
!Introspector.hasMXBeanAnnotation(mbeanType)) { |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
217 |
throw new NotCompliantMBeanException("Not an interface and " + |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
218 |
"does not have @" + MBean.class.getSimpleName() + |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
219 |
" or @" + MXBean.class.getSimpleName() + " annotation: " + |
287 | 220 |
mbeanType.getName()); |
221 |
} |
|
222 |
} |
|
223 |
||
224 |
/** |
|
225 |
* Get the methods to be analyzed to build the MBean interface. |
|
226 |
*/ |
|
227 |
List<Method> getMethods(final Class<?> mbeanType) throws Exception { |
|
833
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
228 |
if (mbeanType.isInterface()) |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
229 |
return Arrays.asList(mbeanType.getMethods()); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
230 |
|
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
231 |
final List<Method> methods = newList(); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
232 |
getAnnotatedMethods(mbeanType, methods); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
233 |
return methods; |
287 | 234 |
} |
2 | 235 |
|
236 |
final PerInterface<M> getPerInterface(Class<?> mbeanInterface) |
|
237 |
throws NotCompliantMBeanException { |
|
238 |
PerInterfaceMap<M> map = getPerInterfaceMap(); |
|
239 |
synchronized (map) { |
|
240 |
WeakReference<PerInterface<M>> wr = map.get(mbeanInterface); |
|
241 |
PerInterface<M> pi = (wr == null) ? null : wr.get(); |
|
242 |
if (pi == null) { |
|
243 |
try { |
|
244 |
MBeanAnalyzer<M> analyzer = getAnalyzer(mbeanInterface); |
|
245 |
MBeanInfo mbeanInfo = |
|
246 |
makeInterfaceMBeanInfo(mbeanInterface, analyzer); |
|
247 |
pi = new PerInterface<M>(mbeanInterface, this, analyzer, |
|
248 |
mbeanInfo); |
|
249 |
wr = new WeakReference<PerInterface<M>>(pi); |
|
250 |
map.put(mbeanInterface, wr); |
|
251 |
} catch (Exception x) { |
|
252 |
throw Introspector.throwException(mbeanInterface,x); |
|
253 |
} |
|
254 |
} |
|
255 |
return pi; |
|
256 |
} |
|
257 |
} |
|
258 |
||
259 |
/** |
|
260 |
* Make the MBeanInfo skeleton for the given MBean interface using |
|
261 |
* the given analyzer. This will never be the MBeanInfo of any real |
|
262 |
* MBean (because the getClassName() must be a concrete class), but |
|
263 |
* its MBeanAttributeInfo[] and MBeanOperationInfo[] can be inserted |
|
264 |
* into such an MBeanInfo, and its Descriptor can be the basis for |
|
265 |
* the MBeanInfo's Descriptor. |
|
266 |
*/ |
|
267 |
private MBeanInfo makeInterfaceMBeanInfo(Class<?> mbeanInterface, |
|
687 | 268 |
MBeanAnalyzer<M> analyzer) throws IntrospectionException { |
2 | 269 |
final MBeanInfoMaker maker = new MBeanInfoMaker(); |
270 |
analyzer.visit(maker); |
|
833
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
271 |
final String defaultDescription = |
2 | 272 |
"Information on the management interface of the MBean"; |
833
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
273 |
String description = Introspector.descriptionForElement(mbeanInterface); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
274 |
if (description == null) |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
275 |
description = defaultDescription; |
2 | 276 |
return maker.makeMBeanInfo(mbeanInterface, description); |
277 |
} |
|
278 |
||
279 |
/** True if the given getter and setter are consistent. */ |
|
280 |
final boolean consistent(M getter, M setter) { |
|
281 |
return (getter == null || setter == null || |
|
282 |
getGenericReturnType(getter).equals(getGenericParameterTypes(setter)[0])); |
|
283 |
} |
|
284 |
||
285 |
/** |
|
286 |
* Invoke the given M on the given target with the given args and cookie. |
|
287 |
* Wrap exceptions appropriately. |
|
288 |
*/ |
|
289 |
final Object invokeM(M m, Object target, Object[] args, Object cookie) |
|
290 |
throws MBeanException, ReflectionException { |
|
291 |
try { |
|
292 |
return invokeM2(m, target, args, cookie); |
|
293 |
} catch (InvocationTargetException e) { |
|
294 |
unwrapInvocationTargetException(e); |
|
295 |
throw new RuntimeException(e); // not reached |
|
296 |
} catch (IllegalAccessException e) { |
|
297 |
throw new ReflectionException(e, e.toString()); |
|
298 |
} |
|
299 |
/* We do not catch and wrap RuntimeException or Error, |
|
300 |
* because we're in a DynamicMBean, so the logic for DynamicMBeans |
|
301 |
* will do the wrapping. |
|
302 |
*/ |
|
303 |
} |
|
304 |
||
305 |
/** |
|
306 |
* Invoke the given setter on the given target with the given argument |
|
307 |
* and cookie. Wrap exceptions appropriately. |
|
308 |
*/ |
|
309 |
/* If the value is of the wrong type for the method we are about to |
|
310 |
* invoke, we are supposed to throw an InvalidAttributeValueException. |
|
311 |
* Rather than making the check always, we invoke the method, then |
|
312 |
* if it throws an exception we check the type to see if that was |
|
313 |
* what caused the exception. The assumption is that an exception |
|
314 |
* from an invalid type will arise before any user method is ever |
|
315 |
* called (either in reflection or in OpenConverter). |
|
316 |
*/ |
|
317 |
final void invokeSetter(String name, M setter, Object target, Object arg, |
|
318 |
Object cookie) |
|
319 |
throws MBeanException, ReflectionException, |
|
320 |
InvalidAttributeValueException { |
|
321 |
try { |
|
322 |
invokeM2(setter, target, new Object[] {arg}, cookie); |
|
323 |
} catch (IllegalAccessException e) { |
|
324 |
throw new ReflectionException(e, e.toString()); |
|
325 |
} catch (RuntimeException e) { |
|
326 |
maybeInvalidParameter(name, setter, arg, cookie); |
|
327 |
throw e; |
|
328 |
} catch (InvocationTargetException e) { |
|
329 |
maybeInvalidParameter(name, setter, arg, cookie); |
|
330 |
unwrapInvocationTargetException(e); |
|
331 |
} |
|
332 |
} |
|
333 |
||
334 |
private void maybeInvalidParameter(String name, M setter, Object arg, |
|
335 |
Object cookie) |
|
336 |
throws InvalidAttributeValueException { |
|
337 |
if (!validParameter(setter, arg, 0, cookie)) { |
|
338 |
final String msg = |
|
339 |
"Invalid value for attribute " + name + ": " + arg; |
|
340 |
throw new InvalidAttributeValueException(msg); |
|
341 |
} |
|
342 |
} |
|
343 |
||
344 |
static boolean isValidParameter(Method m, Object value, int paramNo) { |
|
345 |
Class<?> c = m.getParameterTypes()[paramNo]; |
|
346 |
try { |
|
347 |
// Following is expensive but we only call this method to determine |
|
348 |
// if an exception is due to an incompatible parameter type. |
|
349 |
// Plain old c.isInstance doesn't work for primitive types. |
|
350 |
Object a = Array.newInstance(c, 1); |
|
351 |
Array.set(a, 0, value); |
|
352 |
return true; |
|
353 |
} catch (IllegalArgumentException e) { |
|
354 |
return false; |
|
355 |
} |
|
356 |
} |
|
357 |
||
358 |
private static void |
|
359 |
unwrapInvocationTargetException(InvocationTargetException e) |
|
360 |
throws MBeanException { |
|
361 |
Throwable t = e.getCause(); |
|
362 |
if (t instanceof RuntimeException) |
|
363 |
throw (RuntimeException) t; |
|
364 |
else if (t instanceof Error) |
|
365 |
throw (Error) t; |
|
366 |
else |
|
367 |
throw new MBeanException((Exception) t, |
|
368 |
(t == null ? null : t.toString())); |
|
369 |
} |
|
370 |
||
371 |
/** A visitor that constructs the per-interface MBeanInfo. */ |
|
687 | 372 |
private class MBeanInfoMaker |
373 |
implements MBeanAnalyzer.MBeanVisitor<M, IntrospectionException> { |
|
2 | 374 |
|
375 |
public void visitAttribute(String attributeName, |
|
376 |
M getter, |
|
687 | 377 |
M setter) throws IntrospectionException { |
2 | 378 |
MBeanAttributeInfo mbai = |
379 |
getMBeanAttributeInfo(attributeName, getter, setter); |
|
380 |
||
381 |
attrs.add(mbai); |
|
382 |
} |
|
383 |
||
384 |
public void visitOperation(String operationName, |
|
385 |
M operation) { |
|
386 |
MBeanOperationInfo mboi = |
|
387 |
getMBeanOperationInfo(operationName, operation); |
|
388 |
||
389 |
ops.add(mboi); |
|
390 |
} |
|
391 |
||
392 |
/** Make an MBeanInfo based on the attributes and operations |
|
393 |
* found in the interface. */ |
|
394 |
MBeanInfo makeMBeanInfo(Class<?> mbeanInterface, |
|
395 |
String description) { |
|
396 |
final MBeanAttributeInfo[] attrArray = |
|
397 |
attrs.toArray(new MBeanAttributeInfo[0]); |
|
398 |
final MBeanOperationInfo[] opArray = |
|
399 |
ops.toArray(new MBeanOperationInfo[0]); |
|
400 |
final String interfaceClassName = |
|
401 |
"interfaceClassName=" + mbeanInterface.getName(); |
|
687 | 402 |
final Descriptor classNameDescriptor = |
2 | 403 |
new ImmutableDescriptor(interfaceClassName); |
404 |
final Descriptor mbeanDescriptor = getBasicMBeanDescriptor(); |
|
405 |
final Descriptor annotatedDescriptor = |
|
406 |
Introspector.descriptorForElement(mbeanInterface); |
|
407 |
final Descriptor descriptor = |
|
687 | 408 |
DescriptorCache.getInstance().union( |
409 |
classNameDescriptor, |
|
2 | 410 |
mbeanDescriptor, |
411 |
annotatedDescriptor); |
|
412 |
||
413 |
return new MBeanInfo(mbeanInterface.getName(), |
|
414 |
description, |
|
415 |
attrArray, |
|
416 |
null, |
|
417 |
opArray, |
|
418 |
null, |
|
419 |
descriptor); |
|
420 |
} |
|
421 |
||
422 |
private final List<MBeanAttributeInfo> attrs = newList(); |
|
423 |
private final List<MBeanOperationInfo> ops = newList(); |
|
424 |
} |
|
425 |
||
426 |
/* |
|
427 |
* Looking up the MBeanInfo for a given base class (implementation class) |
|
428 |
* is complicated by the fact that we may use the same base class with |
|
429 |
* several different explicit MBean interfaces via the |
|
430 |
* javax.management.StandardMBean class. It is further complicated |
|
431 |
* by the fact that we have to be careful not to retain a strong reference |
|
432 |
* to any Class object for fear we would prevent a ClassLoader from being |
|
433 |
* garbage-collected. So we have a first lookup from the base class |
|
434 |
* to a map for each interface that base class might specify giving |
|
435 |
* the MBeanInfo constructed for that base class and interface. |
|
436 |
*/ |
|
437 |
static class MBeanInfoMap |
|
438 |
extends WeakHashMap<Class<?>, WeakHashMap<Class<?>, MBeanInfo>> { |
|
439 |
} |
|
440 |
||
441 |
/** |
|
442 |
* Return the MBeanInfo for the given resource, based on the given |
|
443 |
* per-interface data. |
|
444 |
*/ |
|
687 | 445 |
final MBeanInfo getMBeanInfo(Object resource, PerInterface<M> perInterface) |
446 |
throws NotCompliantMBeanException { |
|
2 | 447 |
MBeanInfo mbi = |
448 |
getClassMBeanInfo(resource.getClass(), perInterface); |
|
833
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
449 |
MBeanNotificationInfo[] notifs; |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
450 |
try { |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
451 |
notifs = findNotifications(resource); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
452 |
} catch (RuntimeException e) { |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
453 |
NotCompliantMBeanException x = |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
454 |
new NotCompliantMBeanException(e.getMessage()); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
455 |
x.initCause(e); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
456 |
throw x; |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
457 |
} |
687 | 458 |
Descriptor d = getSpecificMBeanDescriptor(); |
459 |
boolean anyNotifs = (notifs != null && notifs.length > 0); |
|
460 |
if (!anyNotifs && ImmutableDescriptor.EMPTY_DESCRIPTOR.equals(d)) |
|
2 | 461 |
return mbi; |
462 |
else { |
|
687 | 463 |
d = ImmutableDescriptor.union(d, mbi.getDescriptor()); |
2 | 464 |
return new MBeanInfo(mbi.getClassName(), |
465 |
mbi.getDescription(), |
|
466 |
mbi.getAttributes(), |
|
467 |
mbi.getConstructors(), |
|
468 |
mbi.getOperations(), |
|
469 |
notifs, |
|
687 | 470 |
d); |
2 | 471 |
} |
472 |
} |
|
473 |
||
474 |
/** |
|
475 |
* Return the basic MBeanInfo for resources of the given class and |
|
476 |
* per-interface data. This MBeanInfo might not be the final MBeanInfo |
|
477 |
* for instances of the class, because if the class is a |
|
478 |
* NotificationBroadcaster then each instance gets to decide what |
|
479 |
* MBeanNotificationInfo[] to put in its own MBeanInfo. |
|
480 |
*/ |
|
481 |
final MBeanInfo getClassMBeanInfo(Class<?> resourceClass, |
|
482 |
PerInterface<M> perInterface) { |
|
483 |
MBeanInfoMap map = getMBeanInfoMap(); |
|
484 |
synchronized (map) { |
|
485 |
WeakHashMap<Class<?>, MBeanInfo> intfMap = map.get(resourceClass); |
|
486 |
if (intfMap == null) { |
|
487 |
intfMap = new WeakHashMap<Class<?>, MBeanInfo>(); |
|
488 |
map.put(resourceClass, intfMap); |
|
489 |
} |
|
490 |
Class<?> intfClass = perInterface.getMBeanInterface(); |
|
491 |
MBeanInfo mbi = intfMap.get(intfClass); |
|
492 |
if (mbi == null) { |
|
493 |
MBeanInfo imbi = perInterface.getMBeanInfo(); |
|
494 |
Descriptor descriptor = |
|
495 |
ImmutableDescriptor.union(imbi.getDescriptor(), |
|
496 |
getMBeanDescriptor(resourceClass)); |
|
497 |
mbi = new MBeanInfo(resourceClass.getName(), |
|
498 |
imbi.getDescription(), |
|
499 |
imbi.getAttributes(), |
|
500 |
findConstructors(resourceClass), |
|
501 |
imbi.getOperations(), |
|
502 |
(MBeanNotificationInfo[]) null, |
|
503 |
descriptor); |
|
504 |
intfMap.put(intfClass, mbi); |
|
505 |
} |
|
506 |
return mbi; |
|
507 |
} |
|
508 |
} |
|
509 |
||
833
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
510 |
/* |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
511 |
* Add to "methods" every public method that has the @ManagedAttribute |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
512 |
* or @ManagedOperation annotation, in the given class or any of |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
513 |
* its superclasses or superinterfaces. |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
514 |
* |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
515 |
* We always add superclass or superinterface methods first, so that |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
516 |
* the stable sort used by eliminateCovariantMethods will put the |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
517 |
* method from the most-derived class last. This means that we will |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
518 |
* see the version of the @ManagedAttribute (or ...Operation) annotation |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
519 |
* from that method, which might have a different description or whatever. |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
520 |
*/ |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
521 |
private static void getAnnotatedMethods(Class<?> c, List<Method> methods) |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
522 |
throws Exception { |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
523 |
Class<?> sup = c.getSuperclass(); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
524 |
if (sup != null) |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
525 |
getAnnotatedMethods(sup, methods); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
526 |
Class<?>[] intfs = c.getInterfaces(); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
527 |
for (Class<?> intf : intfs) |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
528 |
getAnnotatedMethods(intf, methods); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
529 |
for (Method m : c.getMethods()) { |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
530 |
// We are careful not to add m if it is inherited from a parent |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
531 |
// class or interface, because duplicate methods lead to nasty |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
532 |
// behaviour in eliminateCovariantMethods. |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
533 |
if (m.getDeclaringClass() == c && |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
534 |
(m.isAnnotationPresent(ManagedAttribute.class) || |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
535 |
m.isAnnotationPresent(ManagedOperation.class))) |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
536 |
methods.add(m); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
537 |
} |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
538 |
} |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
539 |
|
2 | 540 |
static MBeanNotificationInfo[] findNotifications(Object moi) { |
541 |
if (!(moi instanceof NotificationBroadcaster)) |
|
542 |
return null; |
|
543 |
MBeanNotificationInfo[] mbn = |
|
544 |
((NotificationBroadcaster) moi).getNotificationInfo(); |
|
687 | 545 |
if (mbn == null || mbn.length == 0) |
833
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
546 |
return findNotificationsFromAnnotations(moi.getClass()); |
2 | 547 |
MBeanNotificationInfo[] result = |
548 |
new MBeanNotificationInfo[mbn.length]; |
|
549 |
for (int i = 0; i < mbn.length; i++) { |
|
550 |
MBeanNotificationInfo ni = mbn[i]; |
|
551 |
if (ni.getClass() != MBeanNotificationInfo.class) |
|
552 |
ni = (MBeanNotificationInfo) ni.clone(); |
|
553 |
result[i] = ni; |
|
554 |
} |
|
555 |
return result; |
|
556 |
} |
|
557 |
||
833
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
558 |
private static MBeanNotificationInfo[] findNotificationsFromAnnotations( |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
559 |
Class<?> mbeanClass) { |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
560 |
Class<?> c = getAnnotatedNotificationInfoClass(mbeanClass); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
561 |
if (c == null) |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
562 |
return null; |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
563 |
NotificationInfo ni = c.getAnnotation(NotificationInfo.class); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
564 |
NotificationInfos nis = c.getAnnotation(NotificationInfos.class); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
565 |
List<NotificationInfo> list = newList(); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
566 |
if (ni != null) |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
567 |
list.add(ni); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
568 |
if (nis != null) |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
569 |
list.addAll(Arrays.asList(nis.value())); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
570 |
if (list.isEmpty()) |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
571 |
return null; |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
572 |
List<MBeanNotificationInfo> mbnis = newList(); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
573 |
for (NotificationInfo x : list) { |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
574 |
// The Descriptor includes any fields explicitly specified by |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
575 |
// x.descriptorFields(), plus any fields from the contained |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
576 |
// @Description annotation. |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
577 |
Descriptor d = new ImmutableDescriptor(x.descriptorFields()); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
578 |
d = ImmutableDescriptor.union( |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
579 |
d, Introspector.descriptorForAnnotation(x.description())); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
580 |
MBeanNotificationInfo mbni = new MBeanNotificationInfo( |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
581 |
x.types(), x.notificationClass().getName(), |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
582 |
x.description().value(), d); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
583 |
mbnis.add(mbni); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
584 |
} |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
585 |
return mbnis.toArray(new MBeanNotificationInfo[mbnis.size()]); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
586 |
} |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
587 |
|
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
588 |
private static final Map<Class<?>, WeakReference<Class<?>>> |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
589 |
annotatedNotificationInfoClasses = newWeakHashMap(); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
590 |
|
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
591 |
private static Class<?> getAnnotatedNotificationInfoClass(Class<?> baseClass) { |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
592 |
synchronized (annotatedNotificationInfoClasses) { |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
593 |
WeakReference<Class<?>> wr = |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
594 |
annotatedNotificationInfoClasses.get(baseClass); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
595 |
if (wr != null) |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
596 |
return wr.get(); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
597 |
Class<?> c = null; |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
598 |
if (baseClass.isAnnotationPresent(NotificationInfo.class) || |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
599 |
baseClass.isAnnotationPresent(NotificationInfos.class)) { |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
600 |
c = baseClass; |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
601 |
} else { |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
602 |
Class<?>[] intfs = baseClass.getInterfaces(); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
603 |
for (Class<?> intf : intfs) { |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
604 |
Class<?> c1 = getAnnotatedNotificationInfoClass(intf); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
605 |
if (c1 != null) { |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
606 |
if (c != null) { |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
607 |
throw new IllegalArgumentException( |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
608 |
"Class " + baseClass.getName() + " inherits " + |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
609 |
"@NotificationInfo(s) from both " + |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
610 |
c.getName() + " and " + c1.getName()); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
611 |
} |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
612 |
c = c1; |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
613 |
} |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
614 |
} |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
615 |
} |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
616 |
// Record the result of the search. If no @NotificationInfo(s) |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
617 |
// were found, c is null, and we store a WeakReference(null). |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
618 |
// This prevents us from having to search again and fail again. |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
619 |
annotatedNotificationInfoClasses.put(baseClass, |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
620 |
new WeakReference<Class<?>>(c)); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
621 |
return c; |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
622 |
} |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
623 |
} |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
624 |
|
2 | 625 |
private static MBeanConstructorInfo[] findConstructors(Class<?> c) { |
626 |
Constructor[] cons = c.getConstructors(); |
|
627 |
MBeanConstructorInfo[] mbc = new MBeanConstructorInfo[cons.length]; |
|
628 |
for (int i = 0; i < cons.length; i++) { |
|
833
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
629 |
String descr = "Public constructor of the MBean"; |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
630 |
Description d = cons[i].getAnnotation(Description.class); |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
631 |
if (d != null) |
bfa2bef7517c
6323980: Annotations to simplify MBean development
emcmanus
parents:
687
diff
changeset
|
632 |
descr = d.value(); |
2 | 633 |
mbc[i] = new MBeanConstructorInfo(descr, cons[i]); |
634 |
} |
|
635 |
return mbc; |
|
636 |
} |
|
637 |
||
638 |
} |