com.sun.jaw.reference.common
Class MBeanIntrospector

java.lang.Object
  |
  +--com.sun.jaw.reference.common.MBeanIntrospector

public class MBeanIntrospector
extends java.lang.Object

The MBeanIntrospector class provides a way to learn about the properties and actions supported by an m-bean.

For each of those two kinds of information, the MBeanIntrospector will separately analyze the bean's class and superclasses looking for implicit information and use that information to build a MBeanInfo object that comprehensively describes the target bean.

We use low-level reflection to study the methods of the class and apply standard design patterns to identify property accessors or public actions. We then proceed to analyze the class's superclass and add the information from it (and possibly on up the superclass chain). Non-serializable property accessors or public actions are omitted from the information.


Constructor Summary
MBeanIntrospector()
           
 
Method Summary
static java.lang.reflect.Constructor findConstructor(java.lang.Class theClass, java.lang.Class[] parameterTypes)
          Find a specific constructor of a class
static java.lang.reflect.Method findGetter(java.lang.Class classObj, java.lang.String property)
          Find the getter of a specific property in an object.
static java.lang.reflect.Method findIndexedGetter(java.lang.Class classObj, java.lang.String property)
          Find the getter of a specific property in an object.
static java.lang.reflect.Method findIndexedSetter(java.lang.Class classObj, java.lang.String property)
          Finds the setter of a specific indexed property without knowing its type.
static java.lang.reflect.Method findIndexedSetter(java.lang.Class classObj, java.lang.String property, java.lang.Class type)
          Find the setter of a specific indexed property in an object.
static java.lang.String[] findListOfActions(java.lang.Class targetClass, boolean flat)
          Finds the list of actions available in a specific class.
static java.lang.String[] findListOfProperties(java.lang.Class targetClass, boolean flat)
          Finds the list of properties available in a specific class.
static java.lang.reflect.Method findMethod(java.lang.Class classObj, java.lang.String name)
          Find a specific method of an object without knowing the parameter types.
static java.lang.reflect.Method findMethod(java.lang.Class classObj, java.lang.String name, java.lang.Class[] parameterTypes)
          Find a specific method of an object
protected static java.lang.reflect.Method findMethod(java.lang.Class classObj, java.lang.String name, int paramCount)
          Find a specific method of an object given the number of parameters.
static java.lang.reflect.Method findPerform(java.lang.Class classObj, java.lang.String name, java.lang.Class[] parametersType)
          Find a specify perform method from the method name
static java.lang.reflect.Method findSetter(java.lang.Class classObj, java.lang.String property)
          Find the setter of a specific property without knowing its type.
static java.lang.reflect.Method findSetter(java.lang.Class classObj, java.lang.String property, java.lang.Class type)
          Find the setter of a specific property in an object.
static void flushCaches()
          Flush all the internal caches.
static void flushFromCaches(java.lang.Class clz)
          Flush the internal cached information for a given class.
static MBeanInfo getMBeanInfo(java.lang.Class beanClass)
          Introspect a m-bean and learn about all its properties and actions.
static MBeanInfo getMBeanInfo(java.lang.Class beanClass, java.lang.Class stopClass)
          Introspect a m-bean and learn about all its properties and actions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MBeanIntrospector

public MBeanIntrospector()
Method Detail

getMBeanInfo

public static MBeanInfo getMBeanInfo(java.lang.Class beanClass)
                              throws java.beans.IntrospectionException
Introspect a m-bean and learn about all its properties and actions.
Parameters:
beanClass - The bean class to be analyzed.
Returns:
A MBeanInfo object describing the target m-bean.
Throws:
java.beans.IntrospectionException - if an exception occurs during introspection.

getMBeanInfo

public static MBeanInfo getMBeanInfo(java.lang.Class beanClass,
                                     java.lang.Class stopClass)
                              throws java.beans.IntrospectionException
Introspect a m-bean and learn about all its properties and actions.
Parameters:
beanClass - The bean class to be analyzed.
stopClass - The baseclass at which to stop the analysis.
Returns:
A MBeanInfo object describing the target m-bean.
Throws:
java.beans.IntrospectionException - if an exception occurs during introspection.

flushCaches

public static void flushCaches()
Flush all the internal caches.

flushFromCaches

public static void flushFromCaches(java.lang.Class clz)
Flush the internal cached information for a given class.

findListOfProperties

public static java.lang.String[] findListOfProperties(java.lang.Class targetClass,
                                                      boolean flat)
Finds the list of properties available in a specific class.

When flat is false inherited properties are not returned.


findListOfActions

public static java.lang.String[] findListOfActions(java.lang.Class targetClass,
                                                   boolean flat)
Finds the list of actions available in a specific class.

When flat is false inherited actions are not returned.


findMethod

public static java.lang.reflect.Method findMethod(java.lang.Class classObj,
                                                  java.lang.String name,
                                                  java.lang.Class[] parameterTypes)
Find a specific method of an object
Parameters:
object - object for which the method is requested
name - name of the method to retrieve
parameterTypes - method formal parameter types
Returns:
the method or null if not found

findMethod

public static java.lang.reflect.Method findMethod(java.lang.Class classObj,
                                                  java.lang.String name)
Find a specific method of an object without knowing the parameter types.

The first method whose name matches is returned.

Parameters:
object - object for which the method is requested
name - name of the method to retrieve
Returns:
the method or null if not found

findGetter

public static java.lang.reflect.Method findGetter(java.lang.Class classObj,
                                                  java.lang.String property)
Find the getter of a specific property in an object.
Parameters:
object - object for which a getter is requested
property - property to look for in the object
Returns:
the method for accessing the property, null otherwise

findIndexedGetter

public static java.lang.reflect.Method findIndexedGetter(java.lang.Class classObj,
                                                         java.lang.String property)
Find the getter of a specific property in an object.
Parameters:
object - object for which a getter is requested
property - property to look for in the object
Returns:
the method for accessing the property, null otherwise

findSetter

public static java.lang.reflect.Method findSetter(java.lang.Class classObj,
                                                  java.lang.String property,
                                                  java.lang.Class type)
Find the setter of a specific property in an object.
Parameters:
object - object for which a getter is requested
property - property to look for in the object
type - type of the property
Returns:
the method for accessing the property, null otherwise

findSetter

public static java.lang.reflect.Method findSetter(java.lang.Class classObj,
                                                  java.lang.String property)
Find the setter of a specific property without knowing its type.
Parameters:
object - object for which a getter is requested
property - property to look for in the object
Returns:
the method for accessing the property, null otherwise

findIndexedSetter

public static java.lang.reflect.Method findIndexedSetter(java.lang.Class classObj,
                                                         java.lang.String property,
                                                         java.lang.Class type)
Find the setter of a specific indexed property in an object.
Parameters:
object - object for which a getter is requested
property - property to look for in the object
type - type of the property
Returns:
the method for accessing the property, null otherwise

findIndexedSetter

public static java.lang.reflect.Method findIndexedSetter(java.lang.Class classObj,
                                                         java.lang.String property)
Finds the setter of a specific indexed property without knowing its type.
Parameters:
object - object for which a getter is requested
property - property to look for in the object
Returns:
the method for accessing the property, null otherwise

findConstructor

public static java.lang.reflect.Constructor findConstructor(java.lang.Class theClass,
                                                            java.lang.Class[] parameterTypes)
Find a specific constructor of a class
Parameters:
name - name of the method to retrieve
parameterTypes - method formal parameter types
Returns:
the requested constructor or null if not found

findPerform

public static java.lang.reflect.Method findPerform(java.lang.Class classObj,
                                                   java.lang.String name,
                                                   java.lang.Class[] parametersType)
Find a specify perform method from the method name
Parameters:
object - object for which the method is requested
name - name of the method to retreive
parameterType - method formal parameter type

findMethod

protected static java.lang.reflect.Method findMethod(java.lang.Class classObj,
                                                     java.lang.String name,
                                                     int paramCount)
Find a specific method of an object given the number of parameters.

The first method whose name and parameter count match is returned.

Parameters:
object - object for which the method is requested
name - name of the method to retrieve
paramCount - expected number of parameters
Returns:
the method or null if not found