下面列出了怎么用javax.management.Descriptor的API类实例代码及写法,或者点击链接到github查看源代码。
private static void check(Object x, Descriptor d, Descriptor expect) {
String fail = null;
try {
Descriptor u = ImmutableDescriptor.union(d, expect);
if (!u.equals(d))
fail = "should contain " + expect + "; is " + d;
} catch (IllegalArgumentException e) {
fail = e.getMessage();
}
if (fail == null) {
System.out.println("OK: " + x);
} else {
failed = "NOT OK: Incorrect descriptor for: " + x;
System.out.println(failed);
System.out.println("..." + fail);
}
}
/**
* Returns a copy of the associated Descriptor for the
* ModelMBeanNotificationInfo.
*
* @return Descriptor associated with the
* ModelMBeanNotificationInfo object.
*
* @see #setDescriptor
**/
public Descriptor getDescriptor() {
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER,
ModelMBeanNotificationInfo.class.getName(),
"getDescriptor()", "Entry");
}
if (notificationDescriptor == null) {
// Dead code. Should never happen.
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER,
ModelMBeanNotificationInfo.class.getName(),
"getDescriptor()", "Descriptor value is null, " +
"setting descriptor to default values");
}
notificationDescriptor = validDescriptor(null);
}
return((Descriptor)notificationDescriptor.clone());
}
/**
* Creates a default ModelMBeanNotificationInfo for ATTRIBUTE_CHANGE
* notification. (bug 4744667)
**/
private static final
ModelMBeanNotificationInfo makeAttributeChangeInfo() {
final Descriptor attributeDescriptor = new DescriptorSupport(new
String[] {
"name=ATTRIBUTE_CHANGE",
"descriptorType=notification",
"log=T",
"severity=6",
"displayName=jmx.attribute.change"});
return new ModelMBeanNotificationInfo(new
String[] {"jmx.attribute.change"},
"ATTRIBUTE_CHANGE",
"Signifies that an observed MBean attribute value has changed",
attributeDescriptor );
}
/**
* Constructs a new ModelMBeanAttributeInfo object from this
* ModelMBeanAttributeInfo Object. A default descriptor will
* be created.
*
* @param inInfo the ModelMBeanAttributeInfo to be duplicated
*/
public ModelMBeanAttributeInfo(ModelMBeanAttributeInfo inInfo)
{
super(inInfo.getName(),
inInfo.getType(),
inInfo.getDescription(),
inInfo.isReadable(),
inInfo.isWritable(),
inInfo.isIs());
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER,
ModelMBeanAttributeInfo.class.getName(),
"ModelMBeanAttributeInfo(ModelMBeanAttributeInfo)",
"Entry");
}
Descriptor newDesc = inInfo.getDescriptor();
attrDescriptor = validDescriptor(newDesc);
}
/**
* Returns a copy of the associated Descriptor for the
* ModelMBeanNotificationInfo.
*
* @return Descriptor associated with the
* ModelMBeanNotificationInfo object.
*
* @see #setDescriptor
**/
public Descriptor getDescriptor() {
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER,
ModelMBeanNotificationInfo.class.getName(),
"getDescriptor()", "Entry");
}
if (notificationDescriptor == null) {
// Dead code. Should never happen.
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER,
ModelMBeanNotificationInfo.class.getName(),
"getDescriptor()", "Descriptor value is null, " +
"setting descriptor to default values");
}
notificationDescriptor = validDescriptor(null);
}
return((Descriptor)notificationDescriptor.clone());
}
/**
* Creates a default ModelMBeanNotificationInfo for ATTRIBUTE_CHANGE
* notification. (bug 4744667)
**/
private static final
ModelMBeanNotificationInfo makeAttributeChangeInfo() {
final Descriptor attributeDescriptor = new DescriptorSupport(new
String[] {
"name=ATTRIBUTE_CHANGE",
"descriptorType=notification",
"log=T",
"severity=6",
"displayName=jmx.attribute.change"});
return new ModelMBeanNotificationInfo(new
String[] {"jmx.attribute.change"},
"ATTRIBUTE_CHANGE",
"Signifies that an observed MBean attribute value has changed",
attributeDescriptor );
}
private <T> OpenMBeanParameterInfoSupport(String name,
String description,
OpenType<T> openType,
T defaultValue,
T[] legalValues,
Comparable<T> minValue,
Comparable<T> maxValue)
throws OpenDataException {
super(name,
(openType == null) ? null : openType.getClassName(),
description,
makeDescriptor(openType,
defaultValue, legalValues, minValue, maxValue));
this.openType = openType;
Descriptor d = getDescriptor();
this.defaultValue = defaultValue;
this.minValue = minValue;
this.maxValue = maxValue;
// We already converted the array into an unmodifiable Set
// in the descriptor.
this.legalValues = (Set<?>) d.getFieldValue("legalValues");
check(this);
}
/**
* Creates a default ModelMBeanNotificationInfo for GENERIC
* notification. (bug 4744667)
**/
private static final ModelMBeanNotificationInfo makeGenericInfo() {
final Descriptor genericDescriptor = new DescriptorSupport( new
String[] {
"name=GENERIC",
"descriptorType=notification",
"log=T",
"severity=6",
"displayName=jmx.modelmbean.generic"} );
return new ModelMBeanNotificationInfo(new
String[] {"jmx.modelmbean.generic"},
"GENERIC",
"A text notification has been issued by the managed resource",
genericDescriptor);
}
public void setDescriptors(Descriptor[] inDescriptors)
throws MBeanException, RuntimeOperationsException {
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
}
if (inDescriptors==null) {
// throw RuntimeOperationsException - invalid descriptor
throw new RuntimeOperationsException(
new IllegalArgumentException("Descriptor list is invalid"),
"Exception occurred trying to set the descriptors " +
"of the MBeanInfo");
}
if (inDescriptors.length == 0) { // empty list, no-op
return;
}
for (int j=0; j < inDescriptors.length; j++) {
setDescriptor(inDescriptors[j],null);
}
if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
MODELMBEAN_LOGGER.log(Level.TRACE, "Exit");
}
}
private static void check(Object x, Descriptor d, Descriptor expect) {
String fail = null;
try {
Descriptor u = ImmutableDescriptor.union(d, expect);
if (!u.equals(d))
fail = "should contain " + expect + "; is " + d;
} catch (IllegalArgumentException e) {
fail = e.getMessage();
}
if (fail == null) {
System.out.println("OK: " + x);
} else {
failed = "NOT OK: Incorrect descriptor for: " + x;
System.out.println(failed);
System.out.println("..." + fail);
}
}
/**
* Creates a default ModelMBeanNotificationInfo for GENERIC
* notification. (bug 4744667)
**/
private static final ModelMBeanNotificationInfo makeGenericInfo() {
final Descriptor genericDescriptor = new DescriptorSupport( new
String[] {
"name=GENERIC",
"descriptorType=notification",
"log=T",
"severity=6",
"displayName=jmx.modelmbean.generic"} );
return new ModelMBeanNotificationInfo(new
String[] {"jmx.modelmbean.generic"},
"GENERIC",
"A text notification has been issued by the managed resource",
genericDescriptor);
}
private static boolean test(Object mbean, boolean expectImmutable)
throws Exception {
MBeanServer mbs = MBeanServerFactory.newMBeanServer();
ObjectName on = new ObjectName("a:b=c");
mbs.registerMBean(mbean, on);
MBeanInfo mbi = mbs.getMBeanInfo(on);
Descriptor d = mbi.getDescriptor();
String immutableValue = (String) d.getFieldValue("immutableInfo");
boolean immutable = ("true".equals(immutableValue));
if (immutable != expectImmutable) {
System.out.println("FAILED: " + mbean.getClass().getName() +
" -> " + immutableValue);
return false;
} else {
System.out.println("OK: " + mbean.getClass().getName());
return true;
}
}
/**
* Apply the given JMX "currencyTimeLimit" value to the given descriptor.
* <p>The default implementation sets a value {@code >0} as-is (as number of cache seconds),
* turns a value of {@code 0} into {@code Integer.MAX_VALUE} ("always cache")
* and sets the "defaultCurrencyTimeLimit" (if any, indicating "never cache") in case of
* a value {@code <0}. This follows the recommendation in the JMX 1.2 specification.
* @param desc the JMX attribute or operation descriptor
* @param currencyTimeLimit the "currencyTimeLimit" value to apply
* @see #setDefaultCurrencyTimeLimit(Integer)
* @see #applyDefaultCurrencyTimeLimit(javax.management.Descriptor)
*/
protected void applyCurrencyTimeLimit(Descriptor desc, int currencyTimeLimit) {
if (currencyTimeLimit > 0) {
// number of cache seconds
desc.setField(FIELD_CURRENCY_TIME_LIMIT, Integer.toString(currencyTimeLimit));
}
else if (currencyTimeLimit == 0) {
// "always cache"
desc.setField(FIELD_CURRENCY_TIME_LIMIT, Integer.toString(Integer.MAX_VALUE));
}
else {
// "never cache"
applyDefaultCurrencyTimeLimit(desc);
}
}
static boolean equal(OpenMBeanParameterInfo x1, OpenMBeanParameterInfo x2) {
if (x1 instanceof DescriptorRead) {
if (!(x2 instanceof DescriptorRead))
return false;
Descriptor d1 = ((DescriptorRead) x1).getDescriptor();
Descriptor d2 = ((DescriptorRead) x2).getDescriptor();
if (!d1.equals(d2))
return false;
} else if (x2 instanceof DescriptorRead)
return false;
return
x1.getName().equals(x2.getName()) &&
x1.getOpenType().equals(x2.getOpenType()) &&
(x1.hasDefaultValue() ?
x1.getDefaultValue().equals(x2.getDefaultValue()) :
!x2.hasDefaultValue()) &&
(x1.hasMinValue() ?
x1.getMinValue().equals(x2.getMinValue()) :
!x2.hasMinValue()) &&
(x1.hasMaxValue() ?
x1.getMaxValue().equals(x2.getMaxValue()) :
!x2.hasMaxValue()) &&
(x1.hasLegalValues() ?
x1.getLegalValues().equals(x2.getLegalValues()) :
!x2.hasLegalValues());
}
private <T> OpenMBeanAttributeInfoSupport(String name,
String description,
OpenType<T> openType,
boolean isReadable,
boolean isWritable,
boolean isIs,
T defaultValue,
T[] legalValues,
Comparable<T> minValue,
Comparable<T> maxValue)
throws OpenDataException {
super(name,
(openType==null) ? null : openType.getClassName(),
description,
isReadable,
isWritable,
isIs,
makeDescriptor(openType,
defaultValue, legalValues, minValue, maxValue));
this.openType = openType;
Descriptor d = getDescriptor();
this.defaultValue = defaultValue;
this.minValue = minValue;
this.maxValue = maxValue;
// We already converted the array into an unmodifiable Set
// in the descriptor.
this.legalValues = (Set<?>) d.getFieldValue("legalValues");
check(this);
}
/**
* Gets a copy of the associated Descriptor for the
* ModelMBeanAttributeInfo.
*
* @return Descriptor associated with the
* ModelMBeanAttributeInfo object.
*
* @see #setDescriptor
*/
public Descriptor getDescriptor() {
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER,
ModelMBeanAttributeInfo.class.getName(),
"getDescriptor()", "Entry");
}
if (attrDescriptor == null) {
attrDescriptor = validDescriptor(null);
}
return((Descriptor)attrDescriptor.clone());
}
/**
* Constructs a ModelMBeanInfoSupport which is a duplicate of the given
* ModelMBeanInfo. The returned object is a shallow copy of the given
* object. Neither the Descriptor nor the contained arrays
* ({@code ModelMBeanAttributeInfo[]} etc) are cloned. This method is
* chiefly of interest to modify the Descriptor of the returned instance
* via {@link #setDescriptor setDescriptor} without affecting the
* Descriptor of the original object.
*
* @param mbi the ModelMBeanInfo instance from which the ModelMBeanInfo
* being created is initialized.
*/
public ModelMBeanInfoSupport(ModelMBeanInfo mbi) {
super(mbi.getClassName(),
mbi.getDescription(),
mbi.getAttributes(),
mbi.getConstructors(),
mbi.getOperations(),
mbi.getNotifications());
modelMBeanAttributes = mbi.getAttributes();
modelMBeanConstructors = mbi.getConstructors();
modelMBeanOperations = mbi.getOperations();
modelMBeanNotifications = mbi.getNotifications();
try {
Descriptor mbeandescriptor = mbi.getMBeanDescriptor();
modelMBeanDescriptor = validDescriptor(mbeandescriptor);
} catch (MBeanException mbe) {
modelMBeanDescriptor = validDescriptor(null);
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER,
ModelMBeanInfoSupport.class.getName(),
"ModelMBeanInfo(ModelMBeanInfo)",
"Could not get a valid modelMBeanDescriptor, " +
"setting a default Descriptor");
}
}
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER,
ModelMBeanInfoSupport.class.getName(),
"ModelMBeanInfo(ModelMBeanInfo)", "Exit");
}
}
private static Descriptor typeDescriptor(OpenType<?> openType,
Type originalType) {
return new ImmutableDescriptor(
new String[] {"openType",
"originalType"},
new Object[] {openType,
originalTypeString(originalType)});
}
private void cacheResult(ModelMBeanOperationInfo opInfo,
Descriptor opDescr, Object result)
throws MBeanException {
Descriptor mmbDesc =
modelMBeanInfo.getMBeanDescriptor();
Object objctl =
opDescr.getFieldValue("currencyTimeLimit");
String ctl;
if (objctl != null) {
ctl = objctl.toString();
} else {
ctl = null;
}
if ((ctl == null) && (mmbDesc != null)) {
objctl =
mmbDesc.getFieldValue("currencyTimeLimit");
if (objctl != null) {
ctl = objctl.toString();
} else {
ctl = null;
}
}
if ((ctl != null) && !(ctl.equals("-1"))) {
opDescr.setField("value", result);
opDescr.setField("lastUpdatedTimeStamp",
String.valueOf((new Date()).getTime()));
modelMBeanInfo.setDescriptor(opDescr,
"operation");
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER,
RequiredModelMBean.class.getName(),
"invoke(String,Object[],Object[])",
"new descriptor is " + opDescr);
}
}
}
private <T> OpenMBeanAttributeInfoSupport(String name,
String description,
OpenType<T> openType,
boolean isReadable,
boolean isWritable,
boolean isIs,
T defaultValue,
T[] legalValues,
Comparable<T> minValue,
Comparable<T> maxValue)
throws OpenDataException {
super(name,
(openType==null) ? null : openType.getClassName(),
description,
isReadable,
isWritable,
isIs,
makeDescriptor(openType,
defaultValue, legalValues, minValue, maxValue));
this.openType = openType;
Descriptor d = getDescriptor();
this.defaultValue = defaultValue;
this.minValue = minValue;
this.maxValue = maxValue;
// We already converted the array into an unmodifiable Set
// in the descriptor.
this.legalValues = (Set<?>) d.getFieldValue("legalValues");
check(this);
}
public static void main(String[] args) throws Exception {
System.out.println("Test that ImmutableDescriptor.EMPTY_DESCRIPTOR " +
"deserializes identically");
if (serialize(ImmutableDescriptor.EMPTY_DESCRIPTOR) !=
ImmutableDescriptor.EMPTY_DESCRIPTOR) {
throw new Exception("ImmutableDescriptor.EMPTY_DESCRIPTOR did not " +
"deserialize identically");
}
System.out.println("...OK");
System.out.println("Test that serialization preserves case and " +
"that deserialized object is case-insensitive");
Descriptor d = new ImmutableDescriptor("a=aval", "B=Bval", "cC=cCval");
Descriptor d1 = serialize(d);
Set<String> keys = new HashSet(Arrays.asList(d1.getFieldNames()));
if (keys.size() != 3 ||
!keys.containsAll(Arrays.asList("a", "B", "cC"))) {
throw new Exception("Keys don't match: " + keys);
}
for (String key : keys) {
String value = (String) d.getFieldValue(key);
for (String t :
Arrays.asList(key, key.toLowerCase(), key.toUpperCase())) {
String tvalue = (String) d1.getFieldValue(t);
if (!tvalue.equals(value)) {
throw new Exception("Value of " + key + " for " +
"deserialized object does not match: " +
tvalue + " should be " + value);
}
}
}
System.out.println("...OK");
}
static <T> Descriptor makeDescriptor(OpenType<T> openType,
T defaultValue,
Set<T> legalValues,
Comparable<T> minValue,
Comparable<T> maxValue) {
T[] legals;
if (legalValues == null)
legals = null;
else {
legals = cast(new Object[legalValues.size()]);
legalValues.toArray(legals);
}
return makeDescriptor(openType, defaultValue, legals, minValue, maxValue);
}
static <T> Comparable<?> comparableValueFrom(Descriptor d, String name,
OpenType<T> openType) {
T t = valueFrom(d, name, openType);
if (t == null || t instanceof Comparable<?>)
return (Comparable<?>) t;
final String msg =
"Descriptor field " + name + " with value " + t +
" is not Comparable";
throw new IllegalArgumentException(msg);
}
/**
* Deserializes a {@link ModelMBeanInfoSupport} from an {@link ObjectInputStream}.
*/
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
if (compat) {
// Read an object serialized in the old serial form
//
ObjectInputStream.GetField fields = in.readFields();
modelMBeanDescriptor =
(Descriptor) fields.get("modelMBeanDescriptor", null);
if (fields.defaulted("modelMBeanDescriptor")) {
throw new NullPointerException("modelMBeanDescriptor");
}
modelMBeanAttributes =
(MBeanAttributeInfo[]) fields.get("mmbAttributes", null);
if (fields.defaulted("mmbAttributes")) {
throw new NullPointerException("mmbAttributes");
}
modelMBeanConstructors =
(MBeanConstructorInfo[]) fields.get("mmbConstructors", null);
if (fields.defaulted("mmbConstructors")) {
throw new NullPointerException("mmbConstructors");
}
modelMBeanNotifications =
(MBeanNotificationInfo[]) fields.get("mmbNotifications", null);
if (fields.defaulted("mmbNotifications")) {
throw new NullPointerException("mmbNotifications");
}
modelMBeanOperations =
(MBeanOperationInfo[]) fields.get("mmbOperations", null);
if (fields.defaulted("mmbOperations")) {
throw new NullPointerException("mmbOperations");
}
} else {
// Read an object serialized in the new serial form
//
in.defaultReadObject();
}
}
@Override
Descriptor getBasicMBeanDescriptor() {
/* We don't bother saying mxbean=false, and we can't know whether
the info is immutable until we know whether the MBean class
(not interface) is a NotificationBroadcaster. */
return ImmutableDescriptor.EMPTY_DESCRIPTOR;
}
/**
* Constructs an {@code OpenMBeanParameterInfoSupport} instance,
* which describes the parameter used in one or more operations or
* constructors of a class of open MBeans, with the specified
* {@code name}, {@code openType}, {@code description},
* and {@code descriptor}.
*
* <p>The {@code descriptor} can contain entries that will define
* the values returned by certain methods of this class, as
* explained in the <a href="package-summary.html#constraints">
* package description</a>.
*
* @param name cannot be a null or empty string.
*
* @param description cannot be a null or empty string.
*
* @param openType cannot be null.
*
* @param descriptor The descriptor for the parameter. This may be null
* which is equivalent to an empty descriptor.
*
* @throws IllegalArgumentException if {@code name} or {@code
* description} are null or empty string, or {@code openType} is
* null, or the descriptor entries are invalid as described in the
* <a href="package-summary.html#constraints">package
* description</a>.
*
* @since 1.6
*/
public OpenMBeanParameterInfoSupport(String name,
String description,
OpenType<?> openType,
Descriptor descriptor) {
// Construct parent's state
//
super(name,
(openType==null) ? null : openType.getClassName(),
description,
ImmutableDescriptor.union(descriptor,(openType==null)?null:
openType.getDescriptor()));
// Initialize this instance's specific state
//
this.openType = openType;
descriptor = getDescriptor(); // replace null by empty
this.defaultValue = valueFrom(descriptor, "defaultValue", openType);
this.legalValues = valuesFrom(descriptor, "legalValues", openType);
this.minValue = comparableValueFrom(descriptor, "minValue", openType);
this.maxValue = comparableValueFrom(descriptor, "maxValue", openType);
try {
check(this);
} catch (OpenDataException e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
}
static boolean equal(OpenMBeanParameterInfo x1, OpenMBeanParameterInfo x2) {
if (x1 instanceof DescriptorRead) {
if (!(x2 instanceof DescriptorRead))
return false;
Descriptor d1 = ((DescriptorRead) x1).getDescriptor();
Descriptor d2 = ((DescriptorRead) x2).getDescriptor();
if (!d1.equals(d2))
return false;
} else if (x2 instanceof DescriptorRead)
return false;
return
x1.getName().equals(x2.getName()) &&
x1.getOpenType().equals(x2.getOpenType()) &&
(x1.hasDefaultValue() ?
x1.getDefaultValue().equals(x2.getDefaultValue()) :
!x2.hasDefaultValue()) &&
(x1.hasMinValue() ?
x1.getMinValue().equals(x2.getMinValue()) :
!x2.hasMinValue()) &&
(x1.hasMaxValue() ?
x1.getMaxValue().equals(x2.getMaxValue()) :
!x2.hasMaxValue()) &&
(x1.hasLegalValues() ?
x1.getLegalValues().equals(x2.getLegalValues()) :
!x2.hasLegalValues());
}
public void printModelMBeanDescriptors(ObjectName mbeanObjectName)
{
sleep(1000);
Descriptor[] dArray = new DescriptorSupport[0];
try
{
dArray = (Descriptor[]) (server.invoke(mbeanObjectName, "getDescriptors",
new Object[] {},
new String[] {}));
if (dArray == null)
{
echo("\nDescriptor list is null!");
}
} catch (Exception e)
{
echo("\t!!! Could not get descriptors for mbeanName ");
e.printStackTrace();
return;
}
echo("Descriptors: (");
echo(dArray.length + ")\n");
for (int i=0; i < dArray.length; i++)
{
echo("\n**Descriptor***********************");
String[] dlfields = ((Descriptor) dArray[i]).getFields();
for (int j=0; j < dlfields.length; j++)
{
echo(dlfields[j] + "\n");
}
}
}
public void setDescriptors(Descriptor[] inDescriptors)
throws MBeanException, RuntimeOperationsException {
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER,
ModelMBeanInfoSupport.class.getName(),
"setDescriptors(Descriptor[])", "Entry");
}
if (inDescriptors==null) {
// throw RuntimeOperationsException - invalid descriptor
throw new RuntimeOperationsException(
new IllegalArgumentException("Descriptor list is invalid"),
"Exception occurred trying to set the descriptors " +
"of the MBeanInfo");
}
if (inDescriptors.length == 0) { // empty list, no-op
return;
}
for (int j=0; j < inDescriptors.length; j++) {
setDescriptor(inDescriptors[j],null);
}
if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
MODELMBEAN_LOGGER.logp(Level.FINER,
ModelMBeanInfoSupport.class.getName(),
"setDescriptors(Descriptor[])", "Exit");
}
}
/** Make an MBeanInfo based on the attributes and operations
* found in the interface. */
MBeanInfo makeMBeanInfo(Class<?> mbeanInterface,
String description) {
final MBeanAttributeInfo[] attrArray =
attrs.toArray(new MBeanAttributeInfo[0]);
final MBeanOperationInfo[] opArray =
ops.toArray(new MBeanOperationInfo[0]);
final String interfaceClassName =
"interfaceClassName=" + mbeanInterface.getName();
final Descriptor classNameDescriptor =
new ImmutableDescriptor(interfaceClassName);
final Descriptor mbeanDescriptor = getBasicMBeanDescriptor();
final Descriptor annotatedDescriptor =
Introspector.descriptorForElement(mbeanInterface);
final Descriptor descriptor =
DescriptorCache.getInstance().union(
classNameDescriptor,
mbeanDescriptor,
annotatedDescriptor);
return new MBeanInfo(mbeanInterface.getName(),
description,
attrArray,
null,
opArray,
null,
descriptor);
}