From 5228c5b01c8cf9221e60efa8385f7aa38e77f2da Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Thu, 3 Nov 2011 16:09:12 +0000 Subject: [PATCH] ALF-10482: add timestamp to JMX dumps. I had fixed this in the command line tool, but didn't realise that there was a Share-based interface too. Moved the fix to the common utils class. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31691 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/repo/management/JmxDumpUtil.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/source/java/org/alfresco/repo/management/JmxDumpUtil.java b/source/java/org/alfresco/repo/management/JmxDumpUtil.java index 69b212fd0c..a7fd066eee 100644 --- a/source/java/org/alfresco/repo/management/JmxDumpUtil.java +++ b/source/java/org/alfresco/repo/management/JmxDumpUtil.java @@ -21,7 +21,10 @@ package org.alfresco.repo.management; import java.io.IOException; import java.io.PrintWriter; import java.lang.reflect.Array; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.Comparator; +import java.util.Date; import java.util.Map; import java.util.Set; import java.util.TreeMap; @@ -34,6 +37,7 @@ import javax.management.MBeanServerConnection; import javax.management.ObjectName; import javax.management.openmbean.CompositeData; + /** * A utility class providing a method to dump a local or remote MBeanServer's entire object tree for support purposes. * Nested arrays and CompositeData objects in MBean attribute values are handled. @@ -67,6 +71,8 @@ public class JmxDumpUtil */ public static void dumpConnection(MBeanServerConnection connection, PrintWriter out) throws IOException { + JmxDumpUtil.showStartBanner(out); + // Get all the object names Set objectNames = connection.queryNames(null, null); @@ -81,6 +87,7 @@ public class JmxDumpUtil newObjectNames.addAll(objectNames); objectNames = newObjectNames; + // Dump each MBean for (ObjectName objectName : objectNames) { @@ -351,4 +358,14 @@ public class JmxDumpUtil return value.toString().length(); } } + + /** + * Show a message stating the JmxDumper has been started, with the current date and time. + */ + private static void showStartBanner(PrintWriter out) + { + DateFormat df = SimpleDateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG); + out.println(JmxDumpUtil.class.getSimpleName() + " started: " + df.format(new Date())); + out.println(); + } }