|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.jmx.support.JmxUtils
public abstract class JmxUtils
Collection of generic utility methods to support Spring JMX. Includes a convenient method to locate an MBeanServer.
locateMBeanServer()
Nested Class Summary | |
---|---|
private static class |
JmxUtils.MXBeanChecker
Inner class to avoid a Java 6 dependency. |
Field Summary | |
---|---|
static java.lang.String |
IDENTITY_OBJECT_NAME_KEY
The key used when extending an existing ObjectName with the
identity hash code of its corresponding managed resource. |
private static Log |
logger
|
private static java.lang.String |
MBEAN_SUFFIX
Suffix used to identify an MBean interface. |
private static java.lang.String |
MXBEAN_ANNOTATION_CLASS_NAME
|
private static java.lang.String |
MXBEAN_SUFFIX
Suffix used to identify a Java 6 MXBean interface. |
private static boolean |
mxBeanAnnotationAvailable
|
Constructor Summary | |
---|---|
JmxUtils()
|
Method Summary | |
---|---|
static javax.management.ObjectName |
appendIdentityToObjectName(javax.management.ObjectName objectName,
java.lang.Object managedResource)
Append an additional key/value pair to an existing ObjectName with the key being
the static value identity and the value being the identity hash code of the
managed resource being exposed on the supplied ObjectName . |
static java.lang.String |
getAttributeName(java.beans.PropertyDescriptor property,
boolean useStrictCasing)
Return the JMX attribute name to use for the given JavaBeans property. |
static java.lang.Class<?> |
getClassToExpose(java.lang.Class<?> clazz)
Return the class or interface to expose for the given bean class. |
static java.lang.Class<?> |
getClassToExpose(java.lang.Object managedBean)
Return the class or interface to expose for the given bean. |
static java.lang.Class<?> |
getMBeanInterface(java.lang.Class<?> clazz)
Return the Standard MBean interface for the given class, if any (that is, an interface whose name matches the class name of the given class but with suffix "MBean"). |
static java.lang.String[] |
getMethodSignature(java.lang.reflect.Method method)
Create a String[] representing the argument signature of a
method. |
static java.lang.Class<?> |
getMXBeanInterface(java.lang.Class<?> clazz)
Return the Java 6 MXBean interface exists for the given class, if any (that is, an interface whose name ends with "MXBean" and/or carries an appropriate MXBean annotation). |
static boolean |
isMBean(java.lang.Class<?> clazz)
Determine whether the given bean class qualifies as an MBean as-is. |
static boolean |
isMXBeanSupportAvailable()
Check whether MXBean support is available, i.e. |
static javax.management.MBeanServer |
locateMBeanServer()
Attempt to find a locally running MBeanServer . |
static javax.management.MBeanServer |
locateMBeanServer(java.lang.String agentId)
Attempt to find a locally running MBeanServer . |
static java.lang.Class[] |
parameterInfoToTypes(javax.management.MBeanParameterInfo[] paramInfo)
Convert an array of MBeanParameterInfo into an array of
Class instances corresponding to the parameters. |
static java.lang.Class[] |
parameterInfoToTypes(javax.management.MBeanParameterInfo[] paramInfo,
java.lang.ClassLoader classLoader)
Convert an array of MBeanParameterInfo into an array of
Class instances corresponding to the parameters. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String IDENTITY_OBJECT_NAME_KEY
ObjectName
with the
identity hash code of its corresponding managed resource.
private static final java.lang.String MBEAN_SUFFIX
private static final java.lang.String MXBEAN_SUFFIX
private static final java.lang.String MXBEAN_ANNOTATION_CLASS_NAME
private static final boolean mxBeanAnnotationAvailable
private static final Log logger
Constructor Detail |
---|
public JmxUtils()
Method Detail |
---|
public static javax.management.MBeanServer locateMBeanServer() throws MBeanServerNotFoundException
MBeanServer
. Fails if no
MBeanServer
can be found. Logs a warning if more than one
MBeanServer
found, returning the first one from the list.
MBeanServer
if found
MBeanServerNotFoundException
- if no MBeanServer
could be foundMBeanServerFactory.findMBeanServer(java.lang.String)
public static javax.management.MBeanServer locateMBeanServer(java.lang.String agentId) throws MBeanServerNotFoundException
MBeanServer
. Fails if no
MBeanServer
can be found. Logs a warning if more than one
MBeanServer
found, returning the first one from the list.
agentId
- the agent identifier of the MBeanServer to retrieve.
If this parameter is null
, all registered MBeanServers are considered.
If the empty String is given, the platform MBeanServer will be returned.
MBeanServer
if found
MBeanServerNotFoundException
- if no MBeanServer
could be foundMBeanServerFactory.findMBeanServer(String)
public static java.lang.Class[] parameterInfoToTypes(javax.management.MBeanParameterInfo[] paramInfo) throws java.lang.ClassNotFoundException
MBeanParameterInfo
into an array of
Class
instances corresponding to the parameters.
paramInfo
- the JMX parameter info
java.lang.ClassNotFoundException
- if a parameter type could not be resolvedpublic static java.lang.Class[] parameterInfoToTypes(javax.management.MBeanParameterInfo[] paramInfo, java.lang.ClassLoader classLoader) throws java.lang.ClassNotFoundException
MBeanParameterInfo
into an array of
Class
instances corresponding to the parameters.
paramInfo
- the JMX parameter infoclassLoader
- the ClassLoader to use for loading parameter types
java.lang.ClassNotFoundException
- if a parameter type could not be resolvedpublic static java.lang.String[] getMethodSignature(java.lang.reflect.Method method)
String[]
representing the argument signature of a
method. Each element in the array is the fully qualified class name
of the corresponding argument in the methods signature.
method
- the method to build an argument signature for
public static java.lang.String getAttributeName(java.beans.PropertyDescriptor property, boolean useStrictCasing)
When using strict casing, a JavaBean property with a getter method
such as getFoo()
translates to an attribute called
Foo
. With strict casing disabled, getFoo()
would translate to just foo
.
property
- the JavaBeans property descriptoruseStrictCasing
- whether to use strict casing
public static javax.management.ObjectName appendIdentityToObjectName(javax.management.ObjectName objectName, java.lang.Object managedResource) throws javax.management.MalformedObjectNameException
ObjectName
with the key being
the static value identity
and the value being the identity hash code of the
managed resource being exposed on the supplied ObjectName
. This can be used to
provide a unique ObjectName
for each distinct instance of a particular bean or
class. Useful when generating ObjectNames
at runtime for a set of
managed resources based on the template value supplied by a
ObjectNamingStrategy
.
objectName
- the original JMX ObjectNamemanagedResource
- the MBean instance
javax.management.MalformedObjectNameException
- in case of an invalid object name specificationObjectUtils.getIdentityHexString(Object)
public static java.lang.Class<?> getClassToExpose(java.lang.Object managedBean)
This implementation returns the superclass for a CGLIB proxy and the class of the given bean else (for a JDK proxy or a plain bean class).
managedBean
- the bean instance (might be an AOP proxy)
ClassUtils.getUserClass(Object)
public static java.lang.Class<?> getClassToExpose(java.lang.Class<?> clazz)
This implementation returns the superclass for a CGLIB proxy and the class of the given bean else (for a JDK proxy or a plain bean class).
clazz
- the bean class (might be an AOP proxy class)
ClassUtils.getUserClass(Class)
public static boolean isMBean(java.lang.Class<?> clazz)
This implementation checks for DynamicMBean
classes as well as classes with corresponding "*MBean" interface
(Standard MBeans) or corresponding "*MXBean" interface (Java 6 MXBeans).
clazz
- the bean class to analyze
MBeanExporter.isMBean(Class)
public static java.lang.Class<?> getMBeanInterface(java.lang.Class<?> clazz)
clazz
- the class to check
public static java.lang.Class<?> getMXBeanInterface(java.lang.Class<?> clazz)
clazz
- the class to check
public static boolean isMXBeanSupportAvailable()
true
if available; false
otherwise
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |