java.lang.management
Class ManagementFactory

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.lang.management.ManagementFactory

public class ManagementFactory
extends Object sample code for java.lang.Object definition code for java.lang.Object

The ManagementFactory class is a factory class for getting managed beans for the Java platform. This class consists of static methods each of which returns one or more platform MXBean(s) representing the management interface of a component of the Java virtual machine.

An application can access a platform MXBean in the following ways:

Platform MXBeans

A platform MXBean is a managed bean that conforms to the JMX Instrumentation Specification and only uses a set of basic data types described below. A JMX management application and the platform MBeanServer can interoperate without requiring classes for MXBean specific data types. The data types being transmitted between the JMX connector server and the connector client are open types sample code for javax.management.openmbean.OpenType definition code for javax.management.openmbean.OpenType and this allows interoperation across versions.

The platform MXBean interfaces use only the following data types:

When an attribute or operation of a platform MXBean is accessed via an MBeanServer, the data types are mapped as follows:

The MBeanInfo sample code for javax.management.MBeanInfo definition code for javax.management.MBeanInfo for a platform MXBean describes the data types of the attributes and operations as primitive or open types mapped as specified above.

For example, the MemoryMXBean sample code for java.lang.management.MemoryMXBean definition code for java.lang.management.MemoryMXBean interface has the following getter and setter methods:

 public MemoryUsage getHeapMemoryUsage();
 public boolean isVerbose();
 public void setVerbose(boolean value);
 
These attributes in the MBeanInfo of the MemoryMXBean have the following names and types:
Attribute Name Type
HeapMemoryUsage CompositeData representing MemoryUsage sample code for java.lang.management.MemoryUsage.from(javax.management.openmbean.CompositeData) definition code for java.lang.management.MemoryUsage.from(javax.management.openmbean.CompositeData)
Verbose boolean

Implementation Note:

The mapping specified above could be done in the implementation of each platform MXBean. One good implementation choice is to implement a MXBean as a dynamic MBean sample code for javax.management.DynamicMBean definition code for javax.management.DynamicMBean .

MXBean Names

Each platform MXBean for a Java virtual machine has a unique ObjectName sample code for javax.management.ObjectName definition code for javax.management.ObjectName for registration in the platform MBeanServer. A Java virtual machine has a single instance of the following management interfaces:
Management Interface ObjectName
ClassLoadingMXBean sample code for java.lang.management.ClassLoadingMXBean definition code for java.lang.management.ClassLoadingMXBean java.lang:type=ClassLoading sample code for java.lang.management.ManagementFactory.CLASS_LOADING_MXBEAN_NAME definition code for java.lang.management.ManagementFactory.CLASS_LOADING_MXBEAN_NAME
MemoryMXBean sample code for java.lang.management.MemoryMXBean definition code for java.lang.management.MemoryMXBean java.lang:type=Memory sample code for java.lang.management.ManagementFactory.MEMORY_MXBEAN_NAME definition code for java.lang.management.ManagementFactory.MEMORY_MXBEAN_NAME
ThreadMXBean sample code for java.lang.management.ThreadMXBean definition code for java.lang.management.ThreadMXBean java.lang:type=Threading sample code for java.lang.management.ManagementFactory.THREAD_MXBEAN_NAME definition code for java.lang.management.ManagementFactory.THREAD_MXBEAN_NAME
RuntimeMXBean sample code for java.lang.management.RuntimeMXBean definition code for java.lang.management.RuntimeMXBean java.lang:type=Runtime sample code for java.lang.management.ManagementFactory.RUNTIME_MXBEAN_NAME definition code for java.lang.management.ManagementFactory.RUNTIME_MXBEAN_NAME
OperatingSystemMXBean sample code for java.lang.management.OperatingSystemMXBean definition code for java.lang.management.OperatingSystemMXBean java.lang:type=OperatingSystem sample code for java.lang.management.ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME definition code for java.lang.management.ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME

A Java virtual machine has zero or a single instance of the following management interfaces.

Management Interface ObjectName
CompilationMXBean sample code for java.lang.management.CompilationMXBean definition code for java.lang.management.CompilationMXBean java.lang:type=Compilation sample code for java.lang.management.ManagementFactory.COMPILATION_MXBEAN_NAME definition code for java.lang.management.ManagementFactory.COMPILATION_MXBEAN_NAME

A Java virtual machine may have one or more instances of the following management interfaces.

