Top Description Inners Fields Constructors Methods
com.sun.jmx.mbeanserver

public Class Introspector

extends Object
Class Inheritance
Imports
java.lang.annotation.Annotation, java.lang.ref.SoftReference, java.lang.reflect.AnnotatedElement, .Constructor, .Method, .Modifier, .Proxy, .UndeclaredThrowableException, .Array, .InvocationTargetException, java.util.ArrayList, .Arrays, .Collections, .HashMap, .List, .Locale, .Map, .WeakHashMap, javax.management.Descriptor, .DescriptorKey, .DynamicMBean, .ImmutableDescriptor, .MBeanInfo, .NotCompliantMBeanException, .AttributeNotFoundException, com.sun.jmx.remote.util.EnvHelp, java.security.AccessController, javax.management.openmbean.CompositeData, sun.reflect.misc.MethodUtil, .ReflectUtil

This class contains the methods for performing all the tests needed to verify that a class represents a JMX compliant MBean.
Since
1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
Introspector.SimpleIntrospector

A simple introspector that uses reflection to analyze a class and identify its "getter" methods.

Field Summary

Modifier and TypeField and Description
public static final boolean

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static Object
public static void
checkCompliance(Class<?> mbeanClass)

public static Descriptor
public static Descriptor
public static Object
elementFromComplex(Object complex, String element)

private static boolean
private static <T> Class<? super T>
findMBeanInterface(Class<T> aClass, String aName)

Try to find the MBean interface corresponding to the class aName - i.e. aNameMBean, from within aClass and its superclasses.

private static <M> MBeanInfo
getClassMBeanInfo(MBeanIntrospector<M> introspector, Class<?> baseClass, Class<?> mbeanInterface)

public static Class<?>

Returns:

The MBean interface implemented by the MBean. Return null if the MBean is a DynamicMBean, or if no MBean interface is found.
getMBeanInterface
(Class<?>
The class to be tested.
baseClass
)

Get the MBean interface implemented by a JMX Standard MBean class.

public static <T> Class<? super T>

Returns:

The MXBean interface implemented by the MXBean.
getMXBeanInterface
(Class<T>
The class to be tested.
baseClass
)

Get the MXBean interface implemented by a JMX MXBean class.

public static <T> Class<? super T>

Returns:

The MBean interface implemented by the Standard MBean.
getStandardMBeanInterface
(Class<T>
The class to be tested.
baseClass
)

Get the MBean interface implemented by a JMX Standard MBean class.

private static <T> Class<? super T>
implementsMBean(Class<T>
The interface to be tested
c
,
String
The name of the class implementing this interface
clName
)

Returns the XXMBean interface or null if no such interface exists

public static final boolean

Returns:

true if instances of c are Dynamic MBeans, false otherwise.
isDynamic
(final Class<?>
The class of the MBean under examination.
c
)

Tell whether a MBean of the given class is a Dynamic MBean.

public static <T> DynamicMBean
public static MBeanInfo

Returns:

null if the MBean is a DynamicMBean, the computed javax.management.MBeanInfo otherwise.
testCompliance
(Class<?>
The class to be tested
baseClass
)

Basic method for testing if a given class is a JMX compliant MBean.

public static synchronized MBeanInfo

Returns:

the computed javax.management.MBeanInfo.
testCompliance
(final Class<?>
The class to be tested.
baseClass
,
Class<?>
the MBean interface that the class implements, or null if the interface must be determined by introspection.
mbeanInterface
)

Basic method for testing if a given class is a JMX compliant Standard MBean.

public static void
testComplianceMBeanInterface(Class<?>
An interface class to test for the MBean compliance
interfaceClass
)

Tests the given interface class for being a compliant MBean interface.

public static void
testComplianceMXBeanInterface(Class<?>
An interface class to test for the MXBean compliance
interfaceClass
)

Tests the given interface class for being a compliant MXBean interface.

public static void
testCreation(Class<?>
The class of the MBean we want to create.
c
)

Basic method for testing that a MBean of a given class can be instantiated by the MBean server.

pack-priv static NotCompliantMBeanException

Returns:

nothing - this method always throw an exception. The return type makes it possible to write
 throw throwException(clazz,cause); 
throwException
(Class<?>
the class which was under examination
notCompliant
,
Throwable
the reason why NotCompliantMBeanException should be thrown.
cause
)

Throws a NotCompliantMBeanException or a SecurityException.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALLOW_NONPUBLIC_MBEANback to summary
public static final boolean ALLOW_NONPUBLIC_MBEAN

Constructor Detail

Introspectorback to summary
private Introspector()

Method Detail

annotationToFieldback to summary
private static Object annotationToField(Object x)
checkComplianceback to summary
public static void checkCompliance(Class<?> mbeanClass) throws NotCompliantMBeanException
descriptorForAnnotationsback to summary
public static Descriptor descriptorForAnnotations(Annotation[] annots)
descriptorForElementback to summary
public static Descriptor descriptorForElement(final AnnotatedElement elmt)
elementFromComplexback to summary
public static Object elementFromComplex(Object complex, String element) throws AttributeNotFoundException
equalsback to summary
private static boolean equals(Object x, Object y)
findMBeanInterfaceback to summary
private static <T> Class<? super T> findMBeanInterface(Class<T> aClass, String aName)

Try to find the MBean interface corresponding to the class aName - i.e. aNameMBean, from within aClass and its superclasses.

getClassMBeanInfoback to summary
private static <M> MBeanInfo getClassMBeanInfo(MBeanIntrospector<M> introspector, Class<?> baseClass, Class<?> mbeanInterface) throws NotCompliantMBeanException
getMBeanInterfaceback to summary
public static Class<?> getMBeanInterface(Class<?> baseClass)

Get the MBean interface implemented by a JMX Standard MBean class. This method is only called by the legacy code in "com.sun.management.jmx".

Parameters
baseClass:Class<?>

The class to be tested.

Returns:Class<?>

The MBean interface implemented by the MBean. Return null if the MBean is a DynamicMBean, or if no MBean interface is found.

getMXBeanInterfaceback to summary
public static <T> Class<? super T> getMXBeanInterface(Class<T> baseClass) throws NotCompliantMBeanException

Get the MXBean interface implemented by a JMX MXBean class.

Parameters
baseClass:Class<T>

The class to be tested.

Returns:Class<? super T>

The MXBean interface implemented by the MXBean.

Exceptions
NotCompliantMBeanException:
The specified class is not a JMX compliant MXBean.
getStandardMBeanInterfaceback to summary
public static <T> Class<? super T> getStandardMBeanInterface(Class<T> baseClass) throws NotCompliantMBeanException

Get the MBean interface implemented by a JMX Standard MBean class.

Parameters
baseClass:Class<T>

The class to be tested.

Returns:Class<? super T>

The MBean interface implemented by the Standard MBean.

Exceptions
NotCompliantMBeanException:
The specified class is not a JMX compliant Standard MBean.
implementsMBeanback to summary
private static <T> Class<? super T> implementsMBean(Class<T> c, String clName)

Returns the XXMBean interface or null if no such interface exists

Parameters
c:Class<T>

The interface to be tested

clName:String

The name of the class implementing this interface

isDynamicback to summary
public static final boolean isDynamic(final Class<?> c)

Tell whether a MBean of the given class is a Dynamic MBean. This method does nothing more than returning

javax.management.DynamicMBean.class.isAssignableFrom(c)
This method does not check for any JMX MBean compliance:
  • If true is returned, then instances of c are DynamicMBean.
  • If false is returned, then no further assumption can be made on instances of c. In particular, instances of c may, or may not be JMX standard MBeans.
Parameters
c:Class<?>

The class of the MBean under examination.

Returns:boolean

true if instances of c are Dynamic MBeans, false otherwise.

makeDynamicMBeanback to summary
public static <T> DynamicMBean makeDynamicMBean(T mbean) throws NotCompliantMBeanException
testComplianceback to summary
public static MBeanInfo testCompliance(Class<?> baseClass) throws NotCompliantMBeanException

Basic method for testing if a given class is a JMX compliant MBean.

Parameters
baseClass:Class<?>

The class to be tested

Returns:MBeanInfo

null if the MBean is a DynamicMBean, the computed javax.management.MBeanInfo otherwise.

Exceptions
NotCompliantMBeanException:
The specified class is not a JMX compliant MBean
testComplianceback to summary
public static synchronized MBeanInfo testCompliance(final Class<?> baseClass, Class<?> mbeanInterface) throws NotCompliantMBeanException

Basic method for testing if a given class is a JMX compliant Standard MBean. This method is only called by the legacy code in com.sun.management.jmx.

Parameters
baseClass:Class<?>

The class to be tested.

mbeanInterface:Class<?>

the MBean interface that the class implements, or null if the interface must be determined by introspection.

Returns:MBeanInfo

the computed javax.management.MBeanInfo.

Exceptions
NotCompliantMBeanException:
The specified class is not a JMX compliant Standard MBean
testComplianceMBeanInterfaceback to summary
public static void testComplianceMBeanInterface(Class<?> interfaceClass) throws NotCompliantMBeanException

Tests the given interface class for being a compliant MBean interface. A compliant MBean interface is any publicly accessible interface following the MBean conventions.

Parameters
interfaceClass:Class<?>

An interface class to test for the MBean compliance

Exceptions
NotCompliantMBeanException:
Thrown when the tested interface is not public or contradicts the MBean conventions.
testComplianceMXBeanInterfaceback to summary
public static void testComplianceMXBeanInterface(Class<?> interfaceClass) throws NotCompliantMBeanException

Tests the given interface class for being a compliant MXBean interface. A compliant MXBean interface is any publicly accessible interface following the MXBean conventions.

Parameters
interfaceClass:Class<?>

An interface class to test for the MXBean compliance

Exceptions
NotCompliantMBeanException:
Thrown when the tested interface is not public or contradicts the MXBean conventions.
testCreationback to summary
public static void testCreation(Class<?> c) throws NotCompliantMBeanException

Basic method for testing that a MBean of a given class can be instantiated by the MBean server.

This method checks that:

  • The given class is a concrete class.
  • The given class exposes at least one public constructor.
If these conditions are not met, throws a NotCompliantMBeanException.
Parameters
c:Class<?>

The class of the MBean we want to create.

Exceptions
NotCompliantMBeanException:
if the MBean class makes it impossible to instantiate the MBean from within the MBeanServer.
throwExceptionback to summary
pack-priv static NotCompliantMBeanException throwException(Class<?> notCompliant, Throwable cause) throws NotCompliantMBeanException, SecurityException

Throws a NotCompliantMBeanException or a SecurityException.

Parameters
notCompliant:Class<?>

the class which was under examination

cause:Throwable

the reason why NotCompliantMBeanException should be thrown.

Returns:NotCompliantMBeanException

nothing - this method always throw an exception. The return type makes it possible to write

 throw throwException(clazz,cause); 
Exceptions
NotCompliantMBeanException:
otherwise.
SecurityException:
if cause is a SecurityException
com.sun.jmx.mbeanserver back to summary

private Class Introspector.SimpleIntrospector

extends Object
Class Inheritance

A simple introspector that uses reflection to analyze a class and identify its "getter" methods. This class is intended for use only when Java Beans is not present (which implies that there isn't explicit information about the bean available).

Field Summary

Modifier and TypeField and Description
private static final Map<Class<?>, SoftReference<List<Method>>>
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static List<Method>
getCachedMethods(Class<?> clazz)

Returns the list of methods cached for the given class, or null if not cached.

pack-priv static Method
getReadMethod(Class<?> clazz, String property)

Returns the "getter" to read the given property from the given class or null if no method is found.

pack-priv static List<Method>
getReadMethods(Class<?> clazz)

Returns the list of "getter" methods for the given class.

pack-priv static boolean
isReadMethod(Method method)

Returns true if the given method is a "getter" method (where "getter" method is a public method of the form getXXX or "boolean isXXX")

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheback to summary
private static final Map<Class<?>, SoftReference<List<Method>>> cache
GET_METHOD_PREFIXback to summary
private static final String GET_METHOD_PREFIX
IS_METHOD_PREFIXback to summary
private static final String IS_METHOD_PREFIX

Constructor Detail

SimpleIntrospectorback to summary
private SimpleIntrospector()

Method Detail

getCachedMethodsback to summary
private static List<Method> getCachedMethods(Class<?> clazz)

Returns the list of methods cached for the given class, or null if not cached.

getReadMethodback to summary
pack-priv static Method getReadMethod(Class<?> clazz, String property)

Returns the "getter" to read the given property from the given class or null if no method is found.

getReadMethodsback to summary
pack-priv static List<Method> getReadMethods(Class<?> clazz)

Returns the list of "getter" methods for the given class. The list is ordered so that isXXX methods appear before getXXX methods - this is for compatibility with the JavaBeans Introspector.

isReadMethodback to summary
pack-priv static boolean isReadMethod(Method method)

Returns true if the given method is a "getter" method (where "getter" method is a public method of the form getXXX or "boolean isXXX")