Overview | Package | Class | Tree | Deprecated | Index | Help
| SolarMetric Kodo JDO 3.2.4 generated on January 7 2005
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.solarmetric.manage.jmx.mx4j
Class AbstractDynamicMBean

    java.lang.Object
      |
      +--com.solarmetric.manage.jmx.mx4j.AbstractDynamicMBean

All Implemented Interfaces:
  javax.management.DynamicMBean

public abstract class AbstractDynamicMBean
extends Object
implements javax.management.DynamicMBean

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.3 $

Constructor Summary
`protected` | `AbstractDynamicMBean()` Only subclasses can create a new instance of an AbstractDynamicMBean.

Method Summary
`protected javax.management.MBeanAttributeInfo[]` | `createMBeanAttributeInfo()` To be overridden to return metadata information about manageable attributes.
`protected javax.management.MBeanConstructorInfo[]` | `createMBeanConstructorInfo()` To be overridden to return metadata information about manageable constructors.
`protected javax.management.MBeanInfo` | `createMBeanInfo()` Creates the MBeanInfo for this instance, calling in succession factory methods that the user can override.
`protected javax.management.MBeanNotificationInfo[]` | `createMBeanNotificationInfo()` To be overridden to return metadata information about manageable notifications.
`protected javax.management.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.
`Object` | `getAttribute(String attribute)` Returns the value of the manageable attribute, as specified by the DynamicMBean interface.
`javax.management.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.
`javax.management.MBeanInfo` | `getMBeanInfo()` Returns the MBeaInfo, as specified by the DynamicMBean interface; the default implementation caches the value returned by `createMBeanInfo()` (that is thus called only once).
`protected Object` | `getResource()` Returns the resource object on which invoke attribute's getters, attribute's setters and operation's methods
`protected Object` | `invoke(String name, Class[] params, Object[] args)` Looks up the method to call on the object set as resource (see `setResource(java.lang.Object)`) and invokes it.
`Object` | `invoke(String method, Object[] arguments, String[] params)` Returns the value of the manageable operation as specified by the DynamicMBean interface
`protected Object` | `invokeMethod(Method method, Object resource, Object[] args)` Invokes the given method on the given resource object with the given arguments.
`void` | `setAttribute(javax.management.Attribute attribute)` Sets the value of the manageable attribute, as specified by the DynamicMBean interface.
`javax.management.AttributeList` | `setAttributes(javax.management.AttributeList attributes)` Sets the manageable attributes, as specified by the DynamicMBean interface.
`protected void` | `setMBeanInfo(javax.management.MBeanInfo info)` Sets the MBeanInfo object cached by this instance.
`void` | `setResource(Object resource)` Specifies the resource object on which invoke attribute's getters, attribute's setters and operation's methods.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AbstractDynamicMBean

    protected AbstractDynamicMBean()

  Only subclasses can create a new instance of an AbstractDynamicMBean.
  See Also:
    `createMBeanConstructorInfo()`

Method Detail

### getAttribute

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

  Returns the value of the manageable attribute, as specified by the DynamicMBean interface.
  Specified by:
    `getAttribute` in interface `javax.management.DynamicMBean`
  See Also:
    `createMBeanAttributeInfo()`

### getAttributes

    public javax.management.AttributeList getAttributes(String[] attributes)

  Returns the manageable attributes, as specified by the DynamicMBean interface.
  Specified by:
    `getAttributes` in interface `javax.management.DynamicMBean`

### getMBeanInfo

    public javax.management.MBeanInfo getMBeanInfo()

  Returns the MBeaInfo, as specified by the DynamicMBean interface; the default implementation caches the value returned by `createMBeanInfo()` (that is thus called only once).
  Specified by:
    `getMBeanInfo` in interface `javax.management.DynamicMBean`
  See Also:
    `createMBeanInfo()`, `setMBeanInfo(javax.management.MBeanInfo)`

### invoke

    public Object invoke(String method,
                         Object[] arguments,
                         String[] params)
                  throws javax.management.MBeanException,
                         javax.management.ReflectionException

  Returns the value of the manageable operation as specified by the DynamicMBean interface
  Specified by:
    `invoke` in interface `javax.management.DynamicMBean`
  See Also:
    `createMBeanOperationInfo()`

