Package org.apache.wiki.management

# Class SimpleMBean

java.lang.Object
org.apache.wiki.management.SimpleMBean

All Implemented Interfaces:
  `DynamicMBean`

Direct Known Subclasses:
  `PlainEditorAdminBean`, `SimpleAdminBean`

public abstract class SimpleMBean extends Object implements DynamicMBean
A simple MBean which does not require an interface class unlike the StandardMBean class. The methods are exposed through a method call, which in turn then calls the methods using the Reflection API.

This class is similar to the javax.management.StandardMBean, but it does require the API interface to be declared, so it's simpler. It's not as powerful, but it does not require you to declare two classes (and keep them in sync).

Since:
  2.6

## Field Summary

Fields
Modifier and Type
Field
Description
`protected MBeanInfo`
`m_beanInfo`

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`SimpleMBean()`
Create a new SimpleMBean

## Method Summary

Modifier and Type
Method
Description
`Object`
`getAttribute(String name)`
Gets an attribute using reflection from the MBean.
`abstract String[]`
`getAttributeNames()`
This method must return a list of attributes which are exposed by the SimpleMBean.
`AttributeList`
`getAttributes(String[] arg0)`
Gets multiple attributes at the same time.
`protected String`
`getDescription()`
Customization hook: Override this to get a description for your MBean.
`MBeanInfo`
`getMBeanInfo()`
Return the MBeanInfo structure.
`abstract String[]`
`getMethodNames()`
This method must return a list of operations which are to be exposed by the SimpleMBean.
`Object`
`invoke(String arg0, Object[] arg1, String[] arg2)`
Invokes a particular method.
`void`
`setAttribute(Attribute attr)`
`AttributeList`
`setAttributes(AttributeList arg0)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### m_beanInfo

protected MBeanInfo m_beanInfo

## Constructor Details

### SimpleMBean

protected SimpleMBean() throws NotCompliantMBeanException
Create a new SimpleMBean

Throws:
  `NotCompliantMBeanException` - if an error occurs registering the MBean.

## Method Details

### getDescription

protected String getDescription()
Customization hook: Override this to get a description for your MBean. By default, this is an empty string.

Returns:
  A description for the MBean.

### getAttribute

public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException, ReflectionException
Gets an attribute using reflection from the MBean.

Specified by:
  `getAttribute` in interface `DynamicMBean`
Parameters:
  `name` - Name of the attribute to find.
Returns:
  The value returned by the corresponding getXXX() call
Throws:
  `AttributeNotFoundException` - If there is not such attribute
  `MBeanException`
  `ReflectionException`

### getAttributes

public AttributeList getAttributes(String[] arg0)
Gets multiple attributes at the same time.

Specified by:
  `getAttributes` in interface `DynamicMBean`
Parameters:
  `arg0` - The attribute names to get
Returns:
  A list of attributes

### getMBeanInfo

public MBeanInfo getMBeanInfo()
Return the MBeanInfo structure.

Specified by:
  `getMBeanInfo` in interface `DynamicMBean`
Returns:
  the MBeanInfo

### invoke

public Object invoke(String arg0, Object[] arg1, String[] arg2) throws MBeanException, ReflectionException
Invokes a particular method.

Specified by:
  `invoke` in interface `DynamicMBean`
Parameters:
  `arg0` - Method name
  `arg1` - A list of arguments for the invocation
Throws:
  `MBeanException`
  `ReflectionException`

### setAttribute

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

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

### setAttributes

public AttributeList setAttributes(AttributeList arg0)

Specified by:
  `setAttributes` in interface `DynamicMBean`

### getAttributeNames

public abstract String[] getAttributeNames()
This method must return a list of attributes which are exposed by the SimpleMBean. If there's a getXXX() method available, it'll be exposed as a getter, and if there's a setXXX() method available, it'll be exposed as a setter. For example:

         public void setFoo( String foo ) ...
         public String getFoo() ...

         public String[] getAttributeNames()
         {
             String[] attrs = { "foo" };

             return attrs;
         }

Also, methods starting with "is" are also recognized as getters (e.g. `public boolean isFoo()`.)

Returns:
  An array of attribute names that can be get and optionally set.

### getMethodNames

public abstract String[] getMethodNames()
This method must return a list of operations which are to be exposed by the SimpleMBean. Note that using overloaded method names is not supported - only one will be exposed as a JMX method at random.

Returns:
  An array of method names that should be exposed as JMX operations.