|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2012 the original author or authors. |
|
|
|
|
* Copyright 2002-2014 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -22,10 +22,10 @@ import java.lang.reflect.Method;
@@ -22,10 +22,10 @@ import java.lang.reflect.Method;
|
|
|
|
|
import java.util.Hashtable; |
|
|
|
|
import java.util.List; |
|
|
|
|
import javax.management.DynamicMBean; |
|
|
|
|
import javax.management.JMX; |
|
|
|
|
import javax.management.MBeanParameterInfo; |
|
|
|
|
import javax.management.MBeanServer; |
|
|
|
|
import javax.management.MBeanServerFactory; |
|
|
|
|
import javax.management.MXBean; |
|
|
|
|
import javax.management.MalformedObjectNameException; |
|
|
|
|
import javax.management.ObjectName; |
|
|
|
|
|
|
|
|
@ -59,16 +59,6 @@ public abstract class JmxUtils {
@@ -59,16 +59,6 @@ public abstract class JmxUtils {
|
|
|
|
|
*/ |
|
|
|
|
private static final String MBEAN_SUFFIX = "MBean"; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Suffix used to identify a Java 6 MXBean interface. |
|
|
|
|
*/ |
|
|
|
|
private static final String MXBEAN_SUFFIX = "MXBean"; |
|
|
|
|
|
|
|
|
|
private static final String MXBEAN_ANNOTATION_CLASS_NAME = "javax.management.MXBean"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final boolean mxBeanAnnotationAvailable = |
|
|
|
|
ClassUtils.isPresent(MXBEAN_ANNOTATION_CLASS_NAME, JmxUtils.class.getClassLoader()); |
|
|
|
|
|
|
|
|
|
private static final Log logger = LogFactory.getLog(JmxUtils.class); |
|
|
|
|
|
|
|
|
@ -304,14 +294,7 @@ public abstract class JmxUtils {
@@ -304,14 +294,7 @@ public abstract class JmxUtils {
|
|
|
|
|
} |
|
|
|
|
Class<?>[] implementedInterfaces = clazz.getInterfaces(); |
|
|
|
|
for (Class<?> iface : implementedInterfaces) { |
|
|
|
|
boolean isMxBean = iface.getName().endsWith(MXBEAN_SUFFIX); |
|
|
|
|
if (mxBeanAnnotationAvailable) { |
|
|
|
|
Boolean checkResult = MXBeanChecker.evaluateMXBeanAnnotation(iface); |
|
|
|
|
if (checkResult != null) { |
|
|
|
|
isMxBean = checkResult; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (isMxBean) { |
|
|
|
|
if (JMX.isMXBeanInterface(iface)) { |
|
|
|
|
return iface; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -322,21 +305,11 @@ public abstract class JmxUtils {
@@ -322,21 +305,11 @@ public abstract class JmxUtils {
|
|
|
|
|
* Check whether MXBean support is available, i.e. whether we're running |
|
|
|
|
* on Java 6 or above. |
|
|
|
|
* @return {@code true} if available; {@code false} otherwise |
|
|
|
|
* @deprecated as of Spring 4.0, since Java 6 is required anyway now |
|
|
|
|
*/ |
|
|
|
|
@Deprecated |
|
|
|
|
public static boolean isMXBeanSupportAvailable() { |
|
|
|
|
return mxBeanAnnotationAvailable; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Inner class to avoid a Java 6 dependency. |
|
|
|
|
*/ |
|
|
|
|
private static class MXBeanChecker { |
|
|
|
|
|
|
|
|
|
public static Boolean evaluateMXBeanAnnotation(Class<?> iface) { |
|
|
|
|
MXBean mxBean = iface.getAnnotation(MXBean.class); |
|
|
|
|
return (mxBean != null ? mxBean.value() : null); |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|