author | mchung |
Thu, 10 Apr 2008 10:47:13 -0700 | |
changeset 401 | ef01e0dccd63 |
parent 2 | 90ce3da70b43 |
child 715 | f16baef3a20e |
permissions | -rw-r--r-- |
2 | 1 |
/* |
2 |
* Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved. |
|
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 |
|
7 |
* published by the Free Software Foundation. Sun designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Sun in the LICENSE file that accompanied this code. |
|
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 |
* |
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 |
* have any questions. |
|
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; |
|
36 |
import javax.management.openmbean.CompositeData; |
|
37 |
import javax.management.openmbean.CompositeDataSupport; |
|
38 |
import javax.management.openmbean.CompositeType; |
|
39 |
import javax.management.openmbean.OpenType; |
|
40 |
import javax.management.openmbean.SimpleType; |
|
41 |
import javax.management.openmbean.OpenDataException; |
|
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
42 |
import javax.management.ObjectName; |
2 | 43 |
|
44 |
/** |
|
45 |
* Implementation class for the runtime subsystem. |
|
46 |
* Standard and committed hotspot-specific metrics if any. |
|
47 |
* |
|
48 |
* ManagementFactory.getRuntimeMXBean() returns an instance |
|
49 |
* of this class. |
|
50 |
*/ |
|
51 |
class RuntimeImpl implements RuntimeMXBean { |
|
52 |
||
53 |
private final VMManagement jvm; |
|
54 |
private final long vmStartupTime; |
|
55 |
||
56 |
/** |
|
57 |
* Constructor of RuntimeImpl class. |
|
58 |
*/ |
|
59 |
RuntimeImpl(VMManagement vm) { |
|
60 |
this.jvm = vm; |
|
61 |
this.vmStartupTime = jvm.getStartupTime(); |
|
62 |
} |
|
63 |
||
64 |
public String getName() { |
|
65 |
return jvm.getVmId(); |
|
66 |
} |
|
67 |
||
68 |
public String getManagementSpecVersion() { |
|
69 |
return jvm.getManagementVersion(); |
|
70 |
} |
|
71 |
||
72 |
public String getVmName() { |
|
73 |
return jvm.getVmName(); |
|
74 |
} |
|
75 |
||
76 |
public String getVmVendor() { |
|
77 |
return jvm.getVmVendor(); |
|
78 |
} |
|
79 |
||
80 |
public String getVmVersion() { |
|
81 |
return jvm.getVmVersion(); |
|
82 |
} |
|
83 |
||
84 |
public String getSpecName() { |
|
85 |
return jvm.getVmSpecName(); |
|
86 |
} |
|
87 |
||
88 |
public String getSpecVendor() { |
|
89 |
return jvm.getVmSpecVendor(); |
|
90 |
} |
|
91 |
||
92 |
public String getSpecVersion() { |
|
93 |
return jvm.getVmSpecVersion(); |
|
94 |
} |
|
95 |
||
96 |
public String getClassPath() { |
|
97 |
return jvm.getClassPath(); |
|
98 |
} |
|
99 |
||
100 |
public String getLibraryPath() { |
|
101 |
return jvm.getLibraryPath(); |
|
102 |
} |
|
103 |
||
104 |
public String getBootClassPath() { |
|
105 |
if (!isBootClassPathSupported()) { |
|
106 |
throw new UnsupportedOperationException( |
|
107 |
"Boot class path mechanism is not supported"); |
|
108 |
} |
|
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
109 |
Util.checkMonitorAccess(); |
2 | 110 |
return jvm.getBootClassPath(); |
111 |
} |
|
112 |
||
113 |
public List<String> getInputArguments() { |
|
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
114 |
Util.checkMonitorAccess(); |
2 | 115 |
return jvm.getVmArguments(); |
116 |
} |
|
117 |
||
118 |
public long getUptime() { |
|
119 |
long current = System.currentTimeMillis(); |
|
120 |
||
121 |
// TODO: If called from client side when we support |
|
122 |
// MBean proxy to read performance counters from shared memory, |
|
123 |
// need to check if the monitored VM exitd. |
|
124 |
return (current - vmStartupTime); |
|
125 |
} |
|
126 |
||
127 |
public long getStartTime() { |
|
128 |
return vmStartupTime; |
|
129 |
} |
|
130 |
||
131 |
public boolean isBootClassPathSupported() { |
|
132 |
return jvm.isBootClassPathSupported(); |
|
133 |
} |
|
134 |
||
135 |
public Map<String,String> getSystemProperties() { |
|
136 |
Properties sysProps = System.getProperties(); |
|
137 |
Map<String,String> map = new HashMap<String, String>(); |
|
138 |
||
139 |
// Properties.entrySet() does not include the entries in |
|
140 |
// the default properties. So use Properties.stringPropertyNames() |
|
141 |
// to get the list of property keys including the default ones. |
|
142 |
Set<String> keys = sysProps.stringPropertyNames(); |
|
143 |
for (String k : keys) { |
|
144 |
String value = sysProps.getProperty(k); |
|
145 |
map.put(k, value); |
|
146 |
} |
|
147 |
||
148 |
return map; |
|
149 |
} |
|
401
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
150 |
|
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
151 |
public ObjectName getObjectName() { |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
152 |
return Util.newObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME); |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
153 |
} |
ef01e0dccd63
6610094: Add generic support for platform MXBeans of any type (also fixed 6681031)
mchung
parents:
2
diff
changeset
|
154 |
|
2 | 155 |
} |