Java Reference
In-Depth Information
management application works with an MBeanInfo object. However, in the case
of the Model MBean, its MBeanInfo object is actually the subclass of MBeanInfo :
the ModelMBeanInfoSupport class. Management applications that know which
MBeans are Model MBeans can then use the more specific MBeanInfo class to
take advantage of the advanced capabilities of the Model MBean.
7.3.3
Registering for notifications
The second interface extended by the ModelMBean interface is ModelMBeanNotifi-
cationBroadcaster . This interface declares the notification-handling methods
for Model MBeans. The methods declared by this interface register and remove
notification listeners for Model MBean notifications. Model MBeans (based on
their configuration) emit AttributeChangeNotifications notifications and
generic informational notifications. In addition, the interface declares two send-
Notification() methods that Model MBeans must implement. One of the meth-
ods is the regular sendNotification() method that you have seen in the past,
and the other is an overloaded version that only accepts a String message to
send out in a generic notification. When a generic notification is sent, its type is
jmx.modelmbean.general . There is no need to list these methods here; you will
see them in use later.
7.3.4
MBean persistence
The final interface extended by the ModelMBean interface is PersistentMBean .
This interface declares two methods that initiate the persistence mechanism of a
Model MBean: load() and store() . These methods are invoked based on the
configuration of the Model MBean stored in its ModelMBeanInfo object. The
load() method attempts to load an MBean state from a location specified in its
ModelMBeanInfo instance. Alternatively, the store() method persists the current
state of the MBean to a location specified in its ModelMBeanInfo instance. The
Model MBean implementation in the Sun RI uses Java object serialization to a
flat file for persistence.
7.4 Understanding the Model MBean metadata
As you just read, Model MBeans are Dynamic MBeans, and their management
interfaces are created at runtime. The previous section showed that you can
acquire and interact with the management interface the exact way you would a
Dynamic MBean. (Look back at chapter 5 for more about Dynamic MBeans.)
However, as stated earlier, if you know you are dealing with a Model MBean, you
Search WWH ::




Custom Search