Example usage for javax.management MBeanInfo MBeanInfo

List of usage examples for javax.management MBeanInfo MBeanInfo

Introduction

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

Prototype

public MBeanInfo(String className, String description, MBeanAttributeInfo[] attributes,
        MBeanConstructorInfo[] constructors, MBeanOperationInfo[] operations,
        MBeanNotificationInfo[] notifications) throws IllegalArgumentException 

Source Link

Document

Constructs an MBeanInfo .

Usage

From source file:org.cleverbus.core.throttling.JmxThrottlingConfiguration.java

@Override
public MBeanInfo getMBeanInfo() {
    Map<ThrottleScope, ThrottleProps> props = configuration.getProperties();

    List<MBeanAttributeInfo> attributes = new ArrayList<MBeanAttributeInfo>(props.size());

    // add all throttling properties
    for (Map.Entry<ThrottleScope, ThrottleProps> propsEntry : props.entrySet()) {
        String key = propsEntry.getKey().toHumanString();

        attributes.add(new MBeanAttributeInfo(key, "java.lang.String", key, true, true, false));
    }/*from   w w  w. j av a 2s.  c  o m*/

    MBeanInfo mBeanInfo = new MBeanInfo(this.getClass().getName(), "Throttling Configuration",
            attributes.toArray(new MBeanAttributeInfo[] {}), null, null, null);

    return mBeanInfo;
}

From source file:org.cleverbus.core.alerts.AlertsJmxConfiguration.java

@Override
public MBeanInfo getMBeanInfo() {
    List<AlertInfo> alerts = configuration.getAlerts(false);

    List<MBeanAttributeInfo> attributes = new ArrayList<MBeanAttributeInfo>(alerts.size());

    // add all alert properties
    for (AlertInfo alert : alerts) {
        String keyLimit = alert.getId() + LIMIT_SUFFIX;
        String keyEnable = alert.getId() + ENABLE_SUFFIX;

        attributes.add(new MBeanAttributeInfo(keyEnable, "java.lang.String", "Enable/disable alert", true, true,
                false));/*from w  ww  .j  a  v  a  2 s . com*/
        attributes.add(
                new MBeanAttributeInfo(keyLimit, "java.lang.String", "Set alert limit", true, true, false));
    }

    MBeanInfo mBeanInfo = new MBeanInfo(this.getClass().getName(), "Alerts Configuration",
            attributes.toArray(new MBeanAttributeInfo[] {}), null, null, null);

    return mBeanInfo;
}

From source file:com.betfair.cougar.core.impl.jmx.HtmlAdaptorParser.java

@Override
public MBeanInfo getMBeanInfo() {
    return new MBeanInfo(getClass().getName(), "HTML JMX request parser", null, null, null, null);
}

From source file:com.ecyrd.management.SimpleMBean.java

/**
 *  Create a new SimpleMBean/*  w ww .j  a v  a2 s.c  om*/
 *  
 *  @throws NotCompliantMBeanException {@inheritDoc}
 */
protected SimpleMBean() throws NotCompliantMBeanException {
    //
    //  Create attributes
    //
    String[] attlist = getAttributeNames();
    MBeanAttributeInfo[] attributes = null;

    if (attlist != null) {
        attributes = new MBeanAttributeInfo[attlist.length];

        for (int i = 0; i < attlist.length; i++) {
            String name = attlist[i];
            name = StringUtils.capitalize(name);
            Method getter = findGetterSetter(getClass(), "get" + name, null);

            if (getter == null)
                getter = findGetterSetter(getClass(), "is" + name, null);

            Method setter = null;

            if (getter != null) {
                setter = findGetterSetter(getClass(), "set" + name, getter.getReturnType());
            }

            //
            //  Check, if there's a description available
            //
            Method descriptor = findGetterSetter(getClass(), "get" + name + "Description", null);
            String description = "";

            if (descriptor != null) {
                try {
                    description = (String) descriptor.invoke(this, (Object[]) null);
                } catch (Exception e) {
                    description = "Exception: " + e.getMessage();
                }
            }

            MBeanAttributeInfo info;
            try {
                info = new MBeanAttributeInfo(attlist[i], description, getter, setter);
            } catch (IntrospectionException e) {
                throw new NotCompliantMBeanException(e.getMessage());
            }

            attributes[i] = info;
        }
    }

    //
    //  Create operations.
    //
    String[] oplist = getMethodNames();
    MBeanOperationInfo[] operations = new MBeanOperationInfo[oplist.length];

    Method[] methods = getClass().getMethods();

    for (int i = 0; i < oplist.length; i++) {
        Method method = null;

        for (int m = 0; m < methods.length; m++) {
            if (methods[m].getName().equals(oplist[i])) {
                method = methods[m];
            }
        }

        if (method == null) {
            throw new NotCompliantMBeanException(
                    "Class declares method " + oplist[i] + ", yet does not implement it!");
        }

        MBeanOperationInfo info = new MBeanOperationInfo(method.getName(), method);

        operations[i] = info;
    }

    //
    //  Create the actual BeanInfo instance.
    //
    MBeanConstructorInfo[] constructors = null;
    MBeanNotificationInfo[] notifications = null;

    m_beanInfo = new MBeanInfo(getClass().getName(), getDescription(), attributes, constructors, operations,
            notifications);
}

