Example usage for javax.management Descriptor setField

List of usage examples for javax.management Descriptor setField

Introduction

In this page you can find the example usage for javax.management Descriptor setField.

Prototype

public void setField(String fieldName, Object fieldValue) throws RuntimeOperationsException;

Source Link

Document

Sets the value for a specific field name.

Usage

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

private static ModelMBeanAttributeInfo[] extractAttributeInfo(Object object) {
    Map<String, Method> getters = new HashMap<String, Method>();
    Map<String, Method> setters = new HashMap<String, Method>();
    Map<String, String> descriptions = new HashMap<String, String>();
    for (Method m : object.getClass().getMethods()) {
        JmxGetter getter = m.getAnnotation(JmxGetter.class);
        if (getter != null) {
            getters.put(getter.name(), m);
            descriptions.put(getter.name(), getter.description());
        }/*from  ww w .j av  a  2 s .c o m*/
        JmxSetter setter = m.getAnnotation(JmxSetter.class);
        if (setter != null) {
            setters.put(setter.name(), m);
            descriptions.put(setter.name(), setter.description());
        }
    }

    Set<String> attributes = new HashSet<String>(getters.keySet());
    attributes.addAll(setters.keySet());
    List<ModelMBeanAttributeInfo> infos = new ArrayList<ModelMBeanAttributeInfo>();
    for (String name : attributes) {
        try {
            Method getter = getters.get(name);
            Method setter = setters.get(name);
            ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(name, descriptions.get(name), getter,
                    setter);
            Descriptor descriptor = info.getDescriptor();
            if (getter != null)
                descriptor.setField("getMethod", getter.getName());
            if (setter != null)
                descriptor.setField("setMethod", setter.getName());
            info.setDescriptor(descriptor);
            infos.add(info);
        } catch (IntrospectionException e) {
            throw new RuntimeException(e);
        }
    }

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

From source file:com.oracle.weblogic.examples.spring.jmx.WLDFAwareReflectiveMBeanInfoAssembler.java

@Override
protected void populateMBeanDescriptor(Descriptor descriptor, Object managedBean, String beanKey) {
    super.populateMBeanDescriptor(descriptor, managedBean, beanKey);
    descriptor.setField(WLDF_MBEAN_TYPE_DESCPTR_KEY,
            descriptor.getFieldValue(NAME_MBEAN_DESCPTR_KEY) + MBEAN_KEYNAME_SUFFIX);
}

From source file:org.apache.geode.admin.jmx.internal.ConfigAttributeInfo.java

@Override
public ModelMBeanAttributeInfo createAttributeInfo() {
    Descriptor desc = new DescriptorSupport(
            new String[] { "name=" + this.displayName, "descriptorType=attribute", "currencyTimeLimit=-1", // always stale
                    "displayName=" + this.displayName, "getMethod=getJmxValue", "setMethod=setJmxValue" });

    Assert.assertTrue(this.config != null, "Config target object is null!");
    desc.setField("targetObject", this.config);

    ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(this.displayName, // name
            this.type, // type
            this.description, // description
            this.readable, // isReadable
            this.writeable, // isWritable
            this.is, // isIs
            desc);/*from w  w w.j  av  a2 s . c om*/

    return info;
}

From source file:org.apache.geode.admin.jmx.internal.StatisticAttributeInfo.java

@Override
public ModelMBeanAttributeInfo createAttributeInfo() {
    Descriptor desc = new DescriptorSupport(
            new String[] { "name=" + this.displayName, "descriptorType=attribute", "currencyTimeLimit=-1", // always stale
                    "displayName=" + this.displayName, "getMethod=getValue" });

    Assert.assertTrue(this.stat != null, "Stat target object is null!");
    desc.setField("targetObject", this.stat);

    ModelMBeanAttributeInfo info = new ModelMBeanAttributeInfo(this.displayName, // name
            this.type, // type
            this.description, // description
            this.readable, // isReadable
            this.writeable, // isWritable
            this.is, // isIs
            desc);/* w  ww . jav a  2s . c o  m*/

    return info;
}