diff -r 836adbf7a2cd -r 3317bb8137f4 jdk/src/java.management/share/classes/java/lang/management/package.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/java.management/share/classes/java/lang/management/package.html Sun Aug 17 15:54:13 2014 +0100 @@ -0,0 +1,244 @@ + + + + + + +Provides the management interfaces for monitoring and management of the +Java virtual machine and other components in the Java runtime. +It allows both local and remote +monitoring and management of the running Java virtual machine. + +

Platform MXBean

+

+A platform MXBean is a managed bean that +conforms to the JMX +Instrumentation Specification and only uses a set of basic data types. +Each platform MXBean is a {@link java.lang.management.PlatformManagedObject} +with a unique +{@linkplain java.lang.management.PlatformManagedObject#getObjectName name}. +

ManagementFactory

+ +

The {@link java.lang.management.ManagementFactory} class is the management +factory class for the Java platform. This class provides a set of +static factory methods to obtain the MXBeans for the Java platform +to allow an application to access the MXBeans directly. + +

A platform MBeanServer can be accessed with the +{@link java.lang.management.ManagementFactory#getPlatformMBeanServer + getPlatformMBeanServer} method. On the first call to this method, +it creates the platform MBeanServer and registers all platform MXBeans +including {@linkplain java.lang.management.PlatformManagedObject +platform MXBeans}. +Each platform MXBean is registered with a unique name defined in +the specification of the management interface. +This is a single MBeanServer that can be shared by different managed +components running within the same Java virtual machine. + +

Interoperability

+ +

A management application and a platform MBeanServer of a running +virtual machine can interoperate +without requiring classes used by the platform MXBean interfaces. +The data types being transmitted between the JMX connector +server and the connector client are JMX +{@linkplain javax.management.openmbean.OpenType open types} and +this allows interoperation across versions. +A data type used by the MXBean interfaces are mapped to an +open type when being accessed via MBeanServer interface. +See the +MXBean specification for details. + +

Ways to Access MXBeans

+ +

An application can monitor the instrumentation of the +Java virtual machine and the runtime in the following ways: +

+1. Direct access to an MXBean interface +

+

+2. Indirect access to an MXBean interface via MBeanServer +

+ + +

Platform Extension

+ +

A Java virtual machine implementation may add its platform extension to +the management interface by defining platform-dependent +interfaces that extend the standard management interfaces to include +platform-specific metrics and management operations. +The static factory methods in the ManagementFactory class will +return the MXBeans with the platform extension. + +

+It is recommended to name the platform-specific attributes with +a vendor-specific prefix such as the vendor's name to +avoid collisions of the attribute name between the future extension +to the standard management interface and the platform extension. +If the future extension to the standard management interface defines +a new attribute for a management interface and the attribute name +is happened to be same as some vendor-specific attribute's name, +the applications accessing that vendor-specific attribute would have +to be modified to cope with versioning and compatibility issues. + +

Below is an example showing how to access an attribute +from the platform extension: + +

+1) Direct access to the Oracle-specific MXBean interface +

+
+   List<com.sun.management.GarbageCollectorMXBean> mxbeans =
+       ManagementFactory.getPlatformMXBeans(com.sun.management.GarbageCollectorMXBean.class);
+
+   for (com.sun.management.GarbageCollectorMXBean gc : mxbeans) {
+       // Get the standard attribute "CollectionCount"
+       String count = mxbean.getCollectionCount();
+
+       // Get the platform-specific attribute "LastGcInfo"
+       GcInfo gcinfo = gc.getLastGcInfo();
+       ...
+   }
+
+
+ +

+2) Access the Oracle-specific MXBean interface via MBeanServer + through proxy + +

+   MBeanServerConnection mbs;
+
+   // Connect to a running JVM (or itself) and get MBeanServerConnection
+   // that has the JVM MXBeans registered in it
+   ...
+
+   List<com.sun.management.GarbageCollectorMXBean> mxbeans =
+       ManagementFactory.getPlatformMXBeans(mbs, com.sun.management.GarbageCollectorMXBean.class);
+
+   for (com.sun.management.GarbageCollectorMXBean gc : mxbeans) {
+       // Get the standard attribute "CollectionCount"
+       String count = mxbean.getCollectionCount();
+
+       // Get the platform-specific attribute "LastGcInfo"
+       GcInfo gcinfo = gc.getLastGcInfo();
+       ...
+   }
+
+ +

Unless otherwise noted, passing a null argument to a constructor +or method in any class or interface in this package will cause a {@link +java.lang.NullPointerException NullPointerException} to be thrown. + +

The java.lang.management API is thread-safe. + +@see + JMX Specification. + +@author Mandy Chung +@since 1.5 + + +