Java Reference
In-Depth Information
5.2.3
Invoking operations
So far, you have seen how to acquire the management interface from a Dynamic
MBean, and how to get and set attributes. The management interface is
described by the MBeanInfo object returned by the getMBeanInfo() method, and
attributes are managed via the getAttribute ( s ) () and setAttribute ( s ) () meth-
ods. At this point, we need to explain how the DynamicMBean interface provides a
mechanism for invoking exposed MBean operations. Again, an MBean user
gains knowledge of MBean operations by first acquiring an MBeanInfo object by
invoking the getMBeanInfo() method of the Dynamic MBean.
For the same reason as attributes, operations cannot be explicitly defined by a
Dynamic MBean (its management interface is provided at runtime). Therefore,
another generic mechanism is needed to provide the ability to invoke Dynamic
MBean operations. The DynamicMBean interface declares the invoke() method to
provide such a mechanism.
The invoke() method takes three arguments:
A String value containing the name of the method you want to invoke
An array of Object instances that are the parameter values to the method
being invoked
An array of String values corresponding to the parameter class types of
the invoking method
The last two arguments (the arrays) contain their values in the order they appear
in the desired method declaration. For example, a method declared as setPrint-
Quality( Integer level ) would be described with an array of one element con-
taining the Integer value, and another one-element array containing the value
java.lang.Integer . Dynamic MBeans analyze these arguments, invoke the
appropriate method, and return the result. The result of the underlying method
invocation is returned in the invoke() method as an Object value.
5.3 Understanding the MBeanInfo class
In the previous section, you learned the purposes of the methods of the Dynamic-
MBean interface and how they are used to manage a Dynamic MBean. However,
the previous section only told you that the management interface of the MBean
is contained in the MBeanInfo object returned by the method getMBeanInfo() .
Search WWH ::




Custom Search