Search in sources :

Example 6 with OpenMBeanAttributeInfoSupport

use of javax.management.openmbean.OpenMBeanAttributeInfoSupport in project sling by apache.

the class HealthCheckMBean method createMBeanInfo.

/**
     * Create the mbean info
     */
private MBeanInfo createMBeanInfo(final ServiceReference serviceReference) {
    final List<MBeanAttributeInfo> attrs = new ArrayList<MBeanAttributeInfo>();
    // add relevant service properties
    if (serviceReference.getProperty(HealthCheck.NAME) != null) {
        attrs.add(new MBeanAttributeInfo(HealthCheck.NAME, String.class.getName(), "The name of the health check service.", true, false, false));
    }
    if (serviceReference.getProperty(HealthCheck.TAGS) != null) {
        attrs.add(new MBeanAttributeInfo(HealthCheck.TAGS, String.class.getName(), "The tags of the health check service.", true, false, false));
    }
    // add standard attributes
    attrs.add(new MBeanAttributeInfo(HC_OK_ATTRIBUTE_NAME, Boolean.class.getName(), "The health check result", true, false, false));
    attrs.add(new MBeanAttributeInfo(HC_STATUS_ATTRIBUTE_NAME, String.class.getName(), "The health check status", true, false, false));
    attrs.add(new MBeanAttributeInfo(HC_ELAPSED_TIMED_ATTRIBUTE_NAME, Long.class.getName(), "The elapsed time in miliseconds", true, false, false));
    attrs.add(new MBeanAttributeInfo(HC_FINISHED_AT_ATTRIBUTE_NAME, Date.class.getName(), "The date when the execution finished", true, false, false));
    attrs.add(new MBeanAttributeInfo(HC_TIMED_OUT_ATTRIBUTE_NAME, Boolean.class.getName(), "Indicates of the execution timed out", true, false, false));
    attrs.add(new OpenMBeanAttributeInfoSupport(HC_LOG_ATTRIBUTE_NAME, "The health check result log", LOG_TABLE_TYPE, true, false, false));
    final String description;
    if (serviceReference.getProperty(Constants.SERVICE_DESCRIPTION) != null) {
        description = serviceReference.getProperty(Constants.SERVICE_DESCRIPTION).toString();
    } else {
        description = "Health check";
    }
    return new MBeanInfo(this.getClass().getName(), description, attrs.toArray(new MBeanAttributeInfo[attrs.size()]), null, null, null);
}
Also used : MBeanInfo(javax.management.MBeanInfo) ArrayList(java.util.ArrayList) OpenMBeanAttributeInfoSupport(javax.management.openmbean.OpenMBeanAttributeInfoSupport) MBeanAttributeInfo(javax.management.MBeanAttributeInfo)

Aggregations

OpenMBeanAttributeInfoSupport (javax.management.openmbean.OpenMBeanAttributeInfoSupport)6 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)4 MBeanInfo (javax.management.MBeanInfo)3 MBeanNotificationInfo (javax.management.MBeanNotificationInfo)3 DescriptorSupport (javax.management.modelmbean.DescriptorSupport)3 OpenMBeanAttributeInfo (javax.management.openmbean.OpenMBeanAttributeInfo)3 OpenMBeanConstructorInfo (javax.management.openmbean.OpenMBeanConstructorInfo)3 OpenMBeanConstructorInfoSupport (javax.management.openmbean.OpenMBeanConstructorInfoSupport)3 OpenMBeanInfoSupport (javax.management.openmbean.OpenMBeanInfoSupport)3 OpenMBeanOperationInfo (javax.management.openmbean.OpenMBeanOperationInfo)3 OpenMBeanOperationInfoSupport (javax.management.openmbean.OpenMBeanOperationInfoSupport)3 OpenMBeanParameterInfo (javax.management.openmbean.OpenMBeanParameterInfo)3 OpenMBeanParameterInfoSupport (javax.management.openmbean.OpenMBeanParameterInfoSupport)3 ArrayList (java.util.ArrayList)2 Descriptor (javax.management.Descriptor)2 OpenMBeanInfo (javax.management.openmbean.OpenMBeanInfo)2 OpenType (javax.management.openmbean.OpenType)2 GenericArrayType (java.lang.reflect.GenericArrayType)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1