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);
}
Aggregations