Example usage for javax.management.modelmbean ModelMBeanInfo getDescription

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

Introduction

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

Prototype

public java.lang.String getDescription();

Source Link

Document

Returns a human readable description of the MBean.

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  va 2  s  .  c  o m*/
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));
}