United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6175517 : Standardize a general-purpose MXBean framework

Details
Type:
Enhancement
Submit Date:
2004-10-07
Status:
Resolved
Updated Date:
2012-08-22
Project Name:
JDK
Resolved Date:
2005-06-08
Component:
core-svc
OS:
generic
Sub-Component:
javax.management
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:

Related Reports
Relates:
Relates:
Relates:
Relates:
Relates:

Sub Tasks

Description
In J2SE 5, java.lang.management introduces the notion of MXBeans.  An MXBean is defined by a Java interface, the "MXBean interface".  This interface is similar to a Standard MBean interface -- it contains attributes that are defined by getX and setX methods, and its other methods are operations.  With MXBeans, however, the MBean that is actually registered in the MBean Server does not have exactly the same types for its attributes and operation parameters and return values.  Instead, each type that occurs in the MXBean interface is *converted* to a type built from the fixed set defined in javax.management.openmbean.  The MBean that is actually registered in the MBean Server is an Open MBean that references these converted types.  When it is accessed, it converts values between the original MXBean interface type and the converted Open MBean type.

In this way, a client can access an MXBean without needing to know any model-specific types that might be referenced in the MXBean interface.  The client only needs to know the standard Open MBean types.  So for example a generic JMX console can access any MXBean without need to load any non-standard classes.

A client that does know the model-specific classes, including the MXBean interface itself, can construct a proxy for the MXBean that references the original types.

For an example of MXBeans, see java.lang.management in J2SE 5.  The interface MemoryMXBean is an MXBean interface.  Its method:
    MemoryUsage getHeapMemoryUsage();
defines an attribute called HeapMemoryUsage.  The type of this attribute is converted from MemoryUsage to the Open MBean type CompositeData using rules that are explained in java.lang.management.  Thus, a client of the MBean Server will see an attribute with type CompositeData.

A client that knows the MemoryMXBean interface can construct a proxy using ManagementFactory.newPlatformMXBeanProxy:
    MemoryMXBean proxy =
        ManagementFactory.newPlatformMXBeanProxy(..., MemoryMXBean.class);
    MemoryUsage usage = proxy.getHeapMemoryUsage();

A desirable extension to the model would be for an MXBean to reference another MXBean.  For example, if the interface MemoryManagerMXBean defines a method like this:
    MemoryMXBean[] getMemoryMXBeans();
then that would define an attribute called MemoryMXBeans whose converted type would be ObjectName[].  For each MemoryMXBean instance in the array returned by the original getMemoryMXBeans() method, the MXBean framework would know what ObjectName that MXBean is registered under and return that name.  A proxy for MemoryManagerMXBean would be able to convert the ObjectName into another proxy, of type MemoryMXBean accessing the ObjectName in the same MBean Server as the original proxy.
###@###.### 10/7/04 15:55 GMT

                                    

Comments
EVALUATION

An advanced prototype exists.  Conformance tests do not as yet.  Should be possible to do this for Mustang.
###@###.### 10/7/04 15:55 GMT
                                     
2004-10-07



Hardware and Software, Engineered to Work Together