org.granite.jmx
Class OpenMBean

java.lang.Object
  extended by org.granite.jmx.OpenMBean
All Implemented Interfaces:
DynamicMBean

public class OpenMBean
extends Object
implements DynamicMBean

The OpenMBean class wraps an instance of any bean and introspects its properties and methods for MBeanAttributes and MBeanOperations. It implements all functionalities required by a DynamicMBean and returns an OpenMBeanInfo object.

Limitations:

Author:
Franck WOLFF

Constructor Summary
protected OpenMBean()
          Creates a new OpenMBean instance and instrospects its child class for attributes and operations.
 
Method Summary
static OpenMBean createMBean(Class<?> beanClass, Object instance)
          Creates a new OpenMBean by introspecting the beanClass parameter and wrapping the instance parameter.
static OpenMBean createMBean(Object instance)
          Creates a new OpenMBean by introspecting and wrapping the instance parameter.
 Object getAttribute(String attribute)
          
 AttributeList getAttributes(String[] names)
          
 MBeanInfo getMBeanInfo()
          
 Object invoke(String actionName, Object[] params, String[] signature)
          
 void setAttribute(Attribute attribute)
          
 AttributeList setAttributes(AttributeList attributes)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OpenMBean

protected OpenMBean()
Creates a new OpenMBean instance and instrospects its child class for attributes and operations.

Method Detail

createMBean

public static OpenMBean createMBean(Object instance)
Creates a new OpenMBean by introspecting and wrapping the instance parameter. This method search for an interface named instance.getClass().getSimpleName() + "MBean" and, if it finds it, uses it for introspection. Otherwise, the class of the instance object is used instead.

Parameters:
instance - an instance of a bean to introspect.
Returns:
a new OpenMBean instance that wraps the instance bean.

createMBean

public static OpenMBean createMBean(Class<?> beanClass,
                                    Object instance)
Creates a new OpenMBean by introspecting the beanClass parameter and wrapping the instance parameter.

Parameters:
beanClass - a class (or interface) used for introspection.
instance - the bean to encapsulate.
Returns:
a new OpenMBean instance that wraps the instance bean.
Throws:
IllegalArgumentException - if instance is not an instance of beanClass.

getAttribute

public Object getAttribute(String attribute)
                    throws AttributeNotFoundException,
                           MBeanException,
                           ReflectionException

Specified by:
getAttribute in interface DynamicMBean
Throws:
AttributeNotFoundException
MBeanException
ReflectionException

getAttributes

public AttributeList getAttributes(String[] names)

Specified by:
getAttributes in interface DynamicMBean

getMBeanInfo

public MBeanInfo getMBeanInfo()

Specified by:
getMBeanInfo in interface DynamicMBean

invoke

public Object invoke(String actionName,
                     Object[] params,
                     String[] signature)
              throws MBeanException,
                     ReflectionException

Specified by:
invoke in interface DynamicMBean
Throws:
MBeanException
ReflectionException

setAttribute

public void setAttribute(Attribute attribute)
                  throws AttributeNotFoundException,
                         InvalidAttributeValueException,
                         MBeanException,
                         ReflectionException

Specified by:
setAttribute in interface DynamicMBean
Throws:
AttributeNotFoundException
InvalidAttributeValueException
MBeanException
ReflectionException

setAttributes

public AttributeList setAttributes(AttributeList attributes)

Specified by:
setAttributes in interface DynamicMBean