Example usage for javax.management.modelmbean ModelMBeanInfo getAttributes

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

Introduction

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

Prototype

public MBeanAttributeInfo[] getAttributes();

Source Link

Document

Returns the list of attributes exposed for management.

Usage

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

private void addCustomProperties(final ServiceType serviceType, ModelMBeanInfo serviceInfo) {
    final ConfigSchema propertiesSchema = new ConfigSchema();
    final MBeanAttributeInfo[] attributes = serviceInfo.getAttributes();
    for (int i = 0; i < attributes.length; i++) {
        if (!isMetric(attributes[i])) {
            String description = attributes[i].getDescription();
            if (description == null) {
                description = "";
            }/*w ww.ja  va2s .  co  m*/
            propertiesSchema.addOption(new StringConfigOption(attributes[i].getName(), description));
            // custom properties are currently modified by adding a "set"
            // control action
            if (attributes[i].isWritable()) {
                serviceType.addControlAction("set" + attributes[i].getName());
            }
        }
    }
    serviceType.setCustomProperties(propertiesSchema);
}

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

private void addMeasurements(final ServiceType serviceType, final ProductPlugin productPlugin,
        ModelMBeanInfo serviceInfo) {
    MeasurementInfos measurements = new MeasurementInfos();
    final MBeanAttributeInfo[] attributes = serviceInfo.getAttributes();
    for (int i = 0; i < attributes.length; i++) {
        if (isMetric(attributes[i])) {
            measurements.addMeasurementInfo(
                    createMeasurementInfo(serviceType, productPlugin, (ModelMBeanAttributeInfo) attributes[i]));
        }/*from   www . ja va 2s.co  m*/
    }
    measurements.addMeasurementInfo(createAvailabilityMeasurement(serviceType, productPlugin));
    serviceType.setMeasurements(measurements);
}

From source file:org.springframework.jmx.export.MBeanExporter.java

/**
 * Gets the <code>ModelMBeanInfo</code> for the bean with the supplied key
 * and of the supplied type.//from w ww. j  av a2 s  .  co m
 */
private ModelMBeanInfo getMBeanInfo(Object managedBean, String beanKey) throws JMException {
    ModelMBeanInfo info = this.assembler.getMBeanInfo(managedBean, beanKey);
    if (logger.isWarnEnabled() && ObjectUtils.isEmpty(info.getAttributes())
            && ObjectUtils.isEmpty(info.getOperations())) {
        logger.warn("Bean with key [" + beanKey
                + "] has been registed as an MBean but has no exposed attributes or operations");
    }
    return info;
}