Management Interface ObjectName
GarbageCollectorMXBean sample code for java.lang.management.GarbageCollectorMXBean definition code for java.lang.management.GarbageCollectorMXBean java.lang:type=GarbageCollector sample code for java.lang.management.ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE definition code for java.lang.management.ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE ,name=collector's name
MemoryManagerMXBean sample code for java.lang.management.MemoryManagerMXBean definition code for java.lang.management.MemoryManagerMXBean java.lang:type=MemoryManager sample code for java.lang.management.ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE definition code for java.lang.management.ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE ,name=manager's name
MemoryPoolMXBean sample code for java.lang.management.MemoryPoolMXBean definition code for java.lang.management.MemoryPoolMXBean java.lang:type=MemoryPool sample code for java.lang.management.ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE definition code for java.lang.management.ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE ,name=pool's name

Since:
1.5
See Also:
JMX Specification., Ways to Access Management Metrics, LoggingMXBean sample code for java.util.logging.LoggingMXBean definition code for java.util.logging.LoggingMXBean

Field Summary
static String sample code for java.lang.String definition code for java.lang.String CLASS_LOADING_MXBEAN_NAME sample code for java.lang.management.ManagementFactory.CLASS_LOADING_MXBEAN_NAME definition code for java.lang.management.ManagementFactory.CLASS_LOADING_MXBEAN_NAME
          String representation of the ObjectName for the ClassLoadingMXBean sample code for java.lang.management.ClassLoadingMXBean definition code for java.lang.management.ClassLoadingMXBean .
static String sample code for java.lang.String definition code for java.lang.String COMPILATION_MXBEAN_NAME sample code for java.lang.management.ManagementFactory.COMPILATION_MXBEAN_NAME definition code for java.lang.management.ManagementFactory.COMPILATION_MXBEAN_NAME
          String representation of the ObjectName for the CompilationMXBean sample code for java.lang.management.CompilationMXBean definition code for java.lang.management.CompilationMXBean .
static String sample code for java.lang.String definition code for java.lang.String GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE sample code for java.lang.management.ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE definition code for java.lang.management.ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE
          The domain name and the type key property in the ObjectName for a GarbageCollectorMXBean sample code for java.lang.management.GarbageCollectorMXBean definition code for java.lang.management.GarbageCollectorMXBean .
static String sample code for java.lang.String definition code for java.lang.String MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE sample code for java.lang.management.ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE definition code for java.lang.management.ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE
          The domain name and the type key property in the ObjectName for a MemoryManagerMXBean sample code for java.lang.management.MemoryManagerMXBean definition code for java.lang.management.MemoryManagerMXBean .
static String sample code for java.lang.String definition code for java.lang.String MEMORY_MXBEAN_NAME sample code for java.lang.management.ManagementFactory.MEMORY_MXBEAN_NAME definition code for java.lang.management.ManagementFactory.MEMORY_MXBEAN_NAME
          String representation of the ObjectName for the MemoryMXBean sample code for java.lang.management.MemoryMXBean definition code for java.lang.management.MemoryMXBean .
static String sample code for java.lang.String definition code for java.lang.String MEMORY_POOL_MXBEAN_DOMAIN_TYPE sample code for java.lang.management.ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE definition code for java.lang.management.ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE
          The domain name and the type key property in the ObjectName for a MemoryPoolMXBean sample code for java.lang.management.MemoryPoolMXBean definition code for java.lang.management.MemoryPoolMXBean .
static String sample code for java.lang.String definition code for java.lang.String OPERATING_SYSTEM_MXBEAN_NAME sample code for java.lang.management.ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME definition code for java.lang.management.ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME
          String representation of the ObjectName for the OperatingSystemMXBean sample code for java.lang.management.OperatingSystemMXBean definition code for java.lang.management.OperatingSystemMXBean .
static String sample code for java.lang.String definition code for java.lang.String RUNTIME_MXBEAN_NAME sample code for java.lang.management.ManagementFactory.RUNTIME_MXBEAN_NAME definition code for java.lang.management.ManagementFactory.RUNTIME_MXBEAN_NAME
          String representation of the ObjectName for the RuntimeMXBean sample code for java.lang.management.RuntimeMXBean definition code for java.lang.management.RuntimeMXBean .
