Java Reference
In-Depth Information
desc.setField("descriptorType","mbean");
if( displayName != null )
desc.setField("displayName", displayName );
if( persistLocation != null )
desc.setField("persistLocation",
persistLocation );
if( persistName != null )
desc.setField("persistName", persistName );
if( log != null )
desc.setField("log", log );
if( persistPolicy != null )
desc.setField("persistPolicy", persistPolicy );
if( persistPeriod != null )
desc.setField("persistPeriod", persistPeriod );
if( logFile != null )
desc.setField("logFile", logFile );
return desc;
}
private void copyInto( Object[] array, Hashtable table )
{
Vector temp = new Vector( table.values() );
temp.copyInto( array );
}
}
No fancy code exists in this class. The ModelMBeanInfoBuilder class serves as a
way to avoid repeating lines of code when creating ModelMBeanInfo objects. It
contains methods for creating the metadata objects for attributes, operations,
constructors, and notifications. In addition, the class contains methods for creat-
ing the Descriptor objects for the MBean, attribute, and operation metadata
classes. The descriptor methods don't take all the predefined field names, but
you can add more as needed to the method, or you can add them after the new
Descriptor object is returned.
For a demonstration of using this utility class, look at listing 7.2. It shows the
ModeledClass class, which defines a simple class with two methods. ModeledClass
contains a main() method that you will use to test a Model MBean. The main()
method uses the ModelMBeanInfoBuilder class to create a management interface
for a Model MBean.
Listing 7.2
ModeledClass.java
package jmxbook.ch7;
import javax.management.*;
Search WWH ::




Custom Search