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 MBeanInfom_beanInfo -
Constructor Summary
Constructors Modifier Constructor Description protectedSimpleMBean()Create a new SimpleMBean -
Method Summary
Modifier and Type Method Description ObjectgetAttribute(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.AttributeListgetAttributes(String[] arg0)Gets multiple attributes at the same time.protected StringgetDescription()Customization hook: Override this to get a description for your MBean.MBeanInfogetMBeanInfo()Return the MBeanInfo structure.abstract String[]getMethodNames()This method must return a list of operations which are to be exposed by the SimpleMBean.Objectinvoke(String arg0, Object[] arg1, String[] arg2)Invokes a particular method.voidsetAttribute(Attribute attr)AttributeListsetAttributes(AttributeList arg0)
-
Field Details
-
m_beanInfo
-
-
Constructor Details
-
SimpleMBean
Create a new SimpleMBean- Throws:
NotCompliantMBeanException- if an error occurs registering the MBean.
-
-
Method Details
-
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, ReflectionExceptionGets an attribute using reflection from the MBean.- Specified by:
getAttributein interfaceDynamicMBean- Parameters:
name- Name of the attribute to find.- Returns:
- The value returned by the corresponding getXXX() call
- Throws:
AttributeNotFoundException- If there is not such attributeMBeanExceptionReflectionException
-
getAttributes
Gets multiple attributes at the same time.- Specified by:
getAttributesin interfaceDynamicMBean- Parameters:
arg0- The attribute names to get- Returns:
- A list of attributes
-
getMBeanInfo
Return the MBeanInfo structure.- Specified by:
getMBeanInfoin interfaceDynamicMBean- Returns:
- the MBeanInfo
-
invoke
public Object invoke(String arg0, Object[] arg1, String[] arg2) throws MBeanException, ReflectionExceptionInvokes a particular method.- Specified by:
invokein interfaceDynamicMBean- Parameters:
arg0- Method namearg1- A list of arguments for the invocation- Throws:
MBeanExceptionReflectionException
-
setAttribute
public void setAttribute(Attribute attr) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException- Specified by:
setAttributein interfaceDynamicMBean- Throws:
AttributeNotFoundExceptionInvalidAttributeValueExceptionMBeanExceptionReflectionException
-
setAttributes
- Specified by:
setAttributesin interfaceDynamicMBean
-
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
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.
-