JMXAccessorQueryTask.java 文件源码

java
阅读 15 收藏 0 点赞 0 评论 0

项目:apache-tomcat-7.0.73-with-comment 作者:
/**
 * Call Mbean server for some mbeans with same domain, attributes.
 *  with <em>attributebinding=true</em> you can save all attributes from all found objects
 * as your ant properties
 * @param jmxServerConnection
 * @param qry
 * @return The query result
 */
protected String jmxQuery(MBeanServerConnection jmxServerConnection,
        String qry) {
    String isError = null;
    Set<ObjectName> names = null;
    String resultproperty = getResultproperty();
    try {
        names = jmxServerConnection.queryNames(new ObjectName(qry), null);
        if (resultproperty != null) {
            setProperty(resultproperty + ".Length",Integer.toString(names.size()));
        }
    } catch (Exception e) {
        if (isEcho())
            handleErrorOutput(e.getMessage());
        return "Can't query mbeans " + qry;
    }

    if (resultproperty != null) {
        Iterator<ObjectName> it = names.iterator();
        int oindex = 0;
        String pname = null;
        while (it.hasNext()) {
            ObjectName oname = it.next();
            pname = resultproperty + "." + Integer.toString(oindex) + ".";
            oindex++;
                setProperty(pname + "Name", oname.toString());
                if (isAttributebinding()) {
                    bindAttributes(jmxServerConnection, resultproperty, pname, oname);

                }
            }
    }
    return isError;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号