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:
- Direct access to an MXBean interface
- Get the MXBean instance through the static factory method
and access the MXBean locally of the running
virtual machine.
- Construct an MXBean proxy instance that forwards the
method calls to a given
MBeanServer
by calling
newPlatfromMXBeanProxy
.
A proxy is typically constructed to remotely access
an MXBean of another running virtual machine.
- Indirect access to an MXBean interface via MBeanServer
- Go through the
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.
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
open types
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
Integer
, Long
,
Boolean
, etc and
String
Enum
classes
- Classes that define only getter methods and define a static
from method with a
CompositeData
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:
- 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
CompositeData
argument is mapped to
CompositeData
.
- Map<K,V> is mapped to
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.
- 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
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:
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:
A Java virtual machine has zero or a single instance of
the following management interfaces.
A Java virtual machine may have one or more instances of the following
management interfaces.