static String sample code for java.lang.String definition code for java.lang.String THREAD_MXBEAN_NAME sample code for java.lang.management.ManagementFactory.THREAD_MXBEAN_NAME definition code for java.lang.management.ManagementFactory.THREAD_MXBEAN_NAME
          String representation of the ObjectName for the ThreadMXBean sample code for java.lang.management.ThreadMXBean definition code for java.lang.management.ThreadMXBean .
 
Method Summary
static ClassLoadingMXBean sample code for java.lang.management.ClassLoadingMXBean definition code for java.lang.management.ClassLoadingMXBean getClassLoadingMXBean sample code for java.lang.management.ManagementFactory.getClassLoadingMXBean() definition code for java.lang.management.ManagementFactory.getClassLoadingMXBean() ()
          Returns the managed bean for the class loading system of the Java virtual machine.
static CompilationMXBean sample code for java.lang.management.CompilationMXBean definition code for java.lang.management.CompilationMXBean getCompilationMXBean sample code for java.lang.management.ManagementFactory.getCompilationMXBean() definition code for java.lang.management.ManagementFactory.getCompilationMXBean() ()
          Returns the managed bean for the compilation system of the Java virtual machine.
static List sample code for java.util.List definition code for java.util.List <GarbageCollectorMXBean sample code for java.lang.management.GarbageCollectorMXBean definition code for java.lang.management.GarbageCollectorMXBean > getGarbageCollectorMXBeans sample code for java.lang.management.ManagementFactory.getGarbageCollectorMXBeans() definition code for java.lang.management.ManagementFactory.getGarbageCollectorMXBeans() ()
          Returns a list of GarbageCollectorMXBean sample code for java.lang.management.GarbageCollectorMXBean definition code for java.lang.management.GarbageCollectorMXBean objects in the Java virtual machine.
static List sample code for java.util.List definition code for java.util.List <MemoryManagerMXBean sample code for java.lang.management.MemoryManagerMXBean definition code for java.lang.management.MemoryManagerMXBean > getMemoryManagerMXBeans sample code for java.lang.management.ManagementFactory.getMemoryManagerMXBeans() definition code for java.lang.management.ManagementFactory.getMemoryManagerMXBeans() ()
          Returns a list of MemoryManagerMXBean sample code for java.lang.management.MemoryManagerMXBean definition code for java.lang.management.MemoryManagerMXBean objects in the Java virtual machine.
static MemoryMXBean sample code for java.lang.management.MemoryMXBean definition code for java.lang.management.MemoryMXBean getMemoryMXBean sample code for java.lang.management.ManagementFactory.getMemoryMXBean() definition code for java.lang.management.ManagementFactory.getMemoryMXBean() ()
          Returns the managed bean for the memory system of the Java virtual machine.
static List sample code for java.util.List definition code for java.util.List <MemoryPoolMXBean sample code for java.lang.management.MemoryPoolMXBean definition code for java.lang.management.MemoryPoolMXBean > getMemoryPoolMXBeans sample code for java.lang.management.ManagementFactory.getMemoryPoolMXBeans() definition code for java.lang.management.ManagementFactory.getMemoryPoolMXBeans() ()
          Returns a list of MemoryPoolMXBean sample code for java.lang.management.MemoryPoolMXBean definition code for java.lang.management.MemoryPoolMXBean objects in the Java virtual machine.
static OperatingSystemMXBean sample code for java.lang.management.OperatingSystemMXBean definition code for java.lang.management.OperatingSystemMXBean getOperatingSystemMXBean sample code for java.lang.management.ManagementFactory.getOperatingSystemMXBean() definition code for java.lang.management.ManagementFactory.getOperatingSystemMXBean() ()
          Returns the managed bean for the operating system on which the Java virtual machine is running.
static MBeanServer sample code for javax.management.MBeanServer definition code for javax.management.MBeanServer getPlatformMBeanServer sample code for java.lang.management.ManagementFactory.getPlatformMBeanServer() definition code for java.lang.management.ManagementFactory.getPlatformMBeanServer() ()
          Returns the platform MBeanServer sample code for javax.management.MBeanServer definition code for javax.management.MBeanServer .
static RuntimeMXBean sample code for java.lang.management.RuntimeMXBean definition code for java.lang.management.RuntimeMXBean getRuntimeMXBean sample code for java.lang.management.ManagementFactory.getRuntimeMXBean() definition code for java.lang.management.ManagementFactory.getRuntimeMXBean() ()
          Returns the managed bean for the runtime system of the Java virtual machine.
