Java Doc for ManagementFactory.java in  » 6.0-JDK-Core » lang » java » lang » management » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » lang » java.lang.management 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.lang.management.ManagementFactory

ManagementFactory
public class ManagementFactory (Code)
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 and this allows interoperation across versions.

The platform MXBean interfaces use only the following data types:

  • Primitive types such as int, long, boolean, etc
  • Wrapper classes for primitive types such as java.lang.Integer Integer , java.lang.Long Long , java.lang.Boolean Boolean , etc and java.lang.String String
  • java.lang.Enum Enum classes
  • Classes that define only getter methods and define a static from method with a javax.management.openmbean.CompositeData CompositeData argument to convert from an input CompositeData to an instance of that class
  • java.util.List List<E> where E is a primitive type, a wrapper class, an enum class, or a class supporting conversion from a CompositeData to its class
  • java.util.Map Map<K,V> where K and V are a primitive type, a wrapper class, an enum class, or a class supporting conversion from a CompositeData to its class

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

  • A primitive type or a wrapper class is mapped to the same type.
  • An Enum is mapped to String whose value is the name of the enum constant.
  • A class that defines only getter methods and a static from method with a javax.management.openmbean.CompositeData CompositeData argument is mapped to javax.management.openmbean.CompositeData CompositeData .
  • Map<K,V> is mapped to javax.management.openmbean.TabularData TabularData whose row type is a javax.management.openmbean.CompositeType CompositeType with two items whose names are "key" and "value" and the item types are the corresponding mapped type of K and V respectively and the "key" is the index.
  • List<E> is mapped to an array with the mapped type of E as the element type.
  • An array of element type E is mapped to an array of the same dimenions with the mapped type of E as the element type.
The 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 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 MemoryUsage.from CompositeData representing MemoryUsage
Verbose boolean

MXBean Names

Each platform MXBean for a Java virtual machine has a unique 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
ClassLoadingMXBean ManagementFactory.CLASS_LOADING_MXBEAN_NAMEjava.lang:type=ClassLoading
MemoryMXBean ManagementFactory.MEMORY_MXBEAN_NAMEjava.lang:type=Memory
ThreadMXBean ManagementFactory.THREAD_MXBEAN_NAMEjava.lang:type=Threading
RuntimeMXBean ManagementFactory.RUNTIME_MXBEAN_NAMEjava.lang:type=Runtime
OperatingSystemMXBean ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAMEjava.lang:type=OperatingSystem

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

Management Interface ObjectName
CompilationMXBean ManagementFactory.COMPILATION_MXBEAN_NAMEjava.lang:type=Compilation

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

Management Interface ObjectName
GarbageCollectorMXBean ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPEjava.lang:type=GarbageCollector ,name=collector's name
MemoryManagerMXBean ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPEjava.lang:type=MemoryManager ,name=manager's name
MemoryPoolMXBean ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPEjava.lang:type=MemoryPool ,name=pool's name

See Also:    * JMX Specification.
See Also:    * Ways to Access Management Metrics
See Also:   java.util.logging.LoggingMXBean
See Also:   javax.management.MXBean
author:
   Mandy Chung
version:
   1.31, 05/09/07
since:
   1.5


Field Summary
final public static  StringCLASS_LOADING_MXBEAN_NAME
     String representation of the ObjectName for the ClassLoadingMXBean .
final public static  StringCOMPILATION_MXBEAN_NAME
     String representation of the ObjectName for the CompilationMXBean .
final public static  StringGARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE
     The domain name and the type key property in the ObjectName for a GarbageCollectorMXBean .
final public static  StringMEMORY_MANAGER_MXBEAN_DOMAIN_TYPE
     The domain name and the type key property in the ObjectName for a MemoryManagerMXBean .
final public static  StringMEMORY_MXBEAN_NAME
     String representation of the ObjectName for the MemoryMXBean .
final public static  StringMEMORY_POOL_MXBEAN_DOMAIN_TYPE
     The domain name and the type key property in the ObjectName for a MemoryPoolMXBean .
final public static  StringOPERATING_SYSTEM_MXBEAN_NAME
     String representation of the ObjectName for the OperatingSystemMXBean .
final public static  StringRUNTIME_MXBEAN_NAME
     String representation of the ObjectName for the RuntimeMXBean .
final public static  StringTHREAD_MXBEAN_NAME
     String representation of the ObjectName for the ThreadMXBean .


Method Summary
public static  ClassLoadingMXBeangetClassLoadingMXBean()
     Returns the managed bean for the class loading system of the Java virtual machine.
public static  CompilationMXBeangetCompilationMXBean()
     Returns the managed bean for the compilation system of the Java virtual machine.
public static  List<GarbageCollectorMXBean>getGarbageCollectorMXBeans()
     Returns a list of GarbageCollectorMXBean objects in the Java virtual machine.
public static  MemoryMXBeangetMemoryMXBean()
     Returns the managed bean for the memory system of the Java virtual machine.
public static  List<MemoryManagerMXBean>getMemoryManagerMXBeans()
     Returns a list of MemoryManagerMXBean objects in the Java virtual machine.
public static  List<MemoryPoolMXBean>getMemoryPoolMXBeans()
     Returns a list of MemoryPoolMXBean objects in the Java virtual machine.
