See:
Description
Interface Summary | |
---|---|
ClassLoadingMXBean | The management interface for the class loading system of the Java virtual machine. |
CompilationMXBean | The management interface for the compilation system of the Java virtual machine. |
GarbageCollectorMXBean | The management interface for the garbage collection of the Java virtual machine. |
MemoryManagerMXBean | The management interface for a memory manager. |
MemoryMXBean | The management interface for the memory system of the Java virtual machine. |
MemoryPoolMXBean | The management interface for a memory pool. |
OperatingSystemMXBean | The management interface for the operating system on which the Java virtual machine is running. |
RuntimeMXBean | The management interface for the runtime system of the Java virtual machine. |
ThreadMXBean | The management interface for the thread system of the Java virtual machine. |
Class Summary | |
---|---|
![]() |
![]() |
ManagementFactory | The ManagementFactory class is a factory class for getting managed beans for the Java platform. |
ManagementPermission | The permission which the SecurityManager will check when code that is running with a SecurityManager calls methods defined in the management interface for the Java platform. |
MemoryNotificationInfo | The information about a memory notification. |
MemoryUsage | A MemoryUsage object represents a snapshot of memory usage. |
![]() |
![]() |
ThreadInfo | Thread information. |
Enum Summary | |
---|---|
MemoryType | Types of memory pools . |
Provides the management interface for monitoring and management of the Java virtual machine as well as the operating system on which the Java virtual machine is running. It allows both local and remote monitoring and management of the running Java virtual machine.
Management Interface
Description
ClassLoadingMXBean Class loading system of the Java virtual machine. CompilationMXBean Compilation system of the Java virtual machine. MemoryMXBean Memory system of the Java virtual machine. ThreadMXBean Threads system of the Java virtual machine. RuntimeMXBean Runtime system of the Java virtual machine. OperatingSystemMXBean Operating system on which the Java virtual machine is running. GarbageCollectorMXBean Garbage collector in the Java virtual machine. MemoryManagerMXBean Memory manager in the Java virtual machine. MemoryPoolMXBean Memory pool in the Java virtual machine.
A platform MXBean is a
managed bean
that defines the managementinterface for one component for the platform and is specified in the
ManagementFactory
ManagementFactory
class.
An application can monitor the instrumentation of the Java virtual machine and manage certain characteristics inthe following ways:
A platform MBeanServer can be accessed with the
getPlatformMBeanServer
method. On the first call to this method,it creates the platform MBeanServer and registers all platform MXBeans including platform MXBeans defined in other packages such as
LoggingMXBean
. Each platform MXBean is registered with a unique name defined in the
ManagementFactory
classfor constructing
ObjectName.
ObjectName
.
This is a single MBeanServer that can be shared by different managed components running within the same Java virtual machine.
A data type used by the MXBean interfaces are mapped toan open type when being accessed via MBeanServer interface.The data type mapping is specified in the ManagementFactory class.
RuntimeMXBean mxbean = ManagementFactory.getRuntimeMXBean(); // Get the standard attribute "VmVendor" String vendor = mxbean.getVmVendor();
MBeanServerConnection mbs; // Connect to a running JVM (or itself) and get MBeanServerConnection // that has the JVM MXBeans registered in it ... try { // Assuming the RuntimeMXBean has been registered in mbs ObjectName oname = new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME); // Get standard attribute "VmVendor" String vendor = (String) mbs.getAttribute(oname, "VmVendor"); } catch (....) { // Catch the exceptions thrown by ObjectName constructor // and MBeanServer.getAttribute method ... }
MBeanServerConnection mbs; // Connect to a running JVM (or itself) and get MBeanServerConnection // that has the JVM MBeans registered in it ... // Get a MBean proxy for RuntimeMXBean interface RuntimeMXBean proxy = ManagementFactory.newPlatformMXBeanProxy(mbs, ManagementFactory.RUNTIME_MXBEAN_NAME, RuntimeMXBean.class); // Get standard attribute "VmVendor" String vendor = proxy.getVmVendor();
It is recommended to name the platform-specific attributes witha vendor-specific prefix such as the vendor's name toavoid collisions of the attribute name between the future extensionto the standard management interface and the platform extension.If the future extension to the standard management interface definesa new attribute for a management interface and the attribute nameis happened to be same as some vendor-specific attribute's name,the applications accessing that vendor-specific attribute would haveto be modified to cope with versioning and compatibility issues.
Below is an example showing how to access a platform-specificattribute from Sun's implementation of the RuntimeMXBean .
1) Direct access to the Sun-specific MXBean interface
com.sun.management.RuntimeMXBean mxbean = (com.sun.management.RuntimeMXBean) ManagementFactory.getRuntimeMXBean(); // Get the standard attribute "VmVendor" String vendor = mxbean.getVmVendor(); // Get the platform-specific attribute "Bar" BarType bar = mxbean.getBar();
2) Access the Sun-specific MXBean interface via MBeanServer
MBeanServerConnection mbs; // Connect to a running JVM (or itself) and get MBeanServerConnection // that has the JVM MXBeans registered in it ... try { // Assuming the RuntimeMXBean has been registered in mbs ObjectName oname = new ObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME); // Get standard attribute "VmVendor" String vendor = (String) mbs.getAttribute(oname, "VmVendor"); // Check if this MXBean contains Sun's extension if (mbs.isInstanceOf(oname, "com.sun.management.RuntimeMXBean")) { // Get platform-specific attribute "Bar" BarType bar = (String) mbs.getAttribute(oname, "Bar"); } } catch (....) { // Catch the exceptions thrown by ObjectName constructor // and MBeanServer methods ... }
Unless otherwise noted, passing a null argument to a constructoror method in any class or interface in this package will cause a NullPointerException to be thrown.