static ThreadMXBean sample code for java.lang.management.ThreadMXBean definition code for java.lang.management.ThreadMXBean getThreadMXBean sample code for java.lang.management.ManagementFactory.getThreadMXBean() definition code for java.lang.management.ManagementFactory.getThreadMXBean() ()
          Returns the managed bean for the thread system of the Java virtual machine.
static
<T> T
newPlatformMXBeanProxy sample code for java.lang.management.ManagementFactory.newPlatformMXBeanProxy(javax.management.MBeanServerConnection, java.lang.String, java.lang.Class) definition code for java.lang.management.ManagementFactory.newPlatformMXBeanProxy(javax.management.MBeanServerConnection, java.lang.String, java.lang.Class) (MBeanServerConnection sample code for javax.management.MBeanServerConnection definition code for javax.management.MBeanServerConnection  connection, String sample code for java.lang.String definition code for java.lang.String  mxbeanName, Class sample code for java.lang.Class definition code for java.lang.Class <T> mxbeanInterface)
          Returns a proxy for a platform MXBean interface of a given MXBean name that forwards its method calls through the given MBeanServerConnection.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

CLASS_LOADING_MXBEAN_NAME sample code for java.lang.management.ManagementFactory.CLASS_LOADING_MXBEAN_NAME

public static final String sample code for java.lang.String definition code for java.lang.String  CLASS_LOADING_MXBEAN_NAME
String representation of the ObjectName for the ClassLoadingMXBean sample code for java.lang.management.ClassLoadingMXBean definition code for java.lang.management.ClassLoadingMXBean .

See Also:
Constant Field Values

COMPILATION_MXBEAN_NAME sample code for java.lang.management.ManagementFactory.COMPILATION_MXBEAN_NAME

public static final String sample code for java.lang.String definition code for java.lang.String  COMPILATION_MXBEAN_NAME
String representation of the ObjectName for the CompilationMXBean sample code for java.lang.management.CompilationMXBean definition code for java.lang.management.CompilationMXBean .

See Also:
Constant Field Values

MEMORY_MXBEAN_NAME sample code for java.lang.management.ManagementFactory.MEMORY_MXBEAN_NAME

public static final String sample code for java.lang.String definition code for java.lang.String  MEMORY_MXBEAN_NAME
String representation of the ObjectName for the MemoryMXBean sample code for java.lang.management.MemoryMXBean definition code for java.lang.management.MemoryMXBean .

See Also:
Constant Field Values

OPERATING_SYSTEM_MXBEAN_NAME sample code for java.lang.management.ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME

public static final String sample code for java.lang.String definition code for java.lang.String  OPERATING_SYSTEM_MXBEAN_NAME
String representation of the ObjectName for the OperatingSystemMXBean sample code for java.lang.management.OperatingSystemMXBean definition code for java.lang.management.OperatingSystemMXBean .

See Also:
Constant Field Values

RUNTIME_MXBEAN_NAME sample code for java.lang.management.ManagementFactory.RUNTIME_MXBEAN_NAME

public static final String sample code for java.lang.String definition code for java.lang.String  RUNTIME_MXBEAN_NAME
String representation of the ObjectName for the RuntimeMXBean sample code for java.lang.management.RuntimeMXBean definition code for java.lang.management.RuntimeMXBean .

See Also:
Constant Field Values

THREAD_MXBEAN_NAME sample code for java.lang.management.ManagementFactory.THREAD_MXBEAN_NAME

public static final String sample code for java.lang.String definition code for java.lang.String  THREAD_MXBEAN_NAME
String representation of the ObjectName for the ThreadMXBean sample code for java.lang.management.ThreadMXBean definition code for java.lang.management.ThreadMXBean .

See Also:
Constant Field Values

GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE sample code for java.lang.management.ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE

public static final String sample code for java.lang.String definition code for java.lang.String  GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE
The domain name and the type key property in the ObjectName for a GarbageCollectorMXBean sample code for java.lang.management.GarbageCollectorMXBean definition code for java.lang.management.GarbageCollectorMXBean . The unique ObjectName for a GarbageCollectorMXBean can be formed by appending this string with ",name=collector's name".

See Also:
Constant Field Values

MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE sample code for java.lang.management.ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE

public static final String sample code for java.lang.String definition code for java.lang.String  MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE
The domain name and the type key property in the ObjectName for a MemoryManagerMXBean sample code for java.lang.management.MemoryManagerMXBean definition code for java.lang.management.MemoryManagerMXBean . The unique ObjectName for a MemoryManagerMXBean can be formed by appending this string with ",name=manager's name".

