spring-framework / org.springframework.jmx.support / JmxUtils

JmxUtils

abstract class JmxUtils

Collection of generic utility methods to support Spring JMX. Includes a convenient method to locate an MBeanServer.

Author
Rob Harrop

Author
Juergen Hoeller

Since
1.2

See Also
#locateMBeanServer

Constructors

<init>

JmxUtils()

Collection of generic utility methods to support Spring JMX. Includes a convenient method to locate an MBeanServer.

Properties

IDENTITY_OBJECT_NAME_KEY

static val IDENTITY_OBJECT_NAME_KEY: String

The key used when extending an existing ObjectName with the identity hash code of its corresponding managed resource.

Functions

appendIdentityToObjectName

open static fun appendIdentityToObjectName(objectName: ObjectName, managedResource: Any): ObjectName

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. This can be used to provide a unique ObjectName for each distinct instance of a particular bean or class. Useful when generating ObjectName at runtime for a set of managed resources based on the template value supplied by a org.springframework.jmx.export.naming.ObjectNamingStrategy.

getAttributeName

open static fun getAttributeName(property: PropertyDescriptor, useStrictCasing: Boolean): String

Return the JMX attribute name to use for the given JavaBeans property.

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.

getClassToExpose

open static fun getClassToExpose(managedBean: Any): Class<*>

Return the class or interface to expose for the given bean. This is the class that will be searched for attributes and operations (for example, checked for annotations).

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).

open static fun getClassToExpose(clazz: Class<*>): Class<*>

Return the class or interface to expose for the given bean class. This is the class that will be searched for attributes and operations (for example, checked for annotations).

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).

getMBeanInterface

open static fun getMBeanInterface(clazz: Class<*>): Class<*>

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").

getMXBeanInterface

open static fun getMXBeanInterface(clazz: Class<*>): Class<*>

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).

getMethodSignature

open static fun getMethodSignature(method: Method): Array<String>

Create a 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.

isMBean

open static fun isMBean(clazz: Class<*>): Boolean

Determine whether the given bean class qualifies as an MBean as-is.

This implementation checks for javax.management.DynamicMBean classes as well as classes with corresponding "*MBean" interface (Standard MBeans) or corresponding "*MXBean" interface (Java 6 MXBeans).

locateMBeanServer

open static fun locateMBeanServer(): MBeanServer
open static fun locateMBeanServer(agentId: String): MBeanServer

Attempt to find a locally running MBeanServer. Fails if no MBeanServer can be found. Logs a warning if more than one MBeanServer found, returning the first one from the list.

parameterInfoToTypes

open static fun parameterInfoToTypes(paramInfo: Array<MBeanParameterInfo>): Array<Class<*>>
open static fun parameterInfoToTypes(paramInfo: Array<MBeanParameterInfo>, classLoader: ClassLoader): Array<Class<*>>

Convert an array of MBeanParameterInfo into an array of Class instances corresponding to the parameters.