| java.lang.Object mx4j.AbstractDynamicMBean
All known Subclasses: mx4j.examples.mbeans.legacy.DynamicLegacyService, mx4j.examples.mbeans.dynamic.DynamicService,
AbstractDynamicMBean | abstract public class AbstractDynamicMBean implements DynamicMBean(Code) | | Utility class that allow the user to easily write DynamicMBeans.
By extending this class, the developer does not have to implement the methods of the DynamicMBean interface, but
has instead to provide only the metadata (by overriding few methods) and the implementation (by implementing
the methods) of the MBean itself.
The methods to override that provides metadata information are usually the following:
-
createMBeanAttributeInfo , if the MBeans has manageable attributes
-
createMBeanOperationInfo , if the MBeans has manageable operations
-
createMBeanNotificationInfo , if the MBeans has manageable notifications
-
createMBeanConstructorInfo , if the MBeans has manageable constructors
-
getMBeanDescription
For example, the following MBean only has one manageable attribute:
public class SimpleDynamic extends AbstractDynamicMBean
{
protected MBeanAttributeInfo[] createMBeanAttributeInfo()
{
return new MBeanAttributeInfo[]
{
new MBeanAttributeInfo("Name", String.class.getName(), "The name", true, true, false)
};
}
protected String getMBeanDescription()
{
return "A simple DynamicMBean";
}
public String getName() { ... }
public void setName(String name) { ... }
}
It is responsibility of the developer to specify the metadata and implement the methods specified by the
metadata, that will be invoked via reflection by the AbstractDynamicMBean class. For this reason, the methods
belonging to the MBean implementation (in the case above getName() and setName(...) )
must be public.
version: $Revision: 1.7 $ |
Constructor Summary | |
protected | AbstractDynamicMBean() Only subclasses can create a new instance of an AbstractDynamicMBean. |
Method Summary | |
protected MBeanAttributeInfo[] | createMBeanAttributeInfo() To be overridden to return metadata information about manageable attributes. | protected MBeanConstructorInfo[] | createMBeanConstructorInfo() To be overridden to return metadata information about manageable constructors. | protected MBeanInfo | createMBeanInfo() Creates the MBeanInfo for this instance, calling in succession factory methods that the user can override. | protected MBeanNotificationInfo[] | createMBeanNotificationInfo() To be overridden to return metadata information about manageable notifications. | protected MBeanOperationInfo[] | createMBeanOperationInfo() To be overridden to return metadata information about manageable operations. | protected Method | findMethod(Class cls, String name, Class[] params) Returns the (public) method with the given name and signature on the given class. | public Object | getAttribute(String attribute) Returns the value of the manageable attribute, as specified by the DynamicMBean interface. | public AttributeList | getAttributes(String[] attributes) Returns the manageable attributes, as specified by the DynamicMBean interface. | protected String | getMBeanClassName() To be overridden to return metadata information about the class name of this MBean;
by default returns this class' name. | protected String | getMBeanDescription() To be overridden to return metadata information about the description of this MBean. | public synchronized MBeanInfo | getMBeanInfo() Returns the MBeaInfo, as specified by the DynamicMBean interface; the default implementation caches the value
returned by
AbstractDynamicMBean.createMBeanInfo (that is thus called only once). | protected synchronized Object | getResource() | public Object | invoke(String method, Object[] arguments, String[] params) | protected Object | invoke(String name, Class[] params, Object[] args) | protected Object | invoke(Object resource, String name, Class[] params, Object[] args) Looks up the method to call on given resource and invokes it. | protected Object | invokeMethod(Method method, Object resource, Object[] args) Invokes the given method on the given resource object with the given arguments. | public void | setAttribute(Attribute attribute) Sets the value of the manageable attribute, as specified by the DynamicMBean interface. | public AttributeList | setAttributes(AttributeList attributes) Sets the manageable attributes, as specified by the DynamicMBean interface. | protected synchronized void | setMBeanInfo(MBeanInfo info) Sets the MBeanInfo object cached by this instance. | public synchronized void | setResource(Object resource) Specifies the resource object on which invoke attribute's getters, attribute's setters and operation's methods. |
createMBeanAttributeInfo | protected MBeanAttributeInfo[] createMBeanAttributeInfo()(Code) | | To be overridden to return metadata information about manageable attributes.
|
createMBeanConstructorInfo | protected MBeanConstructorInfo[] createMBeanConstructorInfo()(Code) | | To be overridden to return metadata information about manageable constructors.
|
createMBeanInfo | protected MBeanInfo createMBeanInfo()(Code) | | Creates the MBeanInfo for this instance, calling in succession factory methods that the user can override.
Information to create MBeanInfo are taken calling the following methods:
|
createMBeanNotificationInfo | protected MBeanNotificationInfo[] createMBeanNotificationInfo()(Code) | | To be overridden to return metadata information about manageable notifications.
|
createMBeanOperationInfo | protected MBeanOperationInfo[] createMBeanOperationInfo()(Code) | | To be overridden to return metadata information about manageable operations.
|
getAttributes | public AttributeList getAttributes(String[] attributes)(Code) | | Returns the manageable attributes, as specified by the DynamicMBean interface.
|
getMBeanClassName | protected String getMBeanClassName()(Code) | | To be overridden to return metadata information about the class name of this MBean;
by default returns this class' name.
|
getMBeanDescription | protected String getMBeanDescription()(Code) | | To be overridden to return metadata information about the description of this MBean.
|
setResource | public synchronized void setResource(Object resource)(Code) | | Specifies the resource object on which invoke attribute's getters, attribute's setters and operation's methods.
See Also: AbstractDynamicMBean.getResource |
|
|