Java Dynamic Management Kit 5.0 Tutorial

Model MBean Metadata

The metadata of an MBean is the description of its management interface. The metadata of the model MBean is described by an instance of the ModelMBeanInfo class, which extends the MBeanInfo class.

Like all other MBeans, the metadata of a model MBean contains the list of attributes, operations, constructors, and notifications of the management interface. Model MBeans also describe their target object and their policies for accessing the target object. This information is contained in an object called a descriptor, defined by the Descriptor interface and implemented in the DescriptorSupport class.

There is one overall descriptor for a model MBean instance and one descriptor for each element of the management interface, that is for each attribute, operation, constructor, and notification. Descriptors are stored in the metadata object. As defined by the JMX specification, all classes for describing elements are extended so that they contain a descriptor. For example, the ModelMBeanAttributeInfo class extends the MBeanAttributeInfo class and defines the methods getDescriptor and setDescriptor.

A descriptor is a set of named field and value pairs. Each type of metadata element has a defined set of fields that are mandatory, and users are free to add others. The field names reflect the policies for accessing target objects, and their values determine the behavior. For example, the descriptor of an attribute contains the fields currencyTimeLimit and lastUpdatedTimeStamp that are used by the internal caching mechanism when performing a get or set operation.

In this way, model MBeans are manageable in the same way as any other MBean, but applications that are aware of model MBeans can interact with the additional features they provide. The JMX specification defines the names of all required descriptor fields for each of the metadata elements and for the overall descriptor. The field names are also documented in the Javadoc API for the ModelMBean*Info classes.

InExample 3–1 , the application defines a subroutine to build all descriptors and metadata objects needed to define the management interface of the model MBean.

Example 3–1 Defining Descriptors and MBeanInfo Objects

private void buildModelMBeanInfo(
                 ObjectName inMbeanObjectName, String inMbeanName) {
  try {

    // Create the descriptor and ModelMBeanAttributeInfo
    // for the 1st attribute
    Descriptor stateDesc = new DescriptorSupport();

    dAttributes[0] = new ModelMBeanAttributeInfo(
                             "State: state string.",

    [...] // create descriptors and ModelMBean*Info for
          // all attributes, operations, constructors
          // and notifications

    // Create the descriptor for the whole MBean
    mmbDesc = new DescriptorSupport( new String[] 
                      { ("name="+inMbeanObjectName),

    // Create the ModelMBeanInfo for the whole MBean
    private String dClassName = "TestBean";
    private String dDescription =
       "Simple implementation of a test app Bean.";

    dMBeanInfo = new ModelMBeanInfoSupport(


  } catch (Exception e) {
    echo("\nException in buildModelMBeanInfo : " +