1
1
/*
2
- * Copyright 2002-2012 the original author or authors.
2
+ * Copyright 2002-2014 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
22
22
import java .util .Hashtable ;
23
23
import java .util .List ;
24
24
import javax .management .DynamicMBean ;
25
+ import javax .management .JMX ;
25
26
import javax .management .MBeanParameterInfo ;
26
27
import javax .management .MBeanServer ;
27
28
import javax .management .MBeanServerFactory ;
28
- import javax .management .MXBean ;
29
29
import javax .management .MalformedObjectNameException ;
30
30
import javax .management .ObjectName ;
31
31
@@ -59,16 +59,6 @@ public abstract class JmxUtils {
59
59
*/
60
60
private static final String MBEAN_SUFFIX = "MBean" ;
61
61
62
- /**
63
- * Suffix used to identify a Java 6 MXBean interface.
64
- */
65
- private static final String MXBEAN_SUFFIX = "MXBean" ;
66
-
67
- private static final String MXBEAN_ANNOTATION_CLASS_NAME = "javax.management.MXBean" ;
68
-
69
-
70
- private static final boolean mxBeanAnnotationAvailable =
71
- ClassUtils .isPresent (MXBEAN_ANNOTATION_CLASS_NAME , JmxUtils .class .getClassLoader ());
72
62
73
63
private static final Log logger = LogFactory .getLog (JmxUtils .class );
74
64
@@ -304,14 +294,7 @@ public static Class<?> getMXBeanInterface(Class<?> clazz) {
304
294
}
305
295
Class <?>[] implementedInterfaces = clazz .getInterfaces ();
306
296
for (Class <?> iface : implementedInterfaces ) {
307
- boolean isMxBean = iface .getName ().endsWith (MXBEAN_SUFFIX );
308
- if (mxBeanAnnotationAvailable ) {
309
- Boolean checkResult = MXBeanChecker .evaluateMXBeanAnnotation (iface );
310
- if (checkResult != null ) {
311
- isMxBean = checkResult ;
312
- }
313
- }
314
- if (isMxBean ) {
297
+ if (JMX .isMXBeanInterface (iface )) {
315
298
return iface ;
316
299
}
317
300
}
@@ -322,21 +305,11 @@ public static Class<?> getMXBeanInterface(Class<?> clazz) {
322
305
* Check whether MXBean support is available, i.e. whether we're running
323
306
* on Java 6 or above.
324
307
* @return {@code true} if available; {@code false} otherwise
308
+ * @deprecated as of Spring 4.0, since Java 6 is required anyway now
325
309
*/
310
+ @ Deprecated
326
311
public static boolean isMXBeanSupportAvailable () {
327
- return mxBeanAnnotationAvailable ;
328
- }
329
-
330
-
331
- /**
332
- * Inner class to avoid a Java 6 dependency.
333
- */
334
- private static class MXBeanChecker {
335
-
336
- public static Boolean evaluateMXBeanAnnotation (Class <?> iface ) {
337
- MXBean mxBean = iface .getAnnotation (MXBean .class );
338
- return (mxBean != null ? mxBean .value () : null );
339
- }
312
+ return true ;
340
313
}
341
314
342
315
}
0 commit comments