1 *java.lang.management.ManagementFactory* *ManagementFactory* The ManagementFacto
3 public class ManagementFactory
4 extends |java.lang.Object|
6 |java.lang.management.ManagementFactory_Description|
7 |java.lang.management.ManagementFactory_Fields|
8 |java.lang.management.ManagementFactory_Constructors|
9 |java.lang.management.ManagementFactory_Methods|
11 ================================================================================
13 *java.lang.management.ManagementFactory_Fields*
14 |java.lang.String_java.lang.management.ManagementFactory.CLASS_LOADING_MXBEAN_NAME|
15 |java.lang.String_java.lang.management.ManagementFactory.COMPILATION_MXBEAN_NAME|
16 |java.lang.String_java.lang.management.ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE|
17 |java.lang.String_java.lang.management.ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE|
18 |java.lang.String_java.lang.management.ManagementFactory.MEMORY_MXBEAN_NAME|
19 |java.lang.String_java.lang.management.ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE|
20 |java.lang.String_java.lang.management.ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME|
21 |java.lang.String_java.lang.management.ManagementFactory.RUNTIME_MXBEAN_NAME|
22 |java.lang.String_java.lang.management.ManagementFactory.THREAD_MXBEAN_NAME|
24 *java.lang.management.ManagementFactory_Methods*
25 |java.lang.management.ManagementFactory.getClassLoadingMXBean()|Returns the man
26 |java.lang.management.ManagementFactory.getCompilationMXBean()|Returns the mana
27 |java.lang.management.ManagementFactory.getGarbageCollectorMXBeans()|Returns a
28 |java.lang.management.ManagementFactory.getMemoryManagerMXBeans()|Returns a lis
29 |java.lang.management.ManagementFactory.getMemoryMXBean()|Returns the managed b
30 |java.lang.management.ManagementFactory.getMemoryPoolMXBeans()|Returns a list o
31 |java.lang.management.ManagementFactory.getOperatingSystemMXBean()|Returns the
32 |java.lang.management.ManagementFactory.getPlatformMBeanServer()|Returns the pl
33 |java.lang.management.ManagementFactory.getRuntimeMXBean()|Returns the managed
34 |java.lang.management.ManagementFactory.getThreadMXBean()|Returns the managed b
35 |java.lang.management.ManagementFactory.newPlatformMXBeanProxy(MBeanServerConnection,String,Class<T>)|
37 *java.lang.management.ManagementFactory_Description*
39 The ManagementFactory class is a factory class for getting managed beans for
40 the Java platform. This class consists of static methods each of which returns
41 one or more platform MXBean(s) representing the management interface of a
42 component of the Java virtual machine.
44 An application can access a platform MXBean in the following ways:
46 Direct access to an MXBean interface
48 Get the MXBean instance through the static factory method and access the MXBean
49 locally of the running virtual machine.
51 Construct an MXBean proxy instance that forwards the method calls to a given
52 MBeanServer(|javax.management.MBeanServer|) by calling
53 newPlatfromMXBeanProxy(|java.lang.management.ManagementFactory|) . A proxy is
54 typically constructed to remotely access an MXBean of another running virtual
57 Indirect access to an MXBean interface via MBeanServer
59 Go through the platform MBeanServer(|java.lang.management.ManagementFactory|)
60 to access MXBeans locally or a specific MBeanServerConnection to access MXBeans
61 remotely. The attributes and operations of an MXBean use only JMX open types
62 which include basic data types,
63 CompositeData(|javax.management.openmbean.CompositeData|) , and
64 TabularData(|javax.management.openmbean.TabularData|) defined in
65 OpenType(|javax.management.openmbean.OpenType|) . The mapping is specified
70 Platform MXBeans A platform MXBean is a managed bean that conforms to the JMX
71 Instrumentation Specification and only uses a set of basic data types described
72 below. See the specification of MXBeans for details. A JMX management
73 application and the platform MBeanServer can interoperate without requiring
74 classes for MXBean specific data types. The data types being transmitted
75 between the JMX connector server and the connector client are open
76 types(|javax.management.openmbean.OpenType|) and this allows interoperation
79 The platform MXBean interfaces use only the following data types:
81 Primitive types such as int, long, boolean, etc Wrapper classes for primitive
82 types such as Integer(|java.lang.Integer|) , Long(|java.lang.Long|) ,
83 Boolean(|java.lang.Boolean|) , etc and String(|java.lang.String|)
84 Enum(|java.lang.Enum|) classes Classes that define only getter methods and
85 define a static from method with a
86 CompositeData(|javax.management.openmbean.CompositeData|) argument to convert
87 from an input CompositeData to an instance of that class
89 List<E>(|java.util.List|) where E is a primitive type, a wrapper class,
90 an enum class, or a class supporting conversion from a CompositeData to its
93 Map<K,V>(|java.util.Map|) where K and V are a primitive type, a wrapper
94 class, an enum class, or a class supporting conversion from a CompositeData to
99 When an attribute or operation of a platform MXBean is accessed via an
100 MBeanServer, the data types are mapped as follows:
102 A primitive type or a wrapper class is mapped to the same type.
104 An (|java.lang.Enum|) is mapped to String whose value is the name of the enum
105 constant. A class that defines only getter methods and a static from method
106 with a CompositeData(|javax.management.openmbean.CompositeData|) argument is
107 mapped to CompositeData(|javax.management.openmbean.CompositeData|) .
109 Map<K,V> is mapped to TabularData(|javax.management.openmbean.TabularData|)
110 whose row type is a CompositeType(|javax.management.openmbean.CompositeType|)
111 with two items whose names are "key" and "value" and the item types are the
112 corresponding mapped type of K and V respectively and the "key" is the index.
114 List<E> is mapped to an array with the mapped type of E as the element type.
116 An array of element type E is mapped to an array of the same dimenions with the
117 mapped type of E as the element type.
119 The MBeanInfo(|javax.management.MBeanInfo|) for a platform MXBean describes the
120 data types of the attributes and operations as primitive or open types mapped
123 For example, the (|java.lang.management.MemoryMXBean|) interface has the
124 following getter and setter methods:
128 public MemoryUsage getHeapMemoryUsage(); public boolean isVerbose(); public
129 void setVerbose(boolean value);
131 These attributes in the MBeanInfo of the MemoryMXBean have the following names
138 HeapMemoryUsage CompositeData representing
139 MemoryUsage(|java.lang.management.MemoryUsage|)
145 MXBean Names Each platform MXBean for a Java virtual machine has a unique
146 ObjectName(|javax.management.ObjectName|) for registration in the platform
147 MBeanServer. A Java virtual machine has a single instance of the following
148 management interfaces:
152 Management Interface ObjectName
154 (|java.lang.management.ClassLoadingMXBean|)
155 <tt>java.lang:type=ClassLoading</tt>(|java.lang.management.ManagementFactory|)
157 (|java.lang.management.MemoryMXBean|)
158 <tt>java.lang:type=Memory</tt>(|java.lang.management.ManagementFactory|)
160 (|java.lang.management.ThreadMXBean|)
161 <tt>java.lang:type=Threading</tt>(|java.lang.management.ManagementFactory|)
163 (|java.lang.management.RuntimeMXBean|)
164 <tt>java.lang:type=Runtime</tt>(|java.lang.management.ManagementFactory|)
166 (|java.lang.management.OperatingSystemMXBean|)
167 <tt>java.lang:type=OperatingSystem</tt>(|java.lang.management.ManagementFactory|)
172 A Java virtual machine has zero or a single instance of the following
173 management interfaces.
177 Management Interface ObjectName
179 (|java.lang.management.CompilationMXBean|)
180 <tt>java.lang:type=Compilation</tt>(|java.lang.management.ManagementFactory|)
184 A Java virtual machine may have one or more instances of the following
185 management interfaces.
189 Management Interface ObjectName
191 (|java.lang.management.GarbageCollectorMXBean|)
192 <tt>java.lang:type=GarbageCollector</tt>(|java.lang.management.ManagementFactory|)
193 ,name=collector's name
195 (|java.lang.management.MemoryManagerMXBean|)
196 <tt>java.lang:type=MemoryManager</tt>(|java.lang.management.ManagementFactory|)
199 (|java.lang.management.MemoryPoolMXBean|)
200 <tt>java.lang:type=MemoryPool</tt>(|java.lang.management.ManagementFactory|)
207 *java.lang.String_java.lang.management.ManagementFactory.CLASS_LOADING_MXBEAN_NAME*
209 String representation of the ObjectName for the
210 (|java.lang.management.ClassLoadingMXBean|) .
213 *java.lang.String_java.lang.management.ManagementFactory.COMPILATION_MXBEAN_NAME*
215 String representation of the ObjectName for the
216 (|java.lang.management.CompilationMXBean|) .
219 *java.lang.String_java.lang.management.ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE*
221 The domain name and the type key property in the ObjectName for a
222 (|java.lang.management.GarbageCollectorMXBean|) . The unique ObjectName for a
223 GarbageCollectorMXBean can be formed by appending this string with
224 ",name=collector's name".
227 *java.lang.String_java.lang.management.ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE*
229 The domain name and the type key property in the ObjectName for a
230 (|java.lang.management.MemoryManagerMXBean|) . The unique ObjectName for a
231 MemoryManagerMXBean can be formed by appending this string with
232 ",name=manager's name".
235 *java.lang.String_java.lang.management.ManagementFactory.MEMORY_MXBEAN_NAME*
237 String representation of the ObjectName for the
238 (|java.lang.management.MemoryMXBean|) .
241 *java.lang.String_java.lang.management.ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE*
243 The domain name and the type key property in the ObjectName for a
244 (|java.lang.management.MemoryPoolMXBean|) . The unique ObjectName for a
245 MemoryPoolMXBean can be formed by appending this string with ,name=pool's name.
248 *java.lang.String_java.lang.management.ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME*
250 String representation of the ObjectName for the
251 (|java.lang.management.OperatingSystemMXBean|) .
254 *java.lang.String_java.lang.management.ManagementFactory.RUNTIME_MXBEAN_NAME*
256 String representation of the ObjectName for the
257 (|java.lang.management.RuntimeMXBean|) .
260 *java.lang.String_java.lang.management.ManagementFactory.THREAD_MXBEAN_NAME*
262 String representation of the ObjectName for the
263 (|java.lang.management.ThreadMXBean|) .
267 *java.lang.management.ManagementFactory.getClassLoadingMXBean()*
269 public static |java.lang.management.ClassLoadingMXBean| getClassLoadingMXBean()
271 Returns the managed bean for the class loading system of the Java virtual
276 Returns: a {@link ClassLoadingMXBean} object for the Java virtual machine.
278 *java.lang.management.ManagementFactory.getCompilationMXBean()*
280 public static |java.lang.management.CompilationMXBean| getCompilationMXBean()
282 Returns the managed bean for the compilation system of the Java virtual
283 machine. This method returns null if the Java virtual machine has no
288 Returns: a {@link CompilationMXBean} object for the Java virtual machine or null if the
289 Java virtual machine has no compilation system.
291 *java.lang.management.ManagementFactory.getGarbageCollectorMXBeans()*
293 public static |java.util.List|<GarbageCollectorMXBean> getGarbageCollectorMXBeans()
295 Returns a list of (|java.lang.management.GarbageCollectorMXBean|) objects in
296 the Java virtual machine. The Java virtual machine may have one or more
297 GarbageCollectorMXBean objects. It may add or remove GarbageCollectorMXBean
302 Returns: a list of GarbageCollectorMXBean objects.
304 *java.lang.management.ManagementFactory.getMemoryManagerMXBeans()*
306 public static |java.util.List|<MemoryManagerMXBean> getMemoryManagerMXBeans()
308 Returns a list of (|java.lang.management.MemoryManagerMXBean|) objects in the
309 Java virtual machine. The Java virtual machine can have one or more memory
310 managers. It may add or remove memory managers during execution.
314 Returns: a list of MemoryManagerMXBean objects.
316 *java.lang.management.ManagementFactory.getMemoryMXBean()*
318 public static |java.lang.management.MemoryMXBean| getMemoryMXBean()
320 Returns the managed bean for the memory system of the Java virtual machine.
324 Returns: a {@link MemoryMXBean} object for the Java virtual machine.
326 *java.lang.management.ManagementFactory.getMemoryPoolMXBeans()*
328 public static |java.util.List|<MemoryPoolMXBean> getMemoryPoolMXBeans()
330 Returns a list of (|java.lang.management.MemoryPoolMXBean|) objects in the Java
331 virtual machine. The Java virtual machine can have one or more memory pools. It
332 may add or remove memory pools during execution.
336 Returns: a list of MemoryPoolMXBean objects.
338 *java.lang.management.ManagementFactory.getOperatingSystemMXBean()*
340 public static |java.lang.management.OperatingSystemMXBean| getOperatingSystemMXBean()
342 Returns the managed bean for the operating system on which the Java virtual
347 Returns: an {@link OperatingSystemMXBean} object for the Java virtual machine.
349 *java.lang.management.ManagementFactory.getPlatformMBeanServer()*
351 public static synchronized |javax.management.MBeanServer| getPlatformMBeanServer()
353 Returns the platform MBeanServer(|javax.management.MBeanServer|) . On the first
354 call to this method, it first creates the platform MBeanServer by calling the
355 MBeanServerFactory.createMBeanServer(|javax.management.MBeanServerFactory|)
356 method and registers the platform MXBeans in this platform MBeanServer using
357 the MXBean names defined in the class description. This method, in subsequent
358 calls, will simply return the initially created platform MBeanServer.
360 MXBeans that get created and destroyed dynamically, for example, memory
361 pools(|java.lang.management.MemoryPoolMXBean|) and
362 managers(|java.lang.management.MemoryManagerMXBean|) , will automatically be
363 registered and deregistered into the platform MBeanServer.
365 If the system property javax.management.builder.initial is set, the platform
366 MBeanServer creation will be done by the specified
367 (|javax.management.MBeanServerBuilder|) .
369 It is recommended that this platform MBeanServer also be used to register other
370 application managed beans besides the platform MXBeans. This will allow all
371 MBeans to be published through the same MBeanServer and hence allow for easier
372 network publishing and discovery. Name conflicts with the platform MXBeans
377 Returns: the platform MBeanServer; the platform MXBeans are registered into the platform
378 MBeanServer at the first time this method is called.
380 *java.lang.management.ManagementFactory.getRuntimeMXBean()*
382 public static |java.lang.management.RuntimeMXBean| getRuntimeMXBean()
384 Returns the managed bean for the runtime system of the Java virtual machine.
388 Returns: a {@link RuntimeMXBean} object for the Java virtual machine.
390 *java.lang.management.ManagementFactory.getThreadMXBean()*
392 public static |java.lang.management.ThreadMXBean| getThreadMXBean()
394 Returns the managed bean for the thread system of the Java virtual machine.
398 Returns: a {@link ThreadMXBean} object for the Java virtual machine.
400 *java.lang.management.ManagementFactory.newPlatformMXBeanProxy(MBeanServerConnection,String,Class<T>)*
402 public static |T| newPlatformMXBeanProxy(
403 javax.management.MBeanServerConnection connection,
404 java.lang.String mxbeanName,
405 java.lang.Class<T> mxbeanInterface)
406 throws |java.io.IOException|
408 Returns a proxy for a platform MXBean interface of a given MXBean name that
409 forwards its method calls through the given MBeanServerConnection.
411 This method is equivalent to: Proxy.newProxyInstance(|java.lang.reflect.Proxy|)
412 (mxbeanInterface.getClassLoader(), new Class[] { mxbeanInterface }, handler)
414 where handler is an InvocationHandler(|java.lang.reflect.InvocationHandler|) to
415 which method invocations to the MXBean interface are dispatched. This handler
416 converts an input parameter from an MXBean data type to its mapped open type
417 before forwarding to the MBeanServer and converts a return value from an MXBean
418 method call through the MBeanServer from an open type to the corresponding
419 return type declared in the MXBean interface.
421 If the MXBean is a notification emitter (i.e., it implements
422 NotificationEmitter(|javax.management.NotificationEmitter|) ), both the
423 mxbeanInterface and NotificationEmitter will be implemented by this proxy.
427 Using an MXBean proxy is a convenience remote access to a platform MXBean of a
428 running virtual machine. All method calls to the MXBean proxy are forwarded to
429 an MBeanServerConnection where IOException(|java.io.IOException|) may be thrown
430 when the communication problem occurs with the connector server. An application
431 remotely accesses the platform MXBeans using proxy should prepare to catch
432 IOException as if accessing with the MBeanServerConnector interface.
434 When a client application is designed to remotely access MXBeans for a running
435 virtual machine whose version is different than the version on which the
436 application is running, it should prepare to catch
437 InvalidObjectException(|java.io.InvalidObjectException|) which is thrown when
438 an MXBean proxy receives a name of an enum constant which is missing in the
439 enum class loaded in the client application.
441 MBeanServerInvocationHandler(|javax.management.MBeanServerInvocationHandler|)
442 or its newProxyInstance(|javax.management.MBeanServerInvocationHandler|) method
443 cannot be used to create a proxy for a platform MXBean. The proxy object
444 created by MBeanServerInvocationHandler does not handle the properties of the
445 platform MXBeans described in the class specification.
450 connection - the MBeanServerConnection to forward to.
451 mxbeanName - the name of a platform MXBean within connection to forward to. mxbeanName must
452 be in the format of {@link ObjectName ObjectName}.
453 mxbeanInterface - the MXBean interface to be implemented by the proxy.