Package org.apache.wiki.management
Class SimpleMBean
java.lang.Object
org.apache.wiki.management.SimpleMBean
- All Implemented Interfaces:
DynamicMBean
- Direct Known Subclasses:
PlainEditorAdminBean
,SimpleAdminBean
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetAttribute
(String name) Gets an attribute using reflection from the MBean.abstract String[]
This method must return a list of attributes which are exposed by the SimpleMBean.getAttributes
(String[] arg0) Gets multiple attributes at the same time.protected String
Customization hook: Override this to get a description for your MBean.Return the MBeanInfo structure.abstract String[]
This method must return a list of operations which are to be exposed by the SimpleMBean.Invokes a particular method.void
setAttribute
(Attribute attr) setAttributes
(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, ReflectionException Gets an attribute using reflection from the MBean.- Specified by:
getAttribute
in 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 attributeMBeanException
ReflectionException
-
getAttributes
Gets multiple attributes at the same time.- Specified by:
getAttributes
in interfaceDynamicMBean
- Parameters:
arg0
- The attribute names to get- Returns:
- A list of attributes
-
getMBeanInfo
Return the MBeanInfo structure.- Specified by:
getMBeanInfo
in interfaceDynamicMBean
- Returns:
- the MBeanInfo
-
invoke
public Object invoke(String arg0, Object[] arg1, String[] arg2) throws MBeanException, ReflectionException Invokes a particular method.- Specified by:
invoke
in interfaceDynamicMBean
- Parameters:
arg0
- Method namearg1
- 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 interfaceDynamicMBean
- Throws:
AttributeNotFoundException
InvalidAttributeValueException
MBeanException
ReflectionException
-
setAttributes
- Specified by:
setAttributes
in 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.
-