Example usage for javax.management.modelmbean ModelMBeanAttributeInfo isIs

List of usage examples for javax.management.modelmbean ModelMBeanAttributeInfo isIs

Introduction

In this page you can find the example usage for javax.management.modelmbean ModelMBeanAttributeInfo isIs.

Prototype

public boolean isIs() 

Source Link

Document

Indicates if this attribute has an "is" getter.

Usage

From source file:net.lightbody.bmp.proxy.jetty.util.jmx.ModelMBeanImpl.java

/** Define an attribute.
 * Explicit definition of an attribute. Reflection is used to
 * locate the actual getter and setter methods.
 * @param attrInfo ModelMBeanAttributeInfo.
 *///from   ww w.  j  a va 2s. c om
public synchronized void defineAttribute(ModelMBeanAttributeInfo attrInfo) {
    if (_object == null)
        throw new IllegalStateException("No Object");

    _dirty = true;

    String name = attrInfo.getName();
    String uName = name.substring(0, 1).toUpperCase() + name.substring(1);
    Class oClass = _object.getClass();

    try {
        Class type = TypeUtil.fromName(attrInfo.getType());
        if (type == null)
            type = Thread.currentThread().getContextClassLoader().loadClass(attrInfo.getType());

        Method getter = null;
        Method setter = null;

        if (attrInfo.isReadable())
            getter = oClass.getMethod((attrInfo.isIs() ? "is" : "get") + uName, (java.lang.Class[]) null);

        if (attrInfo.isWritable())
            setter = oClass.getMethod("set" + uName, new Class[] { type });

        _getter.put(name, getter);
        _setter.put(name, setter);
        _attributes.add(attrInfo);
    } catch (Exception e) {
        log.warn(LogSupport.EXCEPTION, e);
        throw new IllegalArgumentException(e.toString());
    }
}