Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6339571

RequiredModelMBean: don't require a ModelMBeanOperationInfo for every ModelMBeanAttributeInfo

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 6
    • Fix Version/s: tbd
    • Component/s: core-svc
    • Labels:
      None

      Description

      The RequiredModelMBean class allows you to define MBean attributes and operations that are directed to methods in one or more underlying "resources". For example, you can specify that the MBean operation "resetCache()" is directed to the method "resetCache()" of some underlying object (resource).

      In the case of attributes, you can either store the attribute value within the MBean itself (more exactly, within the Descriptor for the attribute), or you can forward it to a method on a resource. In the latter case, you must add a getMethod and/or setMethod field to the Descriptor for the attribute, whose value is a String that is the name of the method to invoke on the resource. *And* you must add an operation with that name.

      So for example if I want to add a read-only attribute "CacheSize" that calls the method "getCurrentCacheSize()" on the underlying resource, I must do the following:
      * define a ModelMBeanAttributeInfo for the attribute "CacheSize" that has a Descriptor that looks like this: {"name=CacheSize", "descriptorType=attribute", "getMethod=getCurrentCacheSize"}
      * define a ModelMBeanOperationInfo for the operation "getCurrentCacheSize" that has a Descriptor that looks like this: {"name=getCurrentCacheSize", "descriptorType=operation"}
      * put the ModelMBeanAttributeInfo and ModelMBeanOperationInfo in the appropriate arrays inside the ModelMBeanInfo for the RequiredModelMBean.

      Furthermore, I can add the field "targetObject" to the Descriptor for the ModelMBeanOperationInfo to direct the "getCurrentCacheSize()" method call to some resource (object) other than the default one for this Model MBean.

      The need to create a ModelMBeanOperationInfo is strange. Not only does it lead to extra coding, but it means that the same functionality is exported in two ways by the MBean. I can do getAttribute("CacheSize"), or I can do invoke("getCurrentCacheSize"), with the same results.

      It would make sense to remove the requirement for there to be a ModelMBeanOperationInfo. In the above scenario, all the necessary information is available from the ModelMBeanAttributeInfo. The "targetObject" field should be allowed in the Descriptor for a ModelMBeanAttributeInfo with the obvious meaning.

      There is a compatibility concern, which is that if the ModelMBeanAttributeInfo does not have a "targetObject" field in its Descriptor, we must check to see whether there is a corresponding ModelMBeanOperationInfo that does. This will be the case for existing code that directs different attributes to different resources.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                emcmanus Eamonn McManus
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: