java.lang.management

Class 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. 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 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 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 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 NameType
HeapMemoryUsageCompositeData representing MemoryUsage
Verboseboolean

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.

MXBean Names

Each platform MXBean for a Java virtual machine has a unique ObjectName for registration in the platform MBeanServer. A Java virtual machine has a single instance of the following management interfaces:
Management InterfaceObjectName
ClassLoadingMXBean java.lang:type=ClassLoading
MemoryMXBean java.lang:type=Memory
ThreadMXBean java.lang:type=Threading
RuntimeMXBean java.lang:type=Runtime
OperatingSystemMXBean java.lang:type=OperatingSystem

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

Management InterfaceObjectName
CompilationMXBean java.lang:type=Compilation

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

Management InterfaceObjectName
GarbageCollectorMXBean java.lang:type=GarbageCollector,name=collector's name
MemoryManagerMXBean java.lang:type=MemoryManager,name=manager's name
MemoryPoolMXBean java.lang:type=MemoryPool,name=pool's name
Since:
1.5
See Also:
JMX Specification., Ways to Access Management Metrics, LoggingMXBean

Field Summary

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

Method Summary

static
T 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.
static ClassLoadingMXBean
getClassLoadingMXBean()
Returns the managed bean for the class loading system of the Java virtual machine.
static CompilationMXBean
getCompilationMXBean()
Returns the managed bean for the compilation system of the Java virtual machine.
static List
getGarbageCollectorMXBeans()
Returns a list of GarbageCollectorMXBean objects in the Java virtual machine.
static MemoryMXBean
getMemoryMXBean()
Returns the managed bean for the memory system of the Java virtual machine.
static List
getMemoryManagerMXBeans()
Returns a list of MemoryManagerMXBean objects in the Java virtual machine.
static List
getMemoryPoolMXBeans()
Returns a list of MemoryPoolMXBean objects in the Java virtual machine.
static OperatingSystemMXBean
getOperatingSystemMXBean()
Returns the managed bean for the operating system on which the Java virtual machine is running.
static MBeanServer
getPlatformMBeanServer()
Returns the platform MBeanServer.
static RuntimeMXBean
getRuntimeMXBean()
Returns the managed bean for the runtime system of the Java virtual machine.
static ThreadMXBean
getThreadMXBean()
Returns the managed bean for the thread system of the Java virtual machine.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

CLASS_LOADING_MXBEAN_NAME

public static final String CLASS_LOADING_MXBEAN_NAME
String representation of the ObjectName for the ClassLoadingMXBean.
Field Value:
"java.lang:type=ClassLoading"
Usages and Demos :

View More Examples of ManagementFactory.CLASS_LOADING_MXBEAN_NAME
   1:             final ClassLoadingMXBean clmb = ManagementFactory.newPlatformMXBeanProxy(mbsc, 
   2:                     ManagementFactory.CLASS_LOADING_MXBEAN_NAME, ClassLoadingMXBean.class);
   3:             sb.append(sm.getString("classloading.info"));
   4:             sb.append(sm.getString("classes.loaded", clmb.getLoadedClassCount()));
   5:             sb.append(sm.getString("classes.total", clmb.getTotalLoadedClassCount()));

View Full Code Here

COMPILATION_MXBEAN_NAME

public static final String COMPILATION_MXBEAN_NAME
String representation of the ObjectName for the CompilationMXBean.
Field Value:
"java.lang:type=Compilation"
Usages and Demos :

View More Examples of ManagementFactory.COMPILATION_MXBEAN_NAME
   1:             final CompilationMXBean cmb = ManagementFactory.newPlatformMXBeanProxy(mbsc, 
   2:                     ManagementFactory.COMPILATION_MXBEAN_NAME, CompilationMXBean.class);
   3:             sb.append(sm.getString("complilation.info"));
   4:             sb.append(sm.getString("compilation.monitor.status", cmb.isCompilationTimeMonitoringSupported()));
   5:             sb.append(sm.getString("jit.compilar.name", cmb.getName()));

