Author: rajith
Date: Thu Sep  6 14:41:29 2012
New Revision: 1381625

URL: http://svn.apache.org/viewvc?rev=1381625&view=rev
Log:
QPID-4288 The pid and platform info are now fetched in a static block
and the cached value is returned.

Modified:
    
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java

Modified: 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java?rev=1381625&r1=1381624&r2=1381625&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java
 (original)
+++ 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java
 Thu Sep  6 14:41:29 2012
@@ -49,7 +49,11 @@ public class ConnectionStartProperties
 
     public static final String SESSION_FLOW = "qpid.session_flow";
 
-    public static int getPID()
+    public static int _pid;
+
+    public static final String _platformInfo;
+
+    static
     {
         RuntimeMXBean rtb = ManagementFactory.getRuntimeMXBean();
         String processName = rtb.getName();
@@ -57,23 +61,20 @@ public class ConnectionStartProperties
         {
             try
             {
-                return 
Integer.parseInt(processName.substring(0,processName.indexOf('@')));
+                _pid = 
Integer.parseInt(processName.substring(0,processName.indexOf('@')));
             }
             catch(Exception e)
             {
                 LOGGER.warn("Unable to get the PID due to error",e);
-                return -1;
+                _pid = -1;
             }
         }
         else
         {
             LOGGER.warn("Unable to get the PID due to unsupported format : " + 
processName);
-            return -1;
+            _pid = -1;
         }
-    }
 
-    public static String getPlatformInfo()
-    {
         StringBuilder fullSystemInfo = new 
StringBuilder(System.getProperty("java.runtime.name"));
         fullSystemInfo.append(", ");
         fullSystemInfo.append(System.getProperty("java.runtime.version"));
@@ -88,6 +89,16 @@ public class ConnectionStartProperties
         fullSystemInfo.append(", ");
         fullSystemInfo.append(System.getProperty("sun.os.patch.level"));
 
-        return fullSystemInfo.toString();
+        _platformInfo = fullSystemInfo.toString();
+    }
+
+    public static int getPID()
+    {
+        return _pid;
+    }
+
+    public static String getPlatformInfo()
+    {
+        return _platformInfo;
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org
For additional commands, e-mail: commits-h...@qpid.apache.org

Reply via email to