Java Reference
In-Depth Information
The next several sections discuss the methods declared in this interface. You
might recognize some of the exceptions thrown by these methods from table 4.3
in chapter 4.
5.2.1
Acquiring the dynamic management interface
The
DynamicMBean
interface exposes the management interface of a resource in a
generic manner by using a standard
JMX
class:
MBeanInfo
.
JMX
agents use the
getMBeanInfo()
method to get the description of the management interface of a
Dynamic MBean.
Unlike Standard MBeans, Dynamic MBeans do not use explicitly declared
methods to expose their management interface. Instead, the management inter-
face is described by the
MBeanInfo
value returned from the
getMBeanInfo()
method at runtime. The
MBeanInfo
object is used as a container for standard
JMX
objects that describe various portions of the MBean's management inter-
face. Therefore, the
MBeanInfo
instance contains all the information needed for a
management tool to interact with the managed resource.
NOTE
Internally, the MBean server either acquires or constructs an
MBeanIn-
fo
object for each MBean it contains. These objects aid the MBean serv-
er when it needs to perform operations on its MBean.
We will closely examine the
javax.management.MBeanInfo
object shortly. First, we
need to finish discussing the methods of the
DynamicMBean
interface.
5.2.2
Working with dynamic MBean attributes
The last section revealed that the management interface of a Dynamic MBean is
described by the return value of its
getMBeanInfo()
method. However, once you
acquire the management interface, you still need the ability to access attributes
and invoke operations. Because Dynamic MBeans define their management
interface at runtime, there can be no explicit setter or getter methods for an
exposed attribute.
In order for Dynamic MBeans to provide support for managing attributes,
the
DynamicMBean
interface must provide a generic way of getting and setting any
exposed attributes. The
DynamicMBean
interface has the following methods for
getting attribute values:
getAttribute()
and
getAttributes()
. In addition, it has
the following two setter methods:
setAttribute()
and
setAttributes()
.