See Also:
Constant Field Values

MEMORY_POOL_MXBEAN_DOMAIN_TYPE sample code for java.lang.management.ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE

public static final String sample code for java.lang.String definition code for java.lang.String  MEMORY_POOL_MXBEAN_DOMAIN_TYPE
The domain name and the type key property in the ObjectName for a MemoryPoolMXBean sample code for java.lang.management.MemoryPoolMXBean definition code for java.lang.management.MemoryPoolMXBean . The unique ObjectName for a MemoryPoolMXBean can be formed by appending this string with ,name=pool's name.

See Also:
Constant Field Values
Method Detail

getClassLoadingMXBean sample code for java.lang.management.ManagementFactory.getClassLoadingMXBean() definition code for java.lang.management.ManagementFactory.getClassLoadingMXBean()

public static ClassLoadingMXBean sample code for java.lang.management.ClassLoadingMXBean definition code for java.lang.management.ClassLoadingMXBean  getClassLoadingMXBean()
Returns the managed bean for the class loading system of the Java virtual machine.

Returns:
a ClassLoadingMXBean sample code for java.lang.management.ClassLoadingMXBean definition code for java.lang.management.ClassLoadingMXBean object for the Java virtual machine.

getMemoryMXBean sample code for java.lang.management.ManagementFactory.getMemoryMXBean() definition code for java.lang.management.ManagementFactory.getMemoryMXBean()

public static MemoryMXBean sample code for java.lang.management.MemoryMXBean definition code for java.lang.management.MemoryMXBean  getMemoryMXBean()
Returns the managed bean for the memory system of the Java virtual machine.

Returns:
a MemoryMXBean sample code for java.lang.management.MemoryMXBean definition code for java.lang.management.MemoryMXBean object for the Java virtual machine.

getThreadMXBean sample code for java.lang.management.ManagementFactory.getThreadMXBean() definition code for java.lang.management.ManagementFactory.getThreadMXBean()

public static ThreadMXBean sample code for java.lang.management.ThreadMXBean definition code for java.lang.management.ThreadMXBean  getThreadMXBean()
Returns the managed bean for the thread system of the Java virtual machine.

Returns:
a ThreadMXBean sample code for java.lang.management.ThreadMXBean definition code for java.lang.management.ThreadMXBean object for the Java virtual machine.

getRuntimeMXBean sample code for java.lang.management.ManagementFactory.getRuntimeMXBean() definition code for java.lang.management.ManagementFactory.getRuntimeMXBean()

public static RuntimeMXBean sample code for java.lang.management.RuntimeMXBean definition code for java.lang.management.RuntimeMXBean  getRuntimeMXBean()
Returns the managed bean for the runtime system of the Java virtual machine.

Returns:
a RuntimeMXBean sample code for java.lang.management.RuntimeMXBean definition code for java.lang.management.RuntimeMXBean object for the Java virtual machine.

getCompilationMXBean sample code for java.lang.management.ManagementFactory.getCompilationMXBean() definition code for java.lang.management.ManagementFactory.getCompilationMXBean()

public static CompilationMXBean sample code for java.lang.management.CompilationMXBean definition code for java.lang.management.CompilationMXBean  getCompilationMXBean()
Returns the managed bean for the compilation system of the Java virtual machine. This method returns null if the Java virtual machine has no compilation system.

Returns:
a CompilationMXBean sample code for java.lang.management.CompilationMXBean definition code for java.lang.management.CompilationMXBean object for the Java virtual machine or null if the Java virtual machine has no compilation system.

getOperatingSystemMXBean sample code for java.lang.management.ManagementFactory.getOperatingSystemMXBean() definition code for java.lang.management.ManagementFactory.getOperatingSystemMXBean()

public static OperatingSystemMXBean sample code for java.lang.management.OperatingSystemMXBean definition code for java.lang.management.OperatingSystemMXBean  getOperatingSystemMXBean()
Returns the managed bean for the operating system on which the Java virtual machine is running.

Returns:
an OperatingSystemMXBean sample code for java.lang.management.OperatingSystemMXBean definition code for java.lang.management.OperatingSystemMXBean object for the Java virtual machine.

getMemoryPoolMXBeans sample code for java.lang.management.ManagementFactory.getMemoryPoolMXBeans() definition code for java.lang.management.ManagementFactory.getMemoryPoolMXBeans()