From source file:com.wakacommerce.common.cache.StatisticsServiceImpl.java

@Override
public MBeanInfo getMBeanInfo() {
    SortedSet<String> names = new TreeSet<String>();
    for (Map.Entry<String, CacheStat> stats : cacheStats.entrySet()) {
        names.add(stats.getKey());/*from w ww . j a v  a  2  s .  c  om*/
    }
    MBeanAttributeInfo[] attrs = new MBeanAttributeInfo[names.size()];
    Iterator<String> it = names.iterator();
    for (int i = 0; i < attrs.length; i++) {
        String name = it.next();
        attrs[i] = new MBeanAttributeInfo(name, "java.lang.Double", name, true, // isReadable
                false, // isWritable
                false); // isIs
    }
    attrs = ArrayUtils.add(attrs,
            new MBeanAttributeInfo("LOG_RESOLUTION", "java.lang.Double", "LOG_RESOLUTION", true, // isReadable
                    true, // isWritable
                    false) // isIs
    );
    MBeanOperationInfo[] opers = { new MBeanOperationInfo("activate", "Activate statistic logging", null, // no parameters
            "void", MBeanOperationInfo.ACTION),
            new MBeanOperationInfo("disable", "Disable statistic logging", null, // no parameters
                    "void", MBeanOperationInfo.ACTION) };
    return new MBeanInfo("com.wakacommerce:name=StatisticsService." + appName, "Runtime Statistics", attrs,
            null, // constructors
            opers, null); // notifications
}

From source file:com.cyberway.issue.crawler.settings.ComplexType.java

public MBeanInfo getMBeanInfo(Object context) {
    MBeanAttributeInfoIterator it = getAttributeInfoIterator(context);
    MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[it.size()];
    int index = 0;
    while (it.hasNext()) {
        attributes[index++] = (MBeanAttributeInfo) it.next();
    }/*from ww w .  j  a v  a  2  s . co m*/

    MBeanInfo info = new MBeanInfo(getClass().getName(), getDescription(), attributes, null, null, null);
    return info;
}

From source file:org.apache.hadoop.hbase.metrics.MetricsMBeanBase.java

protected void init() {
    List<MBeanAttributeInfo> attributes = new ArrayList<MBeanAttributeInfo>();
    MBeanInfo parentInfo = super.getMBeanInfo();
    List<String> parentAttributes = new ArrayList<String>();
    for (MBeanAttributeInfo attr : parentInfo.getAttributes()) {
        attributes.add(attr);//www.j  a v a 2 s  .  c o  m
        parentAttributes.add(attr.getName());
    }

    this.registryLength = this.registry.getMetricsList().size();

    for (MetricsBase metric : this.registry.getMetricsList()) {
        if (metric.getName() == null || parentAttributes.contains(metric.getName()))
            continue;

        // add on custom HBase metric types
        if (metric instanceof MetricsRate) {
            attributes.add(new MBeanAttributeInfo(metric.getName(), "java.lang.Float", metric.getDescription(),
                    true, false, false));
            extendedAttributes.put(metric.getName(), metric);
        } else if (metric instanceof MetricsString) {
            attributes.add(new MBeanAttributeInfo(metric.getName(), "java.lang.String", metric.getDescription(),
                    true, false, false));
            extendedAttributes.put(metric.getName(), metric);
            LOG.info("MetricsString added: " + metric.getName());
        } else if (metric instanceof MetricsHistogram) {

            String metricName = metric.getName() + MetricsHistogram.NUM_OPS_METRIC_NAME;
            attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Long", metric.getDescription(), true,
                    false, false));
            extendedAttributes.put(metricName, metric);

            metricName = metric.getName() + MetricsHistogram.MIN_METRIC_NAME;
            attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Long", metric.getDescription(), true,
                    false, false));
            extendedAttributes.put(metricName, metric);

            metricName = metric.getName() + MetricsHistogram.MAX_METRIC_NAME;
            attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Long", metric.getDescription(), true,
                    false, false));
            extendedAttributes.put(metricName, metric);

            metricName = metric.getName() + MetricsHistogram.MEAN_METRIC_NAME;
            attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Float", metric.getDescription(), true,
                    false, false));
            extendedAttributes.put(metricName, metric);

            metricName = metric.getName() + MetricsHistogram.STD_DEV_METRIC_NAME;
            attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Float", metric.getDescription(), true,
                    false, false));
            extendedAttributes.put(metricName, metric);

            metricName = metric.getName() + MetricsHistogram.MEDIAN_METRIC_NAME;
            attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Float", metric.getDescription(), true,
                    false, false));
            extendedAttributes.put(metricName, metric);

            metricName = metric.getName() + MetricsHistogram.SEVENTY_FIFTH_PERCENTILE_METRIC_NAME;
            attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Float", metric.getDescription(), true,
                    false, false));
            extendedAttributes.put(metricName, metric);

            metricName = metric.getName() + MetricsHistogram.NINETY_FIFTH_PERCENTILE_METRIC_NAME;
            attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Float", metric.getDescription(), true,
                    false, false));
            extendedAttributes.put(metricName, metric);

            metricName = metric.getName() + MetricsHistogram.NINETY_NINETH_PERCENTILE_METRIC_NAME;
            attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Float", metric.getDescription(), true,
                    false, false));
            extendedAttributes.put(metricName, metric);
        }
        // else, its probably a hadoop metric already registered. Skip it.
    }

    LOG.info("new MBeanInfo");
    this.extendedInfo = new MBeanInfo(this.getClass().getName(), this.description,
            attributes.toArray(new MBeanAttributeInfo[0]), parentInfo.getConstructors(),
            parentInfo.getOperations(), parentInfo.getNotifications());
}

