Java Reference
In-Depth Information
Table 7.6
Notification-level descriptor attributes (continued)
Descriptor attribute
Possible values
Description
1 to 4
Same as MBean level
visibility
XML format
Same as MBean level
presentationString
As you can see from the table, the descriptor provides attributes in order to store
the pertinent information about a notification. For example, you can specify a
generic notification severity , messageId , and messageText . The messageId is use-
ful when logging notifications: when you come back to analyze the log file, you
will be able to uniquely identify each message based on the notification id.
In addition, the log and logfile attributes specified here can override the ones
specified at the MBean level, but will apply only to this particular notification.
7.5 Model MBeans in action
These metadata classes should feel familiar to you after learning about the meta-
data classes for the Dynamic MBean. However, as noted, the Descriptor objects
enable the Model MBean's additional features. Now that we have covered each
of the metadata objects and their descriptors, we can move into some examples.
7.5.1
Building ModelMBeanInfo objects
When building an instance of the ModelMBeanInfo class, you not only have to cre-
ate arrays of metadata objects, but you also have to create corresponding Descrip-
tor instances for the metadata. If you are modeling a resource with many
operations, attributes, and notifications, you will have to write many lines of
code. One way to help with this problem is to write a class similar to the Dynamic
MBean super class you wrote in chapter 5.
Listing 7.1 shows the ModelMBeanInfoBuilder class. Like the DynamicMBeanSup-
port class in chapter 5, this class contains methods that help you build the meta-
data objects of the Model MBean's management interface. In addition, the
ModelMBeanInfoBuilder class has methods to help construct some of the Descrip-
tor instances you will need for ModelMBeanInfo objects.
Listing 7.1
ModelMBeanInfoBuilder.java
package jmxbook.ch7;
import javax.management.*;
import javax.management.modelmbean.*;
Search WWH ::




Custom Search