View Full Code Here

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 GarbageCollectorMXBean. The unique ObjectName for a GarbageCollectorMXBean can be formed by appending this string with ",name=collector's name".
Field Value:
"java.lang:type=GarbageCollector"
Usages and Demos :

View More Examples of ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE
   1:             ObjectName poolName = new ObjectName(ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE+",*");;
   2:             ObjectName gcName = new ObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE+",*");
   3:             Set mbeans = mbsc.queryNames(poolName, null);
   4:             if (mbeans != null) {
   5:                 pools = new ArrayList<MemoryPoolMXBean>();

View Full Code Here

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 MemoryManagerMXBean. The unique ObjectName for a MemoryManagerMXBean can be formed by appending this string with ",name=manager's name".
Field Value:
"java.lang:type=MemoryManager"

MEMORY_MXBEAN_NAME

public static final String MEMORY_MXBEAN_NAME
String representation of the ObjectName for the MemoryMXBean.
Field Value:
"java.lang:type=Memory"
Usages and Demos :

View More Examples of ManagementFactory.MEMORY_MXBEAN_NAME
   1:             this.mmbean = ManagementFactory.newPlatformMXBeanProxy(mbsc,
   2:                                                  ManagementFactory.MEMORY_MXBEAN_NAME,
   3:                                                  MemoryMXBean.class);
   4:             ObjectName poolName = new ObjectName(ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE+",*");;
   5:             ObjectName gcName = new ObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE+",*");

View Full Code Here

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 MemoryPoolMXBean. The unique ObjectName for a MemoryPoolMXBean can be formed by appending this string with ,name=pool's name.
Field Value:
"java.lang:type=MemoryPool"
Usages and Demos :