public static List sample code for java.util.List definition code for java.util.List <MemoryPoolMXBean sample code for java.lang.management.MemoryPoolMXBean definition code for java.lang.management.MemoryPoolMXBean > getMemoryPoolMXBeans()
Returns a list of MemoryPoolMXBean sample code for java.lang.management.MemoryPoolMXBean definition code for java.lang.management.MemoryPoolMXBean objects in the Java virtual machine. The Java virtual machine can have one or more memory pools. It may add or remove memory pools during execution.

Returns:
a list of MemoryPoolMXBean objects.

getMemoryManagerMXBeans sample code for java.lang.management.ManagementFactory.getMemoryManagerMXBeans() definition code for java.lang.management.ManagementFactory.getMemoryManagerMXBeans()

public static List sample code for java.util.List definition code for java.util.List <MemoryManagerMXBean sample code for java.lang.management.MemoryManagerMXBean definition code for java.lang.management.MemoryManagerMXBean > getMemoryManagerMXBeans()
Returns a list of MemoryManagerMXBean sample code for java.lang.management.MemoryManagerMXBean definition code for java.lang.management.MemoryManagerMXBean objects in the Java virtual machine. The Java virtual machine can have one or more memory managers. It may add or remove memory managers during execution.

Returns:
a list of MemoryManagerMXBean objects.

getGarbageCollectorMXBeans sample code for java.lang.management.ManagementFactory.getGarbageCollectorMXBeans() definition code for java.lang.management.ManagementFactory.getGarbageCollectorMXBeans()

public static List sample code for java.util.List definition code for java.util.List <GarbageCollectorMXBean sample code for java.lang.management.GarbageCollectorMXBean definition code for java.lang.management.GarbageCollectorMXBean > getGarbageCollectorMXBeans()
Returns a list of GarbageCollectorMXBean sample code for java.lang.management.GarbageCollectorMXBean definition code for java.lang.management.GarbageCollectorMXBean objects in the Java virtual machine. The Java virtual machine may have one or more GarbageCollectorMXBean objects. It may add or remove GarbageCollectorMXBean during execution.

Returns:
a list of GarbageCollectorMXBean objects.

getPlatformMBeanServer sample code for java.lang.management.ManagementFactory.getPlatformMBeanServer() definition code for java.lang.management.ManagementFactory.getPlatformMBeanServer()

public static MBeanServer sample code for javax.management.MBeanServer definition code for javax.management.MBeanServer  getPlatformMBeanServer()
Returns the platform MBeanServer sample code for javax.management.MBeanServer definition code for javax.management.MBeanServer . On the first call to this method, it first creates the platform MBeanServer by calling the MBeanServerFactory.createMBeanServer() sample code for javax.management.MBeanServerFactory.createMBeanServer() definition code for javax.management.MBeanServerFactory.createMBeanServer() method and registers the platform MXBeans in this platform MBeanServer using the MXBean names defined in the class description. This method, in subsequent calls, will simply return the initially created platform MBeanServer.

MXBeans that get created and destroyed dynamically, for example, memory pools sample code for java.lang.management.MemoryPoolMXBean definition code for java.lang.management.MemoryPoolMXBean and managers sample code for java.lang.management.MemoryManagerMXBean definition code for java.lang.management.MemoryManagerMXBean , will automatically be registered and deregistered into the platform MBeanServer.

If the system property javax.management.builder.initial is set, the platform MBeanServer creation will be done by the specified MBeanServerBuilder sample code for javax.management.MBeanServerBuilder definition code for javax.management.MBeanServerBuilder .

It is recommended that this platform MBeanServer also be used to register other application managed beans besides the platform MXBeans. This will allow all MBeans to be published through the same MBeanServer and hence allow for easier network publishing and discovery. Name conflicts with the platform MXBeans should be avoided.

Returns:
the platform MBeanServer; the platform MXBeans are registered into the platform MBeanServer at the first time this method is called.
Throws:
SecurityException sample code for java.lang.SecurityException definition code for java.lang.SecurityException - if there is a security manager and the caller does not have the permission required by MBeanServerFactory.createMBeanServer() sample code for javax.management.MBeanServerFactory.createMBeanServer() definition code for javax.management.MBeanServerFactory.createMBeanServer() .
See Also:
MBeanServerFactory sample code for javax.management.MBeanServerFactory definition code for javax.management.MBeanServerFactory , MBeanServerFactory.createMBeanServer() sample code for javax.management.MBeanServerFactory.createMBeanServer() definition code for javax.management.MBeanServerFactory.createMBeanServer()

