This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


java.lang.management
class ManagementFactory

java.lang.Object extended by java.lang.management.ManagementFactory

public class ManagementFactory
extends 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. See the specification of MXBeans for details. 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 {@linkplain javax.management.openmbean.OpenType open types} 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 {@link javax.management.MBeanInfo 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 {@link 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 {@link MemoryUsage#from CompositeData representing MemoryUsage}
Verbose boolean

MXBean Names

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

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

Management Interface ObjectName
{@link CompilationMXBean} {@link #COMPILATION_MXBEAN_NAME java.lang:type=Compilation}

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

Management Interface ObjectName
{@link GarbageCollectorMXBean} {@link #GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE java.lang:type=GarbageCollector},name=collector's name
{@link MemoryManagerMXBean} {@link #MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE java.lang:type=MemoryManager},name=manager's name
{@link MemoryPoolMXBean} {@link #MEMORY_POOL_MXBEAN_DOMAIN_TYPE java.lang:type=MemoryPool},name=pool's name


Field Summary
static String CLASS_LOADING_MXBEAN_NAME
          String representation of the ObjectName for the java.lang.management.ClassLoadingMXBean.
static String COMPILATION_MXBEAN_NAME
          String representation of the ObjectName for the java.lang.management.CompilationMXBean.
static String GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE
          The domain name and the type key property in the ObjectName for a java.lang.management.GarbageCollectorMXBean.
static String MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE
          The domain name and the type key property in the ObjectName for a java.lang.management.MemoryManagerMXBean.
static String MEMORY_MXBEAN_NAME
          String representation of the ObjectName for the java.lang.management.MemoryMXBean.
static String MEMORY_POOL_MXBEAN_DOMAIN_TYPE
          The domain name and the type key property in the ObjectName for a java.lang.management.MemoryPoolMXBean.
static String OPERATING_SYSTEM_MXBEAN_NAME
          String representation of the ObjectName for the java.lang.management.OperatingSystemMXBean.
static String RUNTIME_MXBEAN_NAME
          String representation of the ObjectName for the java.lang.management.RuntimeMXBean.
static String THREAD_MXBEAN_NAME
          String representation of the ObjectName for the java.lang.management.ThreadMXBean.
 
Method Summary
static ClassLoadingMXBean

          Returns the managed bean for the class loading system of the Java virtual machine.
static CompilationMXBean

          Returns the managed bean for the compilation system of the Java virtual machine.
static List

          Returns a list of java.lang.management.GarbageCollectorMXBean objects in the Java virtual machine.
static List

          Returns a list of java.lang.management.MemoryManagerMXBean objects in the Java virtual machine.
static MemoryMXBean

          Returns the managed bean for the memory system of the Java virtual machine.
static List

          Returns a list of java.lang.management.MemoryPoolMXBean objects in the Java virtual machine.
static OperatingSystemMXBean

          Returns the managed bean for the operating system on which the Java virtual machine is running.
static MBeanServer

          Returns the platform javax.management.MBeanServer.
static RuntimeMXBean

          Returns the managed bean for the runtime system of the Java virtual machine.
static ThreadMXBean

          Returns the managed bean for the thread system of the Java virtual machine.
static Object
newPlatformMXBeanProxy(MBeanServerConnection connection, String mxbeanName, Class 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_LOADING_MXBEAN_NAME

public static final String CLASS_LOADING_MXBEAN_NAME
String representation of the ObjectName for the {@link ClassLoadingMXBean}.

COMPILATION_MXBEAN_NAME

public static final String COMPILATION_MXBEAN_NAME
String representation of the ObjectName for the {@link CompilationMXBean}.

GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE

public static final String GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE
The domain name and the type key property in the ObjectName for a {@link GarbageCollectorMXBean}. The unique ObjectName for a GarbageCollectorMXBean can be formed by appending this string with ",name=collector's name".

MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE

public static final String MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE
The domain name and the type key property in the ObjectName for a {@link MemoryManagerMXBean}. The unique ObjectName for a MemoryManagerMXBean can be formed by appending this string with ",name=manager's name".

MEMORY_MXBEAN_NAME

public static final String MEMORY_MXBEAN_NAME
String representation of the ObjectName for the {@link MemoryMXBean}.

MEMORY_POOL_MXBEAN_DOMAIN_TYPE

public static final String MEMORY_POOL_MXBEAN_DOMAIN_TYPE
The domain name and the type key property in the ObjectName for a {@link MemoryPoolMXBean}. The unique ObjectName for a MemoryPoolMXBean can be formed by appending this string with ,name=pool's name.

OPERATING_SYSTEM_MXBEAN_NAME

public static final String OPERATING_SYSTEM_MXBEAN_NAME
String representation of the ObjectName for the {@link OperatingSystemMXBean}.

RUNTIME_MXBEAN_NAME

public static final String RUNTIME_MXBEAN_NAME
String representation of the ObjectName for the {@link RuntimeMXBean}.

THREAD_MXBEAN_NAME

public static final String THREAD_MXBEAN_NAME
String representation of the ObjectName for the {@link ThreadMXBean}.
Method Detail

getClassLoadingMXBean

public static ClassLoadingMXBean getClassLoadingMXBean()
Returns the managed bean for the class loading system of the Java virtual machine.

Returns:
a {@link ClassLoadingMXBean} object for the Java virtual machine.

getCompilationMXBean

public static 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 {@link CompilationMXBean} object for the Java virtual machine or null if the Java virtual machine has no compilation system.

getGarbageCollectorMXBeans

public static List getGarbageCollectorMXBeans()
Returns a list of {@link 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.

getMemoryManagerMXBeans

public static List getMemoryManagerMXBeans()
Returns a list of {@link 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.

getMemoryMXBean

public static MemoryMXBean getMemoryMXBean()
Returns the managed bean for the memory system of the Java virtual machine.

Returns:
a {@link MemoryMXBean} object for the Java virtual machine.

getMemoryPoolMXBeans

public static List getMemoryPoolMXBeans()
Returns a list of {@link 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.

getOperatingSystemMXBean

public static OperatingSystemMXBean getOperatingSystemMXBean()
Returns the managed bean for the operating system on which the Java virtual machine is running.

Returns:
an {@link OperatingSystemMXBean} object for the Java virtual machine.

getPlatformMBeanServer

public static synchronized MBeanServer getPlatformMBeanServer()
Returns the platform {@link javax.management.MBeanServer MBeanServer}. On the first call to this method, it first creates the platform MBeanServer by calling the {@link javax.management.MBeanServerFactory#createMBeanServer 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 {@link MemoryPoolMXBean pools} and {@link MemoryManagerMXBean managers}, 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 {@link 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.

getRuntimeMXBean

public static RuntimeMXBean getRuntimeMXBean()
Returns the managed bean for the runtime system of the Java virtual machine.

Returns:
a {@link RuntimeMXBean} object for the Java virtual machine.

getThreadMXBean

public static ThreadMXBean getThreadMXBean()
Returns the managed bean for the thread system of the Java virtual machine.

Returns:
a {@link ThreadMXBean} object for the Java virtual machine.

newPlatformMXBeanProxy

public static Object newPlatformMXBeanProxy(MBeanServerConnection connection,
                                            String mxbeanName,
                                            Class mxbeanInterface)
                                     throws 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:

{@link java.lang.reflect.Proxy#newProxyInstance Proxy.newProxyInstance}(mxbeanInterface.getClassLoader(), new Class[] { mxbeanInterface }, handler)
where handler is an {@link java.lang.reflect.InvocationHandler 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 {@link javax.management.NotificationEmitter 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 {@link java.io.IOException 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 {@link java.io.InvalidObjectException 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. {@link javax.management.MBeanServerInvocationHandler MBeanServerInvocationHandler} or its {@link javax.management.MBeanServerInvocationHandler#newProxyInstance newProxyInstance} 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 {@link ObjectName ObjectName}.
mxbeanInterface - the MXBean interface to be implemented by the proxy.
Throws:
IOException - if a communication problem occurred when accessing the MBeanServerConnection.


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.