View More Examples of ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE
   1:                                                  MemoryMXBean.class);
   2:             ObjectName poolName = new ObjectName(ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE+",*");;
   3:             ObjectName gcName = new ObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE+",*");
   4:             Set mbeans = mbsc.queryNames(poolName, null);
   5:             if (mbeans != null) {

View Full Code Here

OPERATING_SYSTEM_MXBEAN_NAME

public static final String OPERATING_SYSTEM_MXBEAN_NAME
String representation of the ObjectName for the OperatingSystemMXBean.
Field Value:
"java.lang:type=OperatingSystem"
Usages and Demos :

View More Examples of ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME
   1:             final OperatingSystemMXBean os = ManagementFactory.newPlatformMXBeanProxy(mbsc,
   2:                     ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, OperatingSystemMXBean.class);
   3:             sb.append(getOSInfo(os));
   4:             final RuntimeMXBean rt = ManagementFactory.newPlatformMXBeanProxy(mbsc,
   5:                     ManagementFactory.RUNTIME_MXBEAN_NAME, RuntimeMXBean.class);

View Full Code Here

RUNTIME_MXBEAN_NAME

public static final String RUNTIME_MXBEAN_NAME
String representation of the ObjectName for the RuntimeMXBean.
Field Value:
"java.lang:type=Runtime"
Usages and Demos :

View More Examples of ManagementFactory.RUNTIME_MXBEAN_NAME
   1:             final RuntimeMXBean rt = ManagementFactory.newPlatformMXBeanProxy(mbsc,
   2:                     ManagementFactory.RUNTIME_MXBEAN_NAME, RuntimeMXBean.class);
   3:             sb.append(getVMInfo(rt));
   4:             return ( sb.toString(secretProperty) );
   5:         } catch(final Exception e) {

View Full Code Here
   1:     private String getTitle() throws Exception {
   2:         final RuntimeMXBean rt  = ManagementFactory.newPlatformMXBeanProxy(mbsc, ManagementFactory.RUNTIME_MXBEAN_NAME, RuntimeMXBean.class);
   3:         final String vmname     = rt.getVmName();
   4:         final String vmversion  = rt.getVmVersion();
   5:         final String vmvendor   = rt.getVmVendor();

View Full Code Here
   1:             this.rmbean = ManagementFactory.newPlatformMXBeanProxy(mbsc,
   2:                                                  ManagementFactory.RUNTIME_MXBEAN_NAME,
   3:                                                  RuntimeMXBean.class);
   4:             this.mmbean = ManagementFactory.newPlatformMXBeanProxy(mbsc,
   5:                                                  ManagementFactory.MEMORY_MXBEAN_NAME,

View Full Code Here

THREAD_MXBEAN_NAME

public static final String THREAD_MXBEAN_NAME
String representation of the ObjectName for the ThreadMXBean.
Field Value:
"java.lang:type=Threading"
Usages and Demos :

View More Examples of ManagementFactory.THREAD_MXBEAN_NAME
   1:         try {
   2:             final ThreadMXBean tmx = ManagementFactory.newPlatformMXBeanProxy(mbsc, ManagementFactory.THREAD_MXBEAN_NAME, ThreadMXBean.class);
   3:             final String title = getTitle();
   4:             td.append(title); 
   5:             final long[] tids = tmx.getAllThreadIds();

View Full Code Here

Method Details

T newPlatformMXBeanProxy

public static  T
        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:

Proxy.newProxyInstance(mxbeanInterface.getClassLoader(), new Class[] { mxbeanInterface }, handler)
where handler is an 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), 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 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 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 or its 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 ObjectName.
mxbeanInterface - the MXBean interface to be implemented by the proxy.
Throws:
IllegalArgumentException - if
  • mxbeanName is not with a valid 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 - if a communication problem occurred when accessing the MBeanServerConnection.

getClassLoadingMXBean

public static ClassLoadingMXBean getClassLoadingMXBean()
Returns the managed bean for the class loading system of the Java virtual machine.
Returns:
a ClassLoadingMXBean object for the Java virtual machine.
Usages and Demos :

View More Examples of getClassLoadingMXBean()
   1: 
   2: import java.lang.management.ManagementFactory;
   3: 
   4:         ...
   5:   public void initContainer(ExoContainer container) {
   6:     container.registerComponentInstance(ManagementFactory.getOperatingSystemMXBean()) ;
   7:         ...
   8:     container.registerComponentInstance(ManagementFactory.getRuntimeMXBean()) ;
   9:     container.registerComponentInstance(ManagementFactory.getThreadMXBean()) ;
  10:         ...
  11:     container.registerComponentInstance(ManagementFactory.getClassLoadingMXBean()) ;

View Full Code Here

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 CompilationMXBean object for the Java virtual machine or null if the Java virtual machine has no compilation system.
Usages and Demos :

View More Examples of getCompilationMXBean()
   1: 
   2: import java.lang.management.ManagementFactory;
   3: 
   4:         ...
   5:   public void initContainer(ExoContainer container) {
   6:     container.registerComponentInstance(ManagementFactory.getOperatingSystemMXBean()) ;
   7:         ...
   8:     container.registerComponentInstance(ManagementFactory.getRuntimeMXBean()) ;
   9:     container.registerComponentInstance(ManagementFactory.getThreadMXBean()) ;
  10:         ...
  11:     container.registerComponentInstance(ManagementFactory.getClassLoadingMXBean()) ;
  12:     container.registerComponentInstance(ManagementFactory.getCompilationMXBean()) ;

View Full Code Here

getGarbageCollectorMXBeans

public static List getGarbageCollectorMXBeans()
Returns a list of 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.
Usages and Demos :

View More Examples of getGarbageCollectorMXBeans()
   1: 
   2: import java.lang.management.ManagementFactory;
   3: 
   4:         ...
   5:   public void initContainer(ExoContainer container) {
   6:     container.registerComponentInstance(ManagementFactory.getOperatingSystemMXBean()) ;
   7:         ...
   8:     container.registerComponentInstance(ManagementFactory.getRuntimeMXBean()) ;
   9:     container.registerComponentInstance(ManagementFactory.getThreadMXBean()) ;
  10:         ...
  11:     container.registerComponentInstance(JVMRuntimeInfo.MEMORY_POOL_MXBEANS, ManagementFactory.getMemoryPoolMXBeans()) ;
  12:     container.registerComponentInstance(JVMRuntimeInfo.GARBAGE_COLLECTOR_MXBEANS, ManagementFactory.getGarbageCollectorMXBeans()) ;

View Full Code Here
   1: import java.lang.management.GarbageCollectorMXBean;
   2: import java.lang.management.ManagementFactory;
   3: 
   4:         ...
   5:   {
   6:     Iterator beans = ManagementFactory.getGarbageCollectorMXBeans().iterator();
   7:     while (beans.hasNext())
   8:       {
   9:     GarbageCollectorMXBean bean = (GarbageCollectorMXBean) beans.next();

View Full Code Here
   1: import java.util.logging.Logger;
   2: import java.lang.management.ManagementFactory;
   3: import java.lang.management.GarbageCollectorMXBean;
   4:         ...
   5:         gcsNode.registerMBean();
   6:         List beanList = ManagementFactory.getGarbageCollectorMXBeans();
   7:         Iterator iter = beanList.iterator();
   8:         ...
   9:         assert(threadSystemNode != null): "thread-system node is null";
  10:         ThreadMXBean bean = ManagementFactory.getThreadMXBean();
  11:         long ids[] = bean.getAllThreadIds();

View Full Code Here

getMemoryMXBean

public static MemoryMXBean getMemoryMXBean()
Returns the managed bean for the memory system of the Java virtual machine.
Returns:
a MemoryMXBean object for the Java virtual machine.
Usages and Demos :

View More Examples of getMemoryMXBean()
   1:   {
   2:     MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
   3: 
   4:         ...
   5: 
   6:     ClassLoadingMXBean classLoadingMXBean = ManagementFactory.getClassLoadingMXBean();
   7:   }
   8: }

View Full Code Here
   1: 
   2: import java.lang.management.ManagementFactory;
   3: import java.lang.management.MemoryMXBean;
   4:         ...
   5:   public MemoryInfo() {
   6:     mxbean_ = ManagementFactory.getMemoryMXBean();
   7:   }
   8:   
   9:   public MemoryUsage getHeapMemoryUsage() { 

View Full Code Here
   1: import java.io.IOException;
   2: import java.lang.management.ManagementFactory;
   3: 
   4:         ...
   5:         AsyncServerSocket[] sockets = new AsyncServerSocket[100000];
   6:         long mem = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed();
   7:         ...
   8:         System.out.println(ManagementFactory.getMemoryMXBean().getHeapMemoryUsage());
   9:         time = System.currentTimeMillis();
  10:         ...
  11:         } finally {
  12:             System.out.println(ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() - mem);

View Full Code Here
   1: import java.awt.event.KeyEvent;
   2: import java.lang.management.ManagementFactory;
   3: import java.lang.management.MemoryMXBean;
   4:         ...
   5:     public boolean dispatch(KeyEvent evt, IApplicationWindow window) {
   6:         MemoryMXBean memory = ManagementFactory.getMemoryMXBean();
   7:         System.out.println("*** Before GC ***");
   8:         reportStatus(memory);
   9:         memory.gc();

View Full Code Here
   1: import java.lang.management.MemoryMXBean;
   2: import java.lang.management.ManagementFactory;
   3: 
   4:         ...
   5:   {
   6:     MemoryMXBean bean = ManagementFactory.getMemoryMXBean();
   7:     System.out.println("Bean: " + bean);
   8:     System.out.println("Heap memory usage: " 
   9:                + bean.getHeapMemoryUsage());

View Full Code Here

getMemoryManagerMXBeans

public static List getMemoryManagerMXBeans()
Returns a list of 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.
Usages and Demos :

View More Examples of getMemoryManagerMXBeans()
   1: 
   2: import java.lang.management.ManagementFactory;
   3: import java.lang.management.MemoryManagerMXBean;
   4:         ...
   5:   {
   6:     Iterator beans = ManagementFactory.getMemoryManagerMXBeans().iterator();
   7:     while (beans.hasNext())
   8:       {
   9:     MemoryManagerMXBean bean = (MemoryManagerMXBean) beans.next();

View Full Code Here
   1: 
   2: import java.lang.management.ManagementFactory;
   3: 
   4:         ...
   5:   public void initContainer(ExoContainer container) {
   6:     container.registerComponentInstance(ManagementFactory.getOperatingSystemMXBean()) ;
   7:         ...
   8:     container.registerComponentInstance(ManagementFactory.getRuntimeMXBean()) ;
   9:     container.registerComponentInstance(ManagementFactory.getThreadMXBean()) ;
  10:         ...
  11:     container.registerComponentInstance(new MemoryInfo()) ;
  12:     container.registerComponentInstance(JVMRuntimeInfo.MEMORY_MANAGER_MXBEANS, ManagementFactory.getMemoryManagerMXBeans()) ;

View Full Code Here

getMemoryPoolMXBeans

public static List getMemoryPoolMXBeans()
Returns a list of 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.
Usages and Demos :

View More Examples of getMemoryPoolMXBeans()
   1: 
   2: import java.lang.management.ManagementFactory;
   3: 
   4:         ...
   5:   public void initContainer(ExoContainer container) {
   6:     container.registerComponentInstance(ManagementFactory.getOperatingSystemMXBean()) ;
   7:         ...
   8:     container.registerComponentInstance(ManagementFactory.getRuntimeMXBean()) ;
   9:     container.registerComponentInstance(ManagementFactory.getThreadMXBean()) ;
  10:         ...
  11:     container.registerComponentInstance(JVMRuntimeInfo.MEMORY_MANAGER_MXBEANS, ManagementFactory.getMemoryManagerMXBeans()) ;
  12:     container.registerComponentInstance(JVMRuntimeInfo.MEMORY_POOL_MXBEANS, ManagementFactory.getMemoryPoolMXBeans()) ;

View Full Code Here
   1: 
   2:                         ThreadMXBean tb = ManagementFactory.getThreadMXBean();
   3:                         out.printf("Current thread count: %d%n",
   4:         ...
   5:                         List<MemoryPoolMXBean> pools = 
   6:                             ManagementFactory.getMemoryPoolMXBeans();
   7:                         for(MemoryPoolMXBean pool: pools) {
   8:                             MemoryUsage peak = pool.getPeakUsage();
   9:                             out.printf("Peak %s memory used: %,d%n",

View Full Code Here
   1: 
   2: import java.lang.management.ManagementFactory;
   3: import java.lang.management.MemoryPoolMXBean;
   4:         ...
   5:     List managedPools = new ArrayList();
   6:     Iterator beans = ManagementFactory.getMemoryPoolMXBeans().iterator();
   7:     while (beans.hasNext())
   8:       {
   9:     MemoryPoolMXBean bean = (MemoryPoolMXBean) beans.next();

View Full Code Here
   1: 
   2: import java.lang.management.ManagementFactory;
   3: import java.lang.management.MemoryPoolMXBean;
   4:         ...
   5:   {
   6:     Iterator beans = ManagementFactory.getMemoryPoolMXBeans().iterator();
   7:     while (beans.hasNext())
   8:       {
   9:     MemoryPoolMXBean bean = (MemoryPoolMXBean) beans.next();

View Full Code Here
   1: 
   2: import java.lang.management.ManagementFactory;
   3: import java.lang.management.MemoryPoolMXBean;
   4:         ...
   5:    public static long maxJvmMemory() {
   6:        MemoryMXBean mbean = ManagementFactory.getMemoryMXBean();
   7:        MemoryUsage usage = mbean.getHeapMemoryUsage() ;
   8:         ...
   9: 
  10:       List list = ManagementFactory.getMemoryPoolMXBeans();
  11:       Iterator it = list.iterator();
  12:         ...
  13:       if (this.pool != null) {
  14:          MemoryMXBean mbean = ManagementFactory.getMemoryMXBean();

View Full Code Here

getOperatingSystemMXBean

public static OperatingSystemMXBean getOperatingSystemMXBean()
Returns the managed bean for the operating system on which the Java virtual machine is running.
Returns:
an OperatingSystemMXBean object for the Java virtual machine.
Usages and Demos :

View More Examples of getOperatingSystemMXBean()
   1: 
   2: import java.lang.management.ManagementFactory;
   3: import java.lang.management.OperatingSystemMXBean;
   4:         ...
   5:   {
   6:     OperatingSystemMXBean osBean = ManagementFactory.getOperatingSystemMXBean();
   7:     System.out.println("Bean: " + osBean);
   8:     System.out.println("OS Name: " + osBean.getName());
   9:     System.out.println("OS Version: " + osBean.getVersion());

View Full Code Here
   1: 
   2: import java.lang.management.ManagementFactory;
   3: import java.lang.management.OperatingSystemMXBean;
   4:         ...
   5:   public OperatingSystemInfoImpl() {
   6:     mxbean_ = ManagementFactory.getOperatingSystemMXBean();
   7:   }
   8:   
   9:   public String getArch() { return mxbean_.getArch() ; }

View Full Code Here
   1: 
   2: import java.lang.management.ManagementFactory;
   3: 
   4:         ...
   5:   public void initContainer(ExoContainer container) {
   6:     container.registerComponentInstance(ManagementFactory.getOperatingSystemMXBean()) ;
   7:         ...
   8:     container.registerComponentInstance(ManagementFactory.getRuntimeMXBean()) ;
   9:         ...
  10:     container.registerComponentInstance(ManagementFactory.getThreadMXBean()) ;

View Full Code Here
   1:             {
   2:             final OperatingSystemMXBean operatingSystemMXBean = java.lang.management.ManagementFactory.getOperatingSystemMXBean();
   3:             if(operatingSystemMXBean.getSystemLoadAverage() >= LIGHT_LOAD_FRACTION * operatingSystemMXBean.getAvailableProcessors())
   4:                 { _lastNotLightlyLoaded = now; return(false); }
   5:             }

View Full Code Here

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 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 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 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 - if there is a security manager and the caller does not have the permission required by javax.management.MBeanServerFactory.createMBeanServer.
See Also:
MBeanServerFactory, javax.management.MBeanServerFactory.createMBeanServer
Usages and Demos :

View More Examples of getPlatformMBeanServer()
   1: 
   2: import java.lang.management.ManagementFactory;
   3: import javax.management.*;
   4:         ...
   5:   {
   6:     MBeanServer server = ManagementFactory.getPlatformMBeanServer();
   7:     System.out.println( server.getMBeanCount() );
   8: 
   9:     for ( Object object : server.queryMBeans(new ObjectName("*:*"), null) )

View Full Code Here
   1: 
   2: import java.lang.management.ManagementFactory;
   3: import javax.management.*;
   4:         ...
   5:   {
   6:     MBeanServer server = ManagementFactory.getPlatformMBeanServer();
   7:     ObjectName name = new ObjectName( "com.javatutor.insel.jmx:type=Disko" ); 
   8:     DiskoMBean disko = new Disko();
   9:     server.registerMBean( disko, name );

View Full Code Here
   1: 
   2: import java.lang.management.ManagementFactory;
   3: 
   4:         ...
   5:         Worker worker = new Worker();
   6:         MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
   7: 
   8:         try {
   9:             ObjectName name = new ObjectName("wrox.ch12.jmx:type=Worker");

View Full Code Here
   1: 
   2: import java.lang.management.ManagementFactory;
   3: 
   4:         ...
   5:         JMSWorker worker = new JMSWorker("queue/work-start");
   6:         MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
   7: 
   8:         try {
   9:             ObjectName name = new ObjectName("wrox.ch12.jmx:type=Worker");

View Full Code Here
   1:     {
   2:       MBeanServer mbs=ManagementFactory.getPlatformMBeanServer();
   3:       mbs.registerMBean(new MBeanServerDelegate(),new ObjectName("jdistro:type=test"));
   4:     }
   5:     catch(InstanceAlreadyExistsException ex) { }

View Full Code Here

getRuntimeMXBean

public static RuntimeMXBean getRuntimeMXBean()
Returns the managed bean for the runtime system of the Java virtual machine.
Returns:
a RuntimeMXBean object for the Java virtual machine.
Usages and Demos :

View More Examples of getRuntimeMXBean()
   1: 
   2: import java.lang.management.ManagementFactory;
   3: 
   4:         ...
   5:   public void initContainer(ExoContainer container) {
   6:     container.registerComponentInstance(ManagementFactory.getOperatingSystemMXBean()) ;
   7:         ...
   8:     container.registerComponentInstance(ManagementFactory.getRuntimeMXBean()) ;
   9:         ...
  10:     container.registerComponentInstance(ManagementFactory.getThreadMXBean()) ;

View Full Code Here
   1: 
   2: import java.lang.management.ManagementFactory;
   3: import java.lang.management.RuntimeMXBean;
   4:         ...
   5:   {
   6:     RuntimeMXBean vmBean = ManagementFactory.getRuntimeMXBean();
   7:     System.out.println("Bean: " + vmBean);
   8:     boolean bootClassPath = vmBean.isBootClassPathSupported();
   9:     System.out.println("Boot Class Path Supported: " + bootClassPath);

View Full Code Here
   1: 
   2: import java.lang.management.ManagementFactory;
   3: import java.lang.management.RuntimeMXBean;
   4:         ...
   5:   public JVMRuntimeInfoImpl(InitParams params ) throws Exception {
   6:     mxbean_ = ManagementFactory.getRuntimeMXBean();
   7:     
   8:     PropertiesParam param = params.getPropertiesParam("add.system.properties") ;
   9:     if(param != null) {

View Full Code Here

getThreadMXBean

public static ThreadMXBean getThreadMXBean()
Returns the managed bean for the thread system of the Java virtual machine.
Returns:
a ThreadMXBean object for the Java virtual machine.
Usages and Demos :

View More Examples of getThreadMXBean()
   1: 
   2: import java.lang.management.ManagementFactory;
   3: 
   4:         ...
   5:   public void initContainer(ExoContainer container) {
   6:     container.registerComponentInstance(ManagementFactory.getOperatingSystemMXBean()) ;
   7:         ...
   8:     container.registerComponentInstance(ManagementFactory.getRuntimeMXBean()) ;
   9:         ...
  10:     container.registerComponentInstance(ManagementFactory.getThreadMXBean()) ;

View Full Code Here
   1:     {
   2:       ThreadMXBean tm=ManagementFactory.getThreadMXBean();
   3:       monitoring_&=tm.isThreadCpuTimeSupported();
   4:         ...
   5:     {
   6:       ThreadMXBean  tm=ManagementFactory.getThreadMXBean();
   7:       long[]        ti=tm.getAllThreadIds();
   8:       long tt=0l;
   9:       for(int i=0;i<ti.length;i++)

View Full Code Here
   1: 
   2:                         ThreadMXBean tb = ManagementFactory.getThreadMXBean();
   3:                         out.printf("Current thread count: %d%n",
   4:         ...
   5:                         List<MemoryPoolMXBean> pools = 
   6:                             ManagementFactory.getMemoryPoolMXBeans();
   7:                         for(MemoryPoolMXBean pool: pools) {
   8:                             MemoryUsage peak = pool.getPeakUsage();
   9:                             out.printf("Peak %s memory used: %,d%n",

View Full Code Here
   1: 
   2: import java.lang.management.ManagementFactory;
   3: import java.lang.management.ThreadInfo;
   4:         ...
   5:   {
   6:     ThreadMXBean bean = ManagementFactory.getThreadMXBean();
   7:     System.out.println("Bean: " + bean);
   8:     System.out.println("Monitor deadlocked threads: " + bean.findMonitorDeadlockedThreads());
   9:     long[] ids = bean.getAllThreadIds();

View Full Code Here
   1: import java.net.UnknownHostException;
   2: import java.lang.management.ManagementFactory;
   3: import java.lang.management.ThreadMXBean;
   4:         ...
   5:         StringBuilder sb=new StringBuilder();
   6:         ThreadMXBean bean=ManagementFactory.getThreadMXBean();
   7:         long[] ids=bean.getAllThreadIds();
   8:         ThreadInfo[] threads=bean.getThreadInfo(ids, 20);
   9:         for(int i=0; i < threads.length; i++) {

View Full Code Here