Java Reference
In-Depth Information
In chapters 4 and 5, we covered Standard and Dynamic MBeans. This chapter
discusses a new type of MBean: the Model MBean. The Model MBean is unique
because developers do not have to write an MBean class. The classes and inter-
face that make up the Model MBean are defined by the JMX specification and
are guaranteed to be available in every JMX -compliant agent. Model MBeans are
generic MBeans that can be instantiated in the MBean server and configured by
a user to manage any resource.
In addition to resource management, the Model MBean provides several fea-
tures that make it the most robust MBean, including MBean persistence, attribute
value caching, and more. This chapter discusses how you can use Model MBeans
to rapidly instrument a manageable resource.
7.1 Working with the Model MBean
Without considering the other features of the Model MBean (which we examine
in the next section), the Model MBean's main difference from the Standard and
Dynamic MBeans is that you do not develop the MBean class—the Model
MBean is a required part of a JMX agent. The Model MBean is defined by the
class javax.management.modelmbean.RequiredModelMBean .
As is the case for the Dynamic MBean, the management interface for a Model
MBean is defined at runtime. In fact, the RequiredModelMBean class implements
the ModelMBean interface, which extends the DynamicMBean interface. However,
unlike usual Dynamic MBeans, the Model MBean's management interface is
defined outside the MBean (by a management application or resource) and
inserted into the MBean via a setter method.
To better understand how this works, let's walk through a few steps in a sam-
ple scenario that creates a Model MBean:
An application starts up and locates a JMX agent in order to expose itself
for management by registering an MBean with the agent.
1
The application calls the createMBean() method of the agent's MBean
server, telling it to create an instance of the javax.management.modelm-
bean.RequiredModelMBean class.
2
After the MBean is created, the application sets an object in the MBean
to use as its managed resource.
3
The application creates an instance of the ModelMBeanInfoSupport class.
This object, like the MBeanInfo class from chapter 4, encapsulates the
4
Search WWH ::




Custom Search