public static  OperatingSystemMXBeangetOperatingSystemMXBean()
     Returns the managed bean for the operating system on which the Java virtual machine is running.
public static synchronized  MBeanServergetPlatformMBeanServer()
     Returns the platform javax.management.MBeanServer MBeanServer . On the first call to this method, it first creates the platform MBeanServer by calling the javax.management.MBeanServerFactory.createMBeanServerMBeanServerFactory.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 MemoryPoolMXBean pools and 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 javax.management.MBeanServerBuilder .

It is recommended that this platform MBeanServer also be used to register other application managed beans besides the platform MXBeans.

public static  RuntimeMXBeangetRuntimeMXBean()
     Returns the managed bean for the runtime system of the Java virtual machine.
public static  ThreadMXBeangetThreadMXBean()
     Returns the managed bean for the thread system of the Java virtual machine.
public static  TnewPlatformMXBeanProxy(MBeanServerConnection connection, String mxbeanName, 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.

This method is equivalent to:

java.lang.reflect.Proxy.newProxyInstance Proxy.newProxyInstance (mxbeanInterface.getClassLoader(), new Class[] { mxbeanInterface }, handler)
where handler is an java.lang.reflect.InvocationHandlerInvocationHandler to which method invocations to the MXBean interface are dispatched.

Field Detail
CLASS_LOADING_MXBEAN_NAME
final public static String CLASS_LOADING_MXBEAN_NAME(Code)
String representation of the ObjectName for the ClassLoadingMXBean .



COMPILATION_MXBEAN_NAME
final public static String COMPILATION_MXBEAN_NAME(Code)
String representation of the ObjectName for the CompilationMXBean .



GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE
final public static String GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE(Code)
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".



MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE
final public static String MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE(Code)
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".



MEMORY_MXBEAN_NAME
final public static String MEMORY_MXBEAN_NAME(Code)
String representation of the ObjectName for the MemoryMXBean .



MEMORY_POOL_MXBEAN_DOMAIN_TYPE
final public static String MEMORY_POOL_MXBEAN_DOMAIN_TYPE(Code)
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.



OPERATING_SYSTEM_MXBEAN_NAME
final public static String OPERATING_SYSTEM_MXBEAN_NAME(Code)
String representation of the ObjectName for the OperatingSystemMXBean .



RUNTIME_MXBEAN_NAME
final public static String RUNTIME_MXBEAN_NAME(Code)
String representation of the ObjectName for the RuntimeMXBean .



THREAD_MXBEAN_NAME
final public static String THREAD_MXBEAN_NAME(Code)
String representation of the ObjectName for the ThreadMXBean .





Method Detail
getClassLoadingMXBean
public static ClassLoadingMXBean getClassLoadingMXBean()(Code)
Returns the managed bean for the class loading system of the Java virtual machine. a ClassLoadingMXBean object for the Java virtual machine.



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



getGarbageCollectorMXBeans
public static List<GarbageCollectorMXBean> getGarbageCollectorMXBeans()(Code)
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. a list of GarbageCollectorMXBean objects.



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



getMemoryManagerMXBeans
public static List<MemoryManagerMXBean> getMemoryManagerMXBeans()(Code)
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. a list of MemoryManagerMXBean objects.



getMemoryPoolMXBeans
public static List<MemoryPoolMXBean> getMemoryPoolMXBeans()(Code)
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. a list of MemoryPoolMXBean objects.



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



getPlatformMBeanServer
public static synchronized MBeanServer getPlatformMBeanServer()(Code)
Returns the platform javax.management.MBeanServer MBeanServer . On the first call to this method, it first creates the platform MBeanServer by calling the javax.management.MBeanServerFactory.createMBeanServerMBeanServerFactory.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 MemoryPoolMXBean pools and 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 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. the platform MBeanServer; the platformMXBeans are registered into the platform MBeanServerat the first time this method is called.
exception:
  SecurityException - if there is a security manager and the caller does not have the permission required by javax.management.MBeanServerFactory.createMBeanServer.
See Also:   javax.management.MBeanServerFactory
See Also:   javax.management.MBeanServerFactory.createMBeanServer




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



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



newPlatformMXBeanProxy
public static T newPlatformMXBeanProxy(MBeanServerConnection connection, String mxbeanName, Class<T> mxbeanInterface) throws java.io.IOException(Code)
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:

java.lang.reflect.Proxy.newProxyInstance Proxy.newProxyInstance (mxbeanInterface.getClassLoader(), new Class[] { mxbeanInterface }, handler)
where handler is an java.lang.reflect.InvocationHandlerInvocationHandler 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 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 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 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. javax.management.MBeanServerInvocationHandlerMBeanServerInvocationHandler or its javax.management.MBeanServerInvocationHandler.newProxyInstancenewProxyInstance 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.
Parameters:
  mxbeanName - the name of a platform MXBean withinconnection to forward to. mxbeanName must bein the format of ObjectName ObjectName.
Parameters:
  mxbeanInterface - the MXBean interface to be implementedby the proxy.
throws:
  IllegalArgumentException - if
  • mxbeanName is not with a valid ObjectName ObjectName format, or
  • the named MXBean in the connection isnot 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

throws:
  java.io.IOException - if a communication problem occurred when accessing the MBeanServerConnection.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.