Example usage for javax.management.modelmbean ModelMBeanOperationInfo getDescriptor

List of usage examples for javax.management.modelmbean ModelMBeanOperationInfo getDescriptor

Introduction

In this page you can find the example usage for javax.management.modelmbean ModelMBeanOperationInfo getDescriptor.

Prototype


public Descriptor getDescriptor() 

Source Link

Document

Returns a copy of the associated Descriptor of the ModelMBeanOperationInfo.

Usage

From source file:com.espertech.esper.metrics.jmx.CommonJMXUtil.java

private static ModelMBeanOperationInfo[] extractOperationInfo(Object object) {
    ArrayList<ModelMBeanOperationInfo> infos = new ArrayList<ModelMBeanOperationInfo>();
    for (Method m : object.getClass().getMethods()) {
        JmxOperation jmxOperation = m.getAnnotation(JmxOperation.class);
        JmxGetter jmxGetter = m.getAnnotation(JmxGetter.class);
        JmxSetter jmxSetter = m.getAnnotation(JmxSetter.class);
        if (jmxOperation != null || jmxGetter != null || jmxSetter != null) {
            String description = "";
            int visibility = 1;
            int impact = MBeanOperationInfo.UNKNOWN;
            if (jmxOperation != null) {
                description = jmxOperation.description();
                impact = jmxOperation.impact();
            } else if (jmxGetter != null) {
                description = jmxGetter.description();
                impact = MBeanOperationInfo.INFO;
                visibility = 4;/*from   w  w w  . j  av  a  2  s . c  om*/
            } else if (jmxSetter != null) {
                description = jmxSetter.description();
                impact = MBeanOperationInfo.ACTION;
                visibility = 4;
            }
            ModelMBeanOperationInfo info = new ModelMBeanOperationInfo(m.getName(), description,
                    extractParameterInfo(m), m.getReturnType().getName(), impact);
            info.getDescriptor().setField("visibility", Integer.toString(visibility));
            infos.add(info);
        }
    }

    return infos.toArray(new ModelMBeanOperationInfo[infos.size()]);
}