From source file:org.apache.tomcat.util.mx.DynamicMBeanProxy.java

/**
 * @todo Find if the 'className' is the name of the MBean or
 *       the real class ( I suppose first )
 * @todo Read (optional) descriptions from a .properties, generated
 *       from source/*from   w w  w. j  a  v  a  2 s . com*/
 * @todo Deal with constructors
 *       
 */
public MBeanInfo getMBeanInfo() {
    if (methods == null) {
        init();
    }
    try {
        MBeanAttributeInfo attributes[] = new MBeanAttributeInfo[attMap.size()];

        Enumeration en = attMap.keys();
        int i = 0;
        while (en.hasMoreElements()) {
            String name = (String) en.nextElement();
            attributes[i++] = new MBeanAttributeInfo(name, "Attribute " + name, (Method) getAttMap.get(name),
                    (Method) setAttMap.get(name));
        }

        MBeanOperationInfo operations[] = new MBeanOperationInfo[invokeAttMap.size()];

        en = invokeAttMap.keys();
        i = 0;
        while (en.hasMoreElements()) {
            String name = (String) en.nextElement();
            Method m = (Method) invokeAttMap.get(name);
            if (m != null && name != null) {
                operations[i++] = new MBeanOperationInfo(name, m);
            } else {
                System.out.println("Null arg " + name + " " + m);
            }
        }

        if (log.isDebugEnabled())
            log.debug(real.getClass().getName() + " getMBeanInfo()");

        return new MBeanInfo(real.getClass().getName(), /* ??? */
                "MBean for " + getName(), attributes, new MBeanConstructorInfo[0], operations,
                new MBeanNotificationInfo[0]);
    } catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }
}

From source file:org.broadleafcommerce.common.cache.StatisticsServiceImpl.java

@Override
public MBeanInfo getMBeanInfo() {
    SortedSet<String> names = new TreeSet<String>();
    for (Map.Entry<String, CacheStat> stats : cacheStats.entrySet()) {
        names.add(stats.getKey());/*from   ww w .  j a  va  2s .  com*/
    }
    MBeanAttributeInfo[] attrs = new MBeanAttributeInfo[names.size()];
    Iterator<String> it = names.iterator();
    for (int i = 0; i < attrs.length; i++) {
        String name = it.next();
        attrs[i] = new MBeanAttributeInfo(name, "java.lang.Double", name, true, // isReadable
                false, // isWritable
                false); // isIs
    }
    attrs = ArrayUtils.add(attrs,
            new MBeanAttributeInfo("LOG_RESOLUTION", "java.lang.Double", "LOG_RESOLUTION", true, // isReadable
                    true, // isWritable
                    false) // isIs
    );
    MBeanOperationInfo[] opers = { new MBeanOperationInfo("activate", "Activate statistic logging", null, // no parameters
            "void", MBeanOperationInfo.ACTION),
            new MBeanOperationInfo("disable", "Disable statistic logging", null, // no parameters
                    "void", MBeanOperationInfo.ACTION) };
    return new MBeanInfo("org.broadleafcommerce:name=StatisticsService." + appName, "Runtime Statistics", attrs,
            null, // constructors
            opers, null); // notifications
}

From source file:org.echocat.jemoni.jmx.support.CacheDynamicMBean.java

@Override
public MBeanInfo getMBeanInfo() {
    return new MBeanInfo(_cache.getClass().getName(), null, getAttributes(), null, getOperations(), null);
}