Java Reference
In-Depth Information
You learned in chapter 4 that Standard MBeans are perfect for managing new
resources or resources with well-known, static interfaces. Unfortunately, we all
know that resources often evolve over time. Indeed, certain APIs may vary with
each release.
Standard MBeans are not well suited for these situations because of their
explicitly declared management interfaces. However, the Dynamic MBean is
ideal for handling such cases because it defines its management interface at
runtime in a generic fashion. Dynamic MBeans use metadata classes to describe
their management interfaces. As a developer, you decide how much or how little
of a resource to expose by describing it with the metadata objects.
In this chapter, you will manage a Jini service with a Dynamic MBean. The
MBean will be responsible for changing how the Jini service advertises itself
across a network. In addition, you will provide a Dynamic MBean super class to
provide some code reuse for generating the metadata descriptions of future
resources. After reading this chapter, you will know how to build and when to use
Dynamic MBeans.
5.1 Working with the DynamicMBean interface
JMX agents recognize Dynamic MBeans because they must implement the
javax.management.DynamicMBean interface. Recall from chapter 4 that MBeans can-
not implement both their own MBean interface and the DynamicMBean interface.
This limitation ensures that an MBean cannot be both Standard and Dynamic.
The DynamicMBean interface is a predefined, standard interface that allows MBeans
to describe their management interface at runtime. Remember that an MBean's
management interface is the group of attributes, operations, constructors, and
notifications that it exposes, enabling the management of a resource.
Because the interface to a Dynamic MBean does not change, you can use
Dynamic MBeans to shield other applications from the evolving interface of a
manageable resource. Figure 5.1 illustrates this scenario.
The best place to begin this chapter is a discussion of the javax.manage-
ment.DynamicMBean interface. The next section breaks down the interface and
examines its methods one by one.
5.2 Examining the DynamicMBean interface
To be a Dynamic MBean, a class must implement the DynamicMBean interface. As
previously mentioned, the DynamicMBean interface declares predefined methods
that let an MBean expose the interface to its manageable resource at runtime. By
Search WWH ::




Custom Search