java.lang.Object | |
↳ | java.lang.management.ManagementFactory |
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:
MBeanServer
by calling
newPlatfromMXBeanProxy
.
A proxy is typically constructed to remotely access
an MXBean of another running virtual machine.
platform MBeanServer
to access MXBeans locally or
a specific MBeanServerConnection to access
MXBeans remotely.
The attributes and operations of an MXBean use only
JMX open types which include basic data types,
CompositeData
,
and TabularData
defined in
OpenType
.
The mapping is specified below.
open types
and this allows interoperation across versions.
The platform MXBean interfaces use only the following data types:
Integer
, Long
,
Boolean
, etc and
String
Enum
classesCompositeData
argument to convert from an input CompositeData to
an instance of that class
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
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:
Enum
is mapped to
String whose value is the name of the enum constant.
CompositeData
argument is mapped to
CompositeData
.
TabularData
whose row type is a
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.
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:
These attributes in the MBeanInfo of the MemoryMXBean have the following names and types:public MemoryUsage getHeapMemoryUsage(); public boolean isVerbose(); public void setVerbose(boolean value);
Attribute Name Type HeapMemoryUsage CompositeData representing MemoryUsage
Verbose boolean
ObjectName
for
registration in the platform MBeanServer.
A Java virtual machine has a single instance of the following management
interfaces:
A Java virtual machine has zero or a single instance of the following management interfaces.
Management Interface ObjectName CompilationMXBean
java.lang:type=Compilation
A Java virtual machine may have one or more instances of the following management interfaces.
Management Interface ObjectName GarbageCollectorMXBean
java.lang:type=GarbageCollector
,name=collector's nameMemoryManagerMXBean
java.lang:type=MemoryManager
,name=manager's nameMemoryPoolMXBean
java.lang:type=MemoryPool
,name=pool's name
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | CLASS_LOADING_MXBEAN_NAME | String representation of the
ObjectName for the ClassLoadingMXBean . |
|||||||||
String | COMPILATION_MXBEAN_NAME | String representation of the
ObjectName for the CompilationMXBean . |
|||||||||
String | GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE | The domain name and the type key property in
the ObjectName for a GarbageCollectorMXBean . |
|||||||||
String | MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE | The domain name and the type key property in
the ObjectName for a MemoryManagerMXBean . |
|||||||||
String | MEMORY_MXBEAN_NAME | String representation of the
ObjectName for the MemoryMXBean . |
|||||||||
String | MEMORY_POOL_MXBEAN_DOMAIN_TYPE | The domain name and the type key property in
the ObjectName for a MemoryPoolMXBean . |
|||||||||
String | OPERATING_SYSTEM_MXBEAN_NAME | String representation of the
ObjectName for the OperatingSystemMXBean . |
|||||||||
String | RUNTIME_MXBEAN_NAME | String representation of the
ObjectName for the RuntimeMXBean . |
|||||||||
String | THREAD_MXBEAN_NAME | String representation of the
ObjectName for the ThreadMXBean . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the managed bean for the class loading system of
the Java virtual machine.
| |||||||||||
Returns the managed bean for the compilation system of
the Java virtual machine.
| |||||||||||
Returns a list of
GarbageCollectorMXBean objects
in the Java virtual machine. | |||||||||||
Returns the managed bean for the memory system of
the Java virtual machine.
| |||||||||||
Returns a list of
MemoryManagerMXBean objects
in the Java virtual machine. | |||||||||||
Returns a list of
MemoryPoolMXBean objects in the
Java virtual machine. | |||||||||||
Returns the managed bean for the operating system on which
the Java virtual machine is running.
| |||||||||||
Returns the platform
MBeanServer . | |||||||||||
Returns the managed bean for the runtime system of
the Java virtual machine.
| |||||||||||
Returns the managed bean for the thread system of
the Java virtual machine.
| |||||||||||
Returns a proxy for a platform MXBean interface of a
given MXBean name
that forwards its method calls through the given
MBeanServerConnection.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
String representation of the
ObjectName for the ClassLoadingMXBean
.
String representation of the
ObjectName for the CompilationMXBean
.
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".
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".
String representation of the
ObjectName for the MemoryMXBean
.
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.
String representation of the
ObjectName for the OperatingSystemMXBean
.
String representation of the
ObjectName for the RuntimeMXBean
.
String representation of the
ObjectName for the ThreadMXBean
.
Returns the managed bean for the class loading system of the Java virtual machine.
ClassLoadingMXBean
object for
the Java virtual machine.
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.
CompilationMXBean
object for the Java virtual
machine or null if the Java virtual machine has
no compilation system.
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 the managed bean for the memory system of the Java virtual machine.
MemoryMXBean
object for the Java virtual machine.
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 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 the managed bean for the operating system on which the Java virtual machine is running.
OperatingSystemMXBean
object for
the Java virtual machine.
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.
SecurityException | if there is a security manager
and the caller does not have the permission required by
createMBeanServer() . |
---|
Returns the managed bean for the runtime system of the Java virtual machine.
RuntimeMXBean
object for the Java virtual machine.
Returns the managed bean for the thread system of the Java virtual machine.
ThreadMXBean
object for the Java virtual machine.
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:
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.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. 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.
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. |
IllegalArgumentException | if
|
---|---|
IOException | if a communication problem occurred when accessing the MBeanServerConnection. |