author | mchung |
Tue, 17 Jan 2012 15:55:40 -0800 | |
changeset 11530 | a9d059c15b80 |
parent 5506 | 202f599c92aa |
child 14342 | 8435a30053c1 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.management; |
|
27 |
||
28 |
import java.lang.management.RuntimeMXBean; |
|
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
29 |
import java.lang.management.ManagementFactory; |
2 | 30 |
|
31 |
import java.util.List; |
|
32 |
import java.util.HashMap; |
|
33 |
import java.util.Map; |
|
34 |
import java.util.Set; |
|
35 |
import java.util.Properties; |
|
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
36 |
import javax.management.ObjectName; |
2 | 37 |
|
38 |
/** |
|
39 |
* Implementation class for the runtime subsystem. |
|
40 |
* Standard and committed hotspot-specific metrics if any. |
|
41 |
* |
|
42 |
* ManagementFactory.getRuntimeMXBean() returns an instance |
|
43 |
* of this class. |
|
44 |
*/ |
|
45 |
class RuntimeImpl implements RuntimeMXBean { |
|
46 |
||
47 |
private final VMManagement jvm; |
|
48 |
private final long vmStartupTime; |
|
49 |
||
50 |
/** |
|
51 |
* Constructor of RuntimeImpl class. |
|
52 |
*/ |
|
53 |
RuntimeImpl(VMManagement vm) { |
|
54 |
this.jvm = vm; |
|
55 |
this.vmStartupTime = jvm.getStartupTime(); |
|
56 |
} |
|
57 |
||
58 |
public String getName() { |
|
59 |
return jvm.getVmId(); |
|
60 |
} |
|
61 |
||
62 |
public String getManagementSpecVersion() { |
|
63 |
return jvm.getManagementVersion(); |
|
64 |
} |
|
65 |
||
66 |
public String getVmName() { |
|
67 |
return jvm.getVmName(); |
|
68 |
} |
|
69 |
||
70 |
public String getVmVendor() { |
|
71 |
return jvm.getVmVendor(); |
|
72 |
} |
|
73 |
||
74 |
public String getVmVersion() { |
|
75 |
return jvm.getVmVersion(); |
|
76 |
} |
|
77 |
||
78 |
public String getSpecName() { |
|
79 |
return jvm.getVmSpecName(); |
|
80 |
} |
|
81 |
||
82 |
public String getSpecVendor() { |
|
83 |
return jvm.getVmSpecVendor(); |
|
84 |
} |
|
85 |
||
86 |
public String getSpecVersion() { |
|
87 |
return jvm.getVmSpecVersion(); |
|
88 |
} |
|
89 |
||
90 |
public String getClassPath() { |
|
91 |
return jvm.getClassPath(); |
|
92 |
} |
|
93 |
||
94 |
public String getLibraryPath() { |
|
95 |
return jvm.getLibraryPath(); |
|
96 |
} |
|
97 |
||
98 |
public String getBootClassPath() { |
|
99 |
if (!isBootClassPathSupported()) { |
|
100 |
throw new UnsupportedOperationException( |
|
101 |
"Boot class path mechanism is not supported"); |
|
102 |
} |
|
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
103 |
Util.checkMonitorAccess(); |
2 | 104 |
return jvm.getBootClassPath(); |
105 |
} |
|
106 |
||
107 |
public List<String> getInputArguments() { |
|
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
108 |
Util.checkMonitorAccess(); |
2 | 109 |
return jvm.getVmArguments(); |
110 |
} |
|
111 |
||
112 |
public long getUptime() { |
|
113 |
long current = System.currentTimeMillis(); |
|
114 |
||
115 |
// TODO: If called from client side when we support |
|
116 |
// MBean proxy to read performance counters from shared memory, |
|
117 |
// need to check if the monitored VM exitd. |
|
118 |
return (current - vmStartupTime); |
|
119 |
} |
|
120 |
||
121 |
public long getStartTime() { |
|
122 |
return vmStartupTime; |
|
123 |
} |
|
124 |
||
125 |
public boolean isBootClassPathSupported() { |
|
126 |
return jvm.isBootClassPathSupported(); |
|
127 |
} |
|
128 |
||
129 |
public Map<String,String> getSystemProperties() { |
|
130 |
Properties sysProps = System.getProperties(); |
|
11530
a9d059c15b80
7117570: Warnings in sun.mangement.* and its subpackages
mchung
parents:
5506
diff
changeset
|
131 |
Map<String,String> map = new HashMap<>(); |
2 | 132 |
|
133 |
// Properties.entrySet() does not include the entries in |
|
134 |
// the default properties. So use Properties.stringPropertyNames() |
|
135 |
// to get the list of property keys including the default ones. |
|
136 |
Set<String> keys = sysProps.stringPropertyNames(); |
|
137 |
for (String k : keys) { |
|
138 |
String value = sysProps.getProperty(k); |
|
139 |
map.put(k, value); |
|
140 |
} |
|
141 |
||
142 |
return map; |
|
143 |
} |
|
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
144 |
|
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
145 |
public ObjectName getObjectName() { |
4156 | 146 |
return Util.newObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME); |
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
147 |
} |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
148 |
|
2 | 149 |
} |