Java Reference
In-Depth Information
7.3.1
Configuring a Model MBean
As you read in the previous sections, a Model MBean manages an existing object:
its managed resource. Developers choose how the MBean should use this object
in order to provide the necessary management ability to the underlying man-
aged resource. The Model MBean provides the following two methods that ini-
tialize the MBean for outside use:
setManagedResource( Object resource, String resourceType ) —This
method sets the MBean's managed object. The object is the reference in
which the operations will be invoked and attributes accessed. The resource-
Type parameter tells the MBean what type of Object reference is being
passed in. It can have the value ObjectReference , Handle , IOR , EJBHandle ,
or RMIReference ; however, the Sun RI Model MBean implementation
accepts only the ObjectReference type. Other JMX implementations may
implement the other types.
setModelMBeanInfo( ModelMBeanInfo info ) —The ModelMBeanInfo param-
eter is the metadata object collection that describes the management inter-
face of this Model MBean.
These two methods are very important for creating a Model MBean. They tell
the MBean how to behave and what to interact with. You will see later that not all
operations exposed through the ModelMBeanInfo object have to interact with the
value set via the setManagedResource() method, but in most cases they do. In sec-
tion 7.4, we will dissect the ModelMBeanInfoSupport class, which is the JMX RI
provided implementation of the ModelMBeanInfo interface, as we did the
Dynamic MBean's MBeanInfo class. Doing so will help you better understand all
the features and configurations available to a Model MBean.
7.3.2
Acquiring and using the management interface
Looking back at figure 7.1, you can see that the ModelMBean interface also
extends the DynamicMBean interface. By extending this interface, all Model
MBeans are really Dynamic MBeans. That being so, a Model MBean defines its
management interface at runtime like any other Dynamic MBean. However,
where Dynamic MBeans are user-developed classes that construct their own
MBeanInfo objects to define their management interface, Model MBeans are
standard JMX classes and must have their MBeanInfo created and placed inside
them (using the setModelMBeanInfo() method described earlier).
This requirement creates an interesting situation for Model MBean users.
All MBeans are presented to clients in an identical format; in each case, the
Search WWH ::




Custom Search