### setAttribute

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

  Sets the value of the manageable attribute, as specified by the DynamicMBean interface.
  Specified by:
    `setAttribute` in interface `javax.management.DynamicMBean`
  See Also:
    `createMBeanAttributeInfo()`

### setAttributes

    public javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)

  Sets the manageable attributes, as specified by the DynamicMBean interface.
  Specified by:
    `setAttributes` in interface `javax.management.DynamicMBean`

### invoke

    protected Object invoke(String name,
                            Class[] params,
                            Object[] args)
                     throws javax.management.InvalidAttributeValueException,
                            javax.management.MBeanException,
                            javax.management.ReflectionException

  Looks up the method to call on the object set as resource (see `setResource(java.lang.Object)`) and invokes it. If the resource object is not specified, defaults to 'this'. The default implementation requires that the methods that implement attribute and operation behavior on the resource object are public, but it is possible to override this behavior, and call also private methods.
  See Also:
    `findMethod(java.lang.Class, java.lang.String, java.lang.Class[])`, `invokeMethod(java.lang.reflect.Method, java.lang.Object, java.lang.Object[])`

### findMethod

    protected Method findMethod(Class cls,
                                String name,
                                Class[] params)
                         throws NoSuchMethodException

  Returns the (public) method with the given name and signature on the given class.
  Override to return non-public methods, or to map methods to other classes, or to map methods with different signatures
  See Also:
    `invoke(String, Class[], Object[])`, `invokeMethod(java.lang.reflect.Method, java.lang.Object, java.lang.Object[])`

### invokeMethod

    protected Object invokeMethod(Method method,
                                  Object resource,
                                  Object[] args)
                           throws IllegalAccessException,
                                  IllegalArgumentException,
                                  InvocationTargetException

  Invokes the given method on the given resource object with the given arguments.
  Override to map methods to other objects, or to map methods with different arguments
  See Also:
    `invoke(String, Class[], Object[])`, `findMethod(java.lang.Class, java.lang.String, java.lang.Class[])`

### getResource

    protected Object getResource()

  Returns the resource object on which invoke attribute's getters, attribute's setters and operation's methods
  See Also:
    `setResource(java.lang.Object)`

### setResource

    public void setResource(Object resource)

  Specifies the resource object on which invoke attribute's getters, attribute's setters and operation's methods.
  See Also:
    `getResource()`

### setMBeanInfo

    protected void setMBeanInfo(javax.management.MBeanInfo info)

  Sets the MBeanInfo object cached by this instance.
  The given MBeanInfo is not cloned.
  See Also:
    `getMBeanInfo()`

### createMBeanInfo

    protected javax.management.MBeanInfo createMBeanInfo()

  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:
  - ``createMBeanAttributeInfo()``
  - ``createMBeanConstructorInfo()``
  - ``createMBeanOperationInfo()``
  - ``createMBeanNotificationInfo()``
  - ``getMBeanClassName()``
  - ``getMBeanDescription()``

### createMBeanAttributeInfo

    protected javax.management.MBeanAttributeInfo[] createMBeanAttributeInfo()

  To be overridden to return metadata information about manageable attributes.

### createMBeanConstructorInfo

    protected javax.management.MBeanConstructorInfo[] createMBeanConstructorInfo()

  To be overridden to return metadata information about manageable constructors.

### createMBeanOperationInfo

    protected javax.management.MBeanOperationInfo[] createMBeanOperationInfo()

  To be overridden to return metadata information about manageable operations.

### createMBeanNotificationInfo

    protected javax.management.MBeanNotificationInfo[] createMBeanNotificationInfo()

  To be overridden to return metadata information about manageable notifications.

### getMBeanClassName

    protected String getMBeanClassName()

  To be overridden to return metadata information about the class name of this MBean; by default returns this class' name.

### getMBeanDescription

    protected String getMBeanDescription()

  To be overridden to return metadata information about the description of this MBean.

Overview | Package | Class | Tree | Deprecated | Index | Help
| SolarMetric Kodo JDO 3.2.4 generated on January 7 2005
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 2001,2002 SolarMetric, Inc. All Rights Reserved.