diff options
| author | Rajith Muditha Attapattu <rajith@apache.org> | 2012-09-06 14:41:29 +0000 |
|---|---|---|
| committer | Rajith Muditha Attapattu <rajith@apache.org> | 2012-09-06 14:41:29 +0000 |
| commit | 139c24dcad762d003fbb49f64b8b7d0b7cd0c6fb (patch) | |
| tree | e1a305a276c161da7311fe479ceca6fed5c2fe76 /java | |
| parent | 3d42e62c5f6ca28360ab5f072b4de3d99416c568 (diff) | |
| download | qpid-python-139c24dcad762d003fbb49f64b8b7d0b7cd0c6fb.tar.gz | |
QPID-4288 The pid and platform info are now fetched in a static block
and the cached value is returned.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1381625 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
| -rw-r--r-- | java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java b/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java index 15c144b0eb..59a1b6c5b0 100644 --- a/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java +++ b/java/common/src/main/java/org/apache/qpid/properties/ConnectionStartProperties.java @@ -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; } } |
