2362N/A Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. 0N/A DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A This code is free software; you can redistribute it and/or modify it 0N/A under the terms of the GNU General Public License version 2 only, as 2362N/A published by the Free Software Foundation. Oracle designates this 0N/A particular file as subject to the "Classpath" exception as provided 2362N/A by Oracle in the LICENSE file that accompanied this code. 0N/A This code is distributed in the hope that it will be useful, but WITHOUT 0N/A ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A version 2 for more details (a copy is included in the LICENSE file that 0N/A accompanied this code). 0N/A You should have received a copy of the GNU General Public License version 0N/A 2 along with this work; if not, write to the Free Software Foundation, 0N/A Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
0N/A<
body bgcolor="white">
3887N/AProvides the management interfaces for monitoring and management of the
3887N/AJava virtual machine and other components in the Java runtime.
3887N/AIt allows both local and remote
3887N/Amonitoring and management of the running Java virtual machine.
3887N/A<
h4><
a name="MXBean">Platform MXBean</
a></
h4>
3887N/AA platform MXBean is a <
i>managed bean</
i> that
3887N/AInstrumentation Specification and only uses a set of basic data types.
0N/A<
h4>ManagementFactory</
h4>
3887N/Afactory class for the Java platform. This class provides a set of
0N/Astatic factory methods to obtain the MXBeans for the Java platform
0N/Ato allow an application to access the MXBeans directly.
0N/A<
p>A <
em>platform MBeanServer</
em> can be accessed with the
0N/A getPlatformMBeanServer} method. On the first call to this method,
3887N/Ait creates the platform MBeanServer and registers all platform MXBeans
3887N/AEach platform MXBean is registered with a unique name defined in
3887N/Athe specification of the management interface.
3887N/AThis is a single MBeanServer that can be shared by different managed
0N/Acomponents running within the same Java virtual machine.
0N/A<
h4>Interoperability</
h4>
3887N/A<
p>A management application and a platform MBeanServer of a running
3887N/Avirtual machine can interoperate
0N/Awithout requiring classes used by the platform MXBean interfaces.
0N/AThe data types being transmitted between the JMX connector
0N/Aserver and the connector client are JMX
0N/Athis allows interoperation across versions.
3887N/AA data type used by the MXBean interfaces are mapped to an
3887N/Aopen type when being accessed via MBeanServer interface.
3887N/AMXBean</
a> specification for details.
0N/A<
h4><
a name="examples">Ways to Access MXBeans</
a></
h4>
3887N/A<
p>An application can monitor the instrumentation of the
3887N/AJava virtual machine and the runtime in the following ways:
3887N/A<
b>1. Direct access to an MXBean interface</
b>
3887N/A<
li>Get an MXBean instance locally in the running Java virtual machine:<
p>
0N/A // Get the standard attribute "VmVendor"
3887N/A getPlatformMXBeans} method:
3887N/A // Get the standard attribute "VmVendor"
3887N/A<
li>Construct an MXBean proxy instance that forwards the
3887N/A method calls to a given MBeanServer:<
p>
3887N/A // Connect to a running JVM (or itself) and get MBeanServerConnection
3887N/A // that has the JVM MBeans registered in it
3887N/A // Get a MBean proxy for RuntimeMXBean interface
3887N/A // Get standard attribute "VmVendor"
3887N/A<
p>A proxy is typically used to access an MXBean
3887N/A in a remote Java virtual machine.
3887N/A An alternative way to create an MXBean proxy is:
3887N/A<
b>2. Indirect access to an MXBean interface via MBeanServer</
b><
p>
3887N/A platform MBeanServer} to access MXBeans locally or
3887N/A a specific {@code MBeanServerConnection} to access
3887N/A The attributes and operations of an MXBean use only
3887N/A <
em>JMX open types</
em> which include basic data types,
0N/A MBeanServerConnection mbs;
0N/A // Connect to a running JVM (or itself) and get MBeanServerConnection
0N/A // that has the JVM MXBeans registered in it
0N/A // Assuming the RuntimeMXBean has been registered in mbs
0N/A // Get standard attribute "VmVendor"
0N/A // Catch the exceptions thrown by ObjectName constructor
0N/A<
h4><
a name="extension">Platform Extension</
a></
h4>
3887N/A<
p>A Java virtual machine implementation may add its platform extension to
0N/Athe management interface by defining platform-dependent
0N/Ainterfaces that extend the standard management interfaces to include
3887N/Aplatform-specific metrics and management operations.
0N/AThe static factory methods in the <
tt>ManagementFactory</
tt> class will
3887N/Areturn the MXBeans with the platform extension.
0N/AIt is recommended to name the platform-specific attributes with
0N/Aa vendor-specific prefix such as the vendor's name to
0N/Aavoid collisions of the attribute name between the future extension
0N/Ato the standard management interface and the platform extension.
0N/AIf the future extension to the standard management interface defines
0N/Aa new attribute for a management interface and the attribute name
0N/Ais happened to be same as some vendor-specific attribute's name,
0N/Athe applications accessing that vendor-specific attribute would have
0N/Ato be modified to cope with versioning and compatibility issues.
3887N/A<
p>Below is an example showing how to access an attribute
3887N/Afrom the platform extension:
3887N/A1) Direct access to the Oracle-specific MXBean interface
3887N/A // Get the standard attribute "CollectionCount"
3887N/A // Get the platform-specific attribute "LastGcInfo"
3887N/A2) Access the Oracle-specific MXBean interface via <
tt>MBeanServer</
tt>
0N/A MBeanServerConnection mbs;
0N/A // Connect to a running JVM (or itself) and get MBeanServerConnection
0N/A // that has the JVM MXBeans registered in it
3887N/A // Get the standard attribute "CollectionCount"
3887N/A // Get the platform-specific attribute "LastGcInfo"
0N/A<
p> Unless otherwise noted, passing a <
tt>null</
tt> argument to a constructor
0N/Aor method in any class or interface in this package will cause a {@link
0N/A JMX Specification.</
a>