newPlatformMXBeanProxy sample code for java.lang.management.ManagementFactory.<T>newPlatformMXBeanProxy(javax.management.MBeanServerConnection, java.lang.String, java.lang.Class<T>) definition code for java.lang.management.ManagementFactory.<T>newPlatformMXBeanProxy(javax.management.MBeanServerConnection, java.lang.String, java.lang.Class<T>)

public static <T> T newPlatformMXBeanProxy(MBeanServerConnection sample code for javax.management.MBeanServerConnection definition code for javax.management.MBeanServerConnection  connection,
                                           String sample code for java.lang.String definition code for java.lang.String  mxbeanName,
                                           Class sample code for java.lang.Class definition code for java.lang.Class <T> mxbeanInterface)
                                throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Returns a proxy for a platform MXBean interface of a given MXBean name that forwards its method calls through the given MBeanServerConnection.

This method is equivalent to:

Proxy.newProxyInstance sample code for java.lang.reflect.Proxy.newProxyInstance(java.lang.ClassLoader, java.lang.Class[], java.lang.reflect.InvocationHandler) definition code for java.lang.reflect.Proxy.newProxyInstance(java.lang.ClassLoader, java.lang.Class[], java.lang.reflect.InvocationHandler) (mxbeanInterface.getClassLoader(), new Class[] { mxbeanInterface }, handler)
where handler is an InvocationHandler sample code for java.lang.reflect.InvocationHandler definition code for java.lang.reflect.InvocationHandler to which method invocations to the MXBean interface are dispatched. This handler converts an input parameter from an MXBean data type to its mapped open type before forwarding to the MBeanServer and converts a return value from an MXBean method call through the MBeanServer from an open type to the corresponding return type declared in the MXBean interface.

If the MXBean is a notification emitter (i.e., it implements NotificationEmitter sample code for javax.management.NotificationEmitter definition code for javax.management.NotificationEmitter ), both the mxbeanInterface and NotificationEmitter will be implemented by this proxy.

Notes:

  1. Using an MXBean proxy is a convenience remote access to a platform MXBean of a running virtual machine. All method calls to the MXBean proxy are forwarded to an MBeanServerConnection where IOException sample code for java.io.IOException definition code for java.io.IOException may be thrown when the communication problem occurs with the connector server. An application remotely accesses the platform MXBeans using proxy should prepare to catch IOException as if accessing with the MBeanServerConnector interface.
  2. When a client application is designed to remotely access MXBeans for a running virtual machine whose version is different than the version on which the application is running, it should prepare to catch InvalidObjectException sample code for java.io.InvalidObjectException definition code for java.io.InvalidObjectException which is thrown when an MXBean proxy receives a name of an enum constant which is missing in the enum class loaded in the client application.
  3. MBeanServerInvocationHandler sample code for javax.management.MBeanServerInvocationHandler definition code for javax.management.MBeanServerInvocationHandler or its newProxyInstance sample code for javax.management.MBeanServerInvocationHandler.newProxyInstance(javax.management.MBeanServerConnection, javax.management.ObjectName, java.lang.Class, boolean) definition code for javax.management.MBeanServerInvocationHandler.newProxyInstance(javax.management.MBeanServerConnection, javax.management.ObjectName, java.lang.Class, boolean) method cannot be used to create a proxy for a platform MXBean. The proxy object created by MBeanServerInvocationHandler does not handle the properties of the platform MXBeans described in the class specification.

Parameters:
connection - the MBeanServerConnection to forward to.
mxbeanName - the name of a platform MXBean within connection to forward to. mxbeanName must be in the format of ObjectName sample code for javax.management.ObjectName definition code for javax.management.ObjectName .
mxbeanInterface - the MXBean interface to be implemented by the proxy.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if
  • mxbeanName is not with a valid ObjectName sample code for javax.management.ObjectName definition code for javax.management.ObjectName format, or
  • the named MXBean in the connection is not a MXBean provided by the platform, or
  • the named MXBean is not registered in the MBeanServerConnection, or
  • the named MXBean is not an instance of the given mxbeanInterface
IOException sample code for java.io.IOException definition code for java.io.IOException - if a communication problem occurred when accessing the MBeanServerConnection.