11/*
2- * Copyright 2002-2012 the original author or authors.
2+ * Copyright 2002-2014 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
2222import java .util .Hashtable ;
2323import java .util .List ;
2424import javax .management .DynamicMBean ;
25+ import javax .management .JMX ;
2526import javax .management .MBeanParameterInfo ;
2627import javax .management .MBeanServer ;
2728import javax .management .MBeanServerFactory ;
28- import javax .management .MXBean ;
2929import javax .management .MalformedObjectNameException ;
3030import javax .management .ObjectName ;
3131
@@ -59,16 +59,6 @@ public abstract class JmxUtils {
5959 */
6060 private static final String MBEAN_SUFFIX = "MBean" ;
6161
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 ());
7262
7363 private static final Log logger = LogFactory .getLog (JmxUtils .class );
7464
@@ -304,14 +294,7 @@ public static Class<?> getMXBeanInterface(Class<?> clazz) {
304294 }
305295 Class <?>[] implementedInterfaces = clazz .getInterfaces ();
306296 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 )) {
315298 return iface ;
316299 }
317300 }
@@ -322,21 +305,11 @@ public static Class<?> getMXBeanInterface(Class<?> clazz) {
322305 * Check whether MXBean support is available, i.e. whether we're running
323306 * on Java 6 or above.
324307 * @return {@code true} if available; {@code false} otherwise
308+ * @deprecated as of Spring 4.0, since Java 6 is required anyway now
325309 */
310+ @ Deprecated
326311 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 ;
340313 }
341314
342315}
0 commit comments