JmxDumpUtil.java 文件源码

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

项目:alfresco-repository 作者:
/**
 * Dumps a local or remote MBeanServer's entire object tree for support purposes. Nested arrays and CompositeData
 * objects in MBean attribute values are handled.
 * 
 * @param connection
 *            the server connection (or server itself)
 * @param out
 *            PrintWriter to write the output to
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
public static void dumpConnection(MBeanServerConnection connection, PrintWriter out) throws IOException
{
    JmxDumpUtil.showStartBanner(out);

    // Get all the object names
    Set<ObjectName> objectNames = connection.queryNames(null, null);

    // Sort the names (don't assume ObjectName implements Comparable in JDK 1.5)
    Set<ObjectName> newObjectNames = new TreeSet<ObjectName>(new Comparator<ObjectName>()
    {
        public int compare(ObjectName o1, ObjectName o2)
        {
            return o1.toString().compareTo(o2.toString());
        }
    });
    newObjectNames.addAll(objectNames);
    objectNames = newObjectNames;


    // Dump each MBean
    for (ObjectName objectName : objectNames)
    {
        try
        {
            printMBeanInfo(connection, objectName, out);
        }
        catch (JMException e)
        {
            // Sometimes beans can disappear while we are examining them
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号