JDK-6175517 : Standardize a general-purpose MXBean framework
  • Type: Enhancement
  • Component: core-svc
  • Sub-Component: javax.management
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2004-10-07
  • Updated: 2017-05-16
  • Resolved: 2005-06-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b40Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
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
07-10-2004