Example usage for javax.management.modelmbean ModelMBeanInfo getMBeanDescriptor

List of usage examples for javax.management.modelmbean ModelMBeanInfo getMBeanDescriptor

Introduction

In this page you can find the example usage for javax.management.modelmbean ModelMBeanInfo getMBeanDescriptor.

Prototype

public Descriptor getMBeanDescriptor() throws MBeanException, RuntimeOperationsException;

Source Link

Document

Returns the ModelMBean's descriptor which contains MBean wide policies.

Usage

From source file:org.hyperic.hq.product.jmx.ServiceTypeFactory.java

/**
 * Returns a ServiceType containing ONLY the properties needed at construction time (the ones that guarantee uniqueness)
 * @param productName The name of the product containing the service
 * @param serverType The name of the server containing the service
 * @param serviceInfo Info about the service
 * @param objectName The {@link ObjectName} of the discovered MBean representing the service instance
 * @return A ServiceType containing ONLY the properties needed at construction time (the ones that guarantee uniqueness)
 *//*from ww w  .j a  va2  s .  com*/
public ServiceType getServiceType(String productName, ServerTypeInfo serverType, ModelMBeanInfo serviceInfo,
        ObjectName objectName) {
    String serviceTypeName = objectName.getKeyProperty("type");
    final String subType = objectName.getKeyProperty("subtype");
    if (subType != null) {
        serviceTypeName = serviceTypeName + " " + subType;
    }
    try {
        Descriptor serviceDescriptor = serviceInfo.getMBeanDescriptor();
        if ("false".equals(serviceDescriptor.getFieldValue("export"))) {
            return null;
        }
        String serviceType = (String) serviceDescriptor.getFieldValue("typeName");
        if (serviceType != null) {
            serviceTypeName = serviceType;
        }
    } catch (Exception e) {
        log.warn("Error obtaining MBeanInfo descriptor field values.  Default values will be used.  Cause: "
                + e.getMessage());
    }
    return new ServiceType(serviceTypeName, productName, new ServiceTypeInfo(
            serverType.getName() + ' ' + serviceTypeName, serviceInfo.getDescription(), serverType));
}