Example usage for javax.management AttributeList toString

List of usage examples for javax.management AttributeList toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.tomcat.monitor.jmx.obj.bean.MServer.java

/**
 * Zugriff auf ausgewhlte Menge von MBean Attribute
 * /*from  w ww .  j a  va  2s . co  m*/
 * @param accessorMbean
 *           ObjectName of mbean
 * @param attributes
 *           Map von Attribute und evtl. Path Zugriffs ausdrcken (Separator
 *           ";") see accessValue
 */
public Map<String, Object> values(ObjectName accessorMbean, Map<String, String> attributes) {

    String[] attrNames = new String[attributes.size()];
    attributes.keySet().toArray(attrNames);
    AttributeList list = null;
    try {
        list = mserver.getAttributes(accessorMbean, attrNames);
    } catch (Exception e) {
        logger.error(e);
    }
    Map<String, Object> values = new HashMap<String, Object>();
    if (list != null) {
        if (logger.isDebugEnabled())
            logger.debug("access: " + accessorMbean + " attr=" + list.toString());
        for (Iterator<Object> iter = list.iterator(); iter.hasNext();) {
            Attribute attr = (Attribute) iter.next();
            Object value = attr.getValue();
            String attributePath = attributes.get(attr.getName());
            if (attributePath != null) {
                StringTokenizer st = new StringTokenizer(attributePath, ";");
                while (st.hasMoreTokens()) {
                    String path = st.nextToken();
                    Object pathvalue = accessValue(path, value);
                    values.put(attr.getName() + "." + path, pathvalue);
                }
            } else
                values.put(attr.getName(), value);
        }
    }
    return values;
}