author | jfranck |
Mon, 30 Sep 2013 11:18:18 +0200 | |
changeset 20481 | 2735b307d256 |
parent 14342 | 8435a30053c1 |
child 21334 | c60dfce46a77 |
permissions | -rw-r--r-- |
2 | 1 |
<!-- |
14342
8435a30053c1
7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents:
9013
diff
changeset
|
2 |
Copyright (c) 2003, 2011, 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 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> |
|
27 |
<html> |
|
28 |
<body bgcolor="white"> |
|
29 |
||
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
30 |
Provides the management interfaces for monitoring and management of the |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
31 |
Java virtual machine and other components in the Java runtime. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
32 |
It allows both local and remote |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
33 |
monitoring and management of the running Java virtual machine. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
34 |
<p> |
2 | 35 |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
36 |
<h4><a name="MXBean">Platform MXBean</a></h4> |
2 | 37 |
<p> |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
38 |
A platform MXBean is a <i>managed bean</i> that |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
39 |
conforms to the <a href="../../../javax/management/package-summary.html">JMX</a> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
40 |
Instrumentation Specification and only uses a set of basic data types. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
41 |
Each platform MXBean is a {@link java.lang.management.PlatformManagedObject} |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
42 |
with a unique |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
43 |
{@linkplain java.lang.management.PlatformManagedObject#getObjectName name}. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
44 |
<p> |
2 | 45 |
<h4>ManagementFactory</h4> |
46 |
||
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
47 |
<p>The {@link java.lang.management.ManagementFactory} class is the management |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
48 |
factory class for the Java platform. This class provides a set of |
2 | 49 |
static factory methods to obtain the MXBeans for the Java platform |
50 |
to allow an application to access the MXBeans directly. |
|
51 |
||
52 |
<p>A <em>platform MBeanServer</em> can be accessed with the |
|
53 |
{@link java.lang.management.ManagementFactory#getPlatformMBeanServer |
|
54 |
getPlatformMBeanServer} method. On the first call to this method, |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
55 |
it creates the platform MBeanServer and registers all platform MXBeans |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
56 |
including {@linkplain java.lang.management.PlatformManagedObject |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
57 |
platform MXBeans}. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
58 |
Each platform MXBean is registered with a unique name defined in |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
59 |
the specification of the management interface. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
60 |
This is a single MBeanServer that can be shared by different managed |
2 | 61 |
components running within the same Java virtual machine. |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
62 |
|
2 | 63 |
<h4>Interoperability</h4> |
64 |
||
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
65 |
<p>A management application and a platform MBeanServer of a running |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
66 |
virtual machine can interoperate |
2 | 67 |
without requiring classes used by the platform MXBean interfaces. |
68 |
The data types being transmitted between the JMX connector |
|
69 |
server and the connector client are JMX |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
70 |
{@linkplain javax.management.openmbean.OpenType open types} and |
2 | 71 |
this allows interoperation across versions. |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
72 |
A data type used by the MXBean interfaces are mapped to an |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
73 |
open type when being accessed via MBeanServer interface. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
74 |
See the <a href="../../../javax/management/MXBean.html#MXBean-spec"> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
75 |
MXBean</a> specification for details. |
2 | 76 |
|
77 |
<h4><a name="examples">Ways to Access MXBeans</a></h4> |
|
78 |
||
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
79 |
<p>An application can monitor the instrumentation of the |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
80 |
Java virtual machine and the runtime in the following ways: |
2 | 81 |
<p> |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
82 |
<b>1. Direct access to an MXBean interface</b> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
83 |
<p> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
84 |
<ul> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
85 |
<li>Get an MXBean instance locally in the running Java virtual machine:<p> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
86 |
<pre> |
2 | 87 |
RuntimeMXBean mxbean = ManagementFactory.getRuntimeMXBean(); |
88 |
||
89 |
// Get the standard attribute "VmVendor" |
|
90 |
String vendor = mxbean.getVmVendor(); |
|
91 |
</pre> |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
92 |
<p>Or by calling the |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
93 |
{@link java.lang.management.ManagementFactory#getPlatformMXBean(Class) |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
94 |
getPlatformMXBean} or |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
95 |
{@link java.lang.management.ManagementFactory#getPlatformMXBeans(Class) |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
96 |
getPlatformMXBeans} method: |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
97 |
<pre> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
98 |
RuntimeMXBean mxbean = ManagementFactory.getPlatformMXBean(RuntimeMXBean.class); |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
99 |
|
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
100 |
// Get the standard attribute "VmVendor" |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
101 |
String vendor = mxbean.getVmVendor(); |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
102 |
</pre> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
103 |
<p> |
2 | 104 |
</li> |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
105 |
<li>Construct an MXBean proxy instance that forwards the |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
106 |
method calls to a given MBeanServer:<p> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
107 |
<pre> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
108 |
MBeanServerConnection mbs; |
2 | 109 |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
110 |
// Connect to a running JVM (or itself) and get MBeanServerConnection |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
111 |
// that has the JVM MBeans registered in it |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
112 |
... |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
113 |
|
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
114 |
// Get a MBean proxy for RuntimeMXBean interface |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
115 |
RuntimeMXBean proxy = |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
116 |
{@link java.lang.management.ManagementFactory#getPlatformMXBean(MBeanServerConnection, Class) |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
117 |
ManagementFactory.getPlatformMXBean}(mbs, |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
118 |
RuntimeMXBean.class); |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
119 |
// Get standard attribute "VmVendor" |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
120 |
String vendor = proxy.getVmVendor(); |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
121 |
</pre> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
122 |
<p>A proxy is typically used to access an MXBean |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
123 |
in a remote Java virtual machine. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
124 |
An alternative way to create an MXBean proxy is: |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
125 |
<pre> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
126 |
RuntimeMXBean proxy = |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
127 |
{@link java.lang.management.ManagementFactory#newPlatformMXBeanProxy |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
128 |
ManagementFactory.newPlatformMXBeanProxy}(mbs, |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
129 |
ManagementFactory.RUNTIME_MXBEAN_NAME, |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
130 |
RuntimeMXBean.class); |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
131 |
</pre> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
132 |
</li> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
133 |
</ul> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
134 |
<p> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
135 |
<b>2. Indirect access to an MXBean interface via MBeanServer</b><p> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
136 |
<ul> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
137 |
<li>Go through the |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
138 |
{@link java.lang.management.ManagementFactory#getPlatformMBeanServer |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
139 |
platform MBeanServer} to access MXBeans locally or |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
140 |
a specific {@code MBeanServerConnection} to access |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
141 |
MXBeans remotely. |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
142 |
The attributes and operations of an MXBean use only |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
143 |
<em>JMX open types</em> which include basic data types, |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
144 |
{@link javax.management.openmbean.CompositeData CompositeData}, |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
145 |
and {@link javax.management.openmbean.TabularData TabularData} |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
146 |
defined in {@link javax.management.openmbean.OpenType OpenType}.<p> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
147 |
<pre> |
2 | 148 |
MBeanServerConnection mbs; |
149 |
||
150 |
// Connect to a running JVM (or itself) and get MBeanServerConnection |
|
151 |
// that has the JVM MXBeans registered in it |
|
152 |
... |
|
153 |
||
154 |
try { |
|
155 |
// Assuming the RuntimeMXBean has been registered in mbs |
|
156 |
ObjectName oname = new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME); |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
157 |
|
2 | 158 |
// Get standard attribute "VmVendor" |
159 |
String vendor = (String) mbs.getAttribute(oname, "VmVendor"); |
|
160 |
} catch (....) { |
|
161 |
// Catch the exceptions thrown by ObjectName constructor |
|
162 |
// and MBeanServer.getAttribute method |
|
163 |
... |
|
164 |
} |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
165 |
</pre> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
166 |
</li> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
167 |
</ul> |
2 | 168 |
|
169 |
||
170 |
<h4><a name="extension">Platform Extension</a></h4> |
|
171 |
||
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
172 |
<p>A Java virtual machine implementation may add its platform extension to |
2 | 173 |
the management interface by defining platform-dependent |
174 |
interfaces that extend the standard management interfaces to include |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
175 |
platform-specific metrics and management operations. |
2 | 176 |
The static factory methods in the <tt>ManagementFactory</tt> class will |
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
177 |
return the MXBeans with the platform extension. |
2 | 178 |
|
179 |
<p> |
|
180 |
It is recommended to name the platform-specific attributes with |
|
181 |
a vendor-specific prefix such as the vendor's name to |
|
182 |
avoid collisions of the attribute name between the future extension |
|
183 |
to the standard management interface and the platform extension. |
|
184 |
If the future extension to the standard management interface defines |
|
185 |
a new attribute for a management interface and the attribute name |
|
186 |
is happened to be same as some vendor-specific attribute's name, |
|
187 |
the applications accessing that vendor-specific attribute would have |
|
188 |
to be modified to cope with versioning and compatibility issues. |
|
189 |
||
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
190 |
<p>Below is an example showing how to access an attribute |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
191 |
from the platform extension: |
2 | 192 |
|
193 |
<p> |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
194 |
1) Direct access to the Oracle-specific MXBean interface |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
195 |
<blockquote> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
196 |
<pre> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
197 |
List<com.sun.management.GarbageCollectorMXBean> mxbeans = |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
198 |
ManagementFactory.getPlatformMXBeans(com.sun.management.GarbageCollectorMXBean.class); |
2 | 199 |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
200 |
for (com.sun.management.GarbageCollectorMXBean gc : mxbeans) { |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
201 |
// Get the standard attribute "CollectionCount" |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
202 |
String count = mxbean.getCollectionCount(); |
2 | 203 |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
204 |
// Get the platform-specific attribute "LastGcInfo" |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
205 |
GcInfo gcinfo = gc.getLastGcInfo(); |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
206 |
... |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
207 |
} |
2 | 208 |
</pre> |
209 |
</blockquote> |
|
210 |
||
211 |
<p> |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
212 |
2) Access the Oracle-specific MXBean interface via <tt>MBeanServer</tt> |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
213 |
through proxy |
2 | 214 |
|
215 |
<blockquote><pre> |
|
216 |
MBeanServerConnection mbs; |
|
217 |
||
218 |
// Connect to a running JVM (or itself) and get MBeanServerConnection |
|
219 |
// that has the JVM MXBeans registered in it |
|
220 |
... |
|
221 |
||
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
222 |
List<com.sun.management.GarbageCollectorMXBean> mxbeans = |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
223 |
ManagementFactory.getPlatformMXBeans(mbs, com.sun.management.GarbageCollectorMXBean.class); |
2 | 224 |
|
9013
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
225 |
for (com.sun.management.GarbageCollectorMXBean gc : mxbeans) { |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
226 |
// Get the standard attribute "CollectionCount" |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
227 |
String count = mxbean.getCollectionCount(); |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
228 |
|
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
229 |
// Get the platform-specific attribute "LastGcInfo" |
eedac0b9f552
7024172: Move BufferPoolMXBean and PlatformLoggingMXBean java.lang.management
mchung
parents:
5506
diff
changeset
|
230 |
GcInfo gcinfo = gc.getLastGcInfo(); |
2 | 231 |
... |
232 |
} |
|
233 |
</pre></blockquote> |
|
234 |
||
235 |
<p> Unless otherwise noted, passing a <tt>null</tt> argument to a constructor |
|
236 |
or method in any class or interface in this package will cause a {@link |
|
237 |
java.lang.NullPointerException NullPointerException} to be thrown. |
|
238 |
||
239 |
<p> The java.lang.management API is thread-safe. |
|
240 |
||
241 |
@see <a href="../../../javax/management/package-summary.html"> |
|
242 |
JMX Specification.</a> |
|
243 |
||
244 |
@author Mandy Chung |
|
245 |
@since 1.5 |
|
246 |
||
247 |
</body> |
|
248 |
</html> |