java.lang.management
Class ManagementFactory

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

public class ManagementFactory
extends Object

ManagementFactory class is a factory class for getting managed beans for the Java platform.

This class consists of static methods each of which returns an instance or a list of all instances implementing the management interface of one component of the Java virtual machine. An instance implementing a management interface is a managed bean (MBean) conforming to the JMX instrumentation specification. An application can monitor the instrumentation of the Java virtual machine and manage certain characteristics in any of the following ways:

The latter two methods require the MBean to be registered in an MBeanServer. This class provides a static method getPlatformMBeanServer() to return the platform MBeanServer registered with all MBeans for the platform. Each MBean has a unique ObjectName to register in an MBeanServer.

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

Management Interface ObjectName
ClassLoadingMBean java.lang:type=ClassLoading
MemoryMBean java.lang:type=Memory
ThreadMBean java.lang:type=Threading
RuntimeMBean java.lang:type=Runtime
OperatingSystemMBean java.lang:type=OperatingSystem

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

Management Interface ObjectName
CompilationMBean java.lang:type=Compilation

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

Management Interface ObjectName
GarbageCollectorMBean java.lang:type=GarbageCollector,name=collector's name
MemoryManagerMBean java.lang:type=MemoryManager,name=manager's name
MemoryPoolMBean java.lang:type=MemoryPool,name=pool's name

Since:
1.5
See Also:
Ways to Access Management Metrics

Field Summary
static String CLASS_LOADING_MBEAN_NAME
          String representation of the ObjectName for the ClassLoadingMBean.
static String COMPILATION_MBEAN_NAME
          String representation of the ObjectName for the CompilationMBean.
static String GARBAGE_COLLECTOR_MBEAN_DOMAIN_TYPE
          The domain name and the type key property in the ObjectName for a GarbageCollectorMBean.
static String MEMORY_MANAGER_MBEAN_DOMAIN_TYPE
          The domain name and the type key property in the ObjectName for a MemoryManagerMBean.
static String MEMORY_MBEAN_NAME
          String representation of the ObjectName for the MemoryMBean.
static String MEMORY_POOL_MBEAN_DOMAIN_TYPE
          The domain name and the type key property in the ObjectName for a MemoryPoolMBean.
static String OPERATING_SYSTEM_MBEAN_NAME
          String representation of the ObjectName for the OperatingSystemMBean.
static String RUNTIME_MBEAN_NAME
          String representation of the ObjectName for the RuntimeMBean.
static String THREAD_MBEAN_NAME
          String representation of the ObjectName for the ThreadMBean.
 
Method Summary
static ClassLoadingMBean getClassLoadingMBean()
          Returns the managed bean for the class loading system of the Java virtual machine.
static CompilationMBean getCompilationMBean()
          Returns the managed bean for the compilation system of the Java virtual machine.
static List getGarbageCollectorMBeans()
          Returns a list of GarbageCollectorMBean objects in the Java virtual machine.
static List getMemoryManagerMBeans()
          Returns a list of MemoryManagerMBean objects in the Java virtual machine.
static MemoryMBean getMemoryMBean()
          Returns the managed bean for the memory system of the Java virtual machine.
static List getMemoryPoolMBeans()
          Returns a list of MemoryPoolMBean objects in the Java virtual machine.
static OperatingSystemMBean getOperatingSystemMBean()
          Returns the managed bean for the operating system on which the Java virtual machine is running.
static MBeanServer getPlatformMBeanServer()
          Returns the platform MBeanServer.
static RuntimeMBean getRuntimeMBean()
          Returns the managed bean for the runtime system of the Java virtual machine.
static ThreadMBean getThreadMBean()
          Returns the managed bean for the thread system of the Java virtual machine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_LOADING_MBEAN_NAME

public static final String CLASS_LOADING_MBEAN_NAME
String representation of the ObjectName for the ClassLoadingMBean.

See Also:
Constant Field Values

COMPILATION_MBEAN_NAME

public static final String COMPILATION_MBEAN_NAME
String representation of the ObjectName for the CompilationMBean.

See Also:
Constant Field Values

MEMORY_MBEAN_NAME

public static final String MEMORY_MBEAN_NAME
String representation of the ObjectName for the MemoryMBean.

See Also:
Constant Field Values

OPERATING_SYSTEM_MBEAN_NAME

public static final String OPERATING_SYSTEM_MBEAN_NAME
String representation of the ObjectName for the OperatingSystemMBean.

See Also:
Constant Field Values

RUNTIME_MBEAN_NAME

public static final String RUNTIME_MBEAN_NAME
String representation of the ObjectName for the RuntimeMBean.

See Also:
Constant Field Values

THREAD_MBEAN_NAME

public static final String THREAD_MBEAN_NAME
String representation of the ObjectName for the ThreadMBean.

See Also:
Constant Field Values

GARBAGE_COLLECTOR_MBEAN_DOMAIN_TYPE

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

See Also:
Constant Field Values

MEMORY_MANAGER_MBEAN_DOMAIN_TYPE

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

See Also:
Constant Field Values

MEMORY_POOL_MBEAN_DOMAIN_TYPE

public static final String MEMORY_POOL_MBEAN_DOMAIN_TYPE
The domain name and the type key property in the ObjectName for a MemoryPoolMBean. The unique ObjectName for a MemoryPoolMBean can be formed by appending this string with ,name=pool's name.

See Also:
Constant Field Values
Method Detail

getClassLoadingMBean

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

Returns:
a ClassLoadingMBean object for the Java virtual machine.

getMemoryMBean

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

Returns:
a MemoryMBean object for the Java virtual machine.

getThreadMBean

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

Returns:
a ThreadMBean object for the Java virtual machine.

getRuntimeMBean

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

Returns:
a RuntimeMBean object for the Java virtual machine.

getCompilationMBean

public static CompilationMBean getCompilationMBean()
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 CompilationMBean object for the Java virtual machine or null if the Java virtual machine has no compilation system.

getOperatingSystemMBean

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

Returns:
an OperatingSystemMBean object for the Java virtual machine.

getMemoryPoolMBeans

public static List getMemoryPoolMBeans()
Returns a list of MemoryPoolMBean 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 MemoryPoolMBean objects.

getMemoryManagerMBeans

public static List getMemoryManagerMBeans()
Returns a list of MemoryManagerMBean 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 MemoryManagerMBean objects.

getGarbageCollectorMBeans

public static List getGarbageCollectorMBeans()
Returns a list of GarbageCollectorMBean objects in the Java virtual machine. The Java virtual machine may have one or more GarbageCollectorMBean objects. It may add or remove GarbageCollectorMBean during execution.

Returns:
a list of GarbageCollectorMBean objects.

getPlatformMBeanServer

public static MBeanServer getPlatformMBeanServer()
Returns the platform MBeanServer. On the first call to this method, it first creates the platform MBeanServer by calling the MBeanServerFactory.createMBeanServer() method and registers the platform MBeans in this platform MBeanServer using the MBean names defined in the class description. This method, in subsequent calls, will simply return the initially created platform MBeanServer.

MBeans that get created and destroyed dynamically, for example, memory pools and 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 MBeanServerBuilder.

It is recommended that this platform MBeanServer also be used to register other application MBeans besides the platform MBeans. 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 MBeans should be avoided.

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