Wednesday, January 20, 2010

4.9 Common Mistakes with Model MBeans




Ru-Brd









4.9 Common Mistakes with Model MBeans



  1. Trying to set descriptors used by the model MBean code.
    The model MBean implementation uses some of the descriptor values to manage the logic of value caching. You should never manually set the following descriptor fields:



    • Attribute descriptor:
      lastUpdatedTimeStamp



    • Operation descriptor:
      lastReturnedValue, lastUpdatedTimeStamp



    Note that the value field of the attribute descriptor is where the cached value of the attribute is maintained by the model MBean. If you set the value field and the getMethod field, then the value in the value field will be replaced according to the caching policy. You must turn caching off entirely to retain the value you place there. It is perfectly valid to put an initial value there, but it might be more appropriate to put that value in the defaultValue field.


  2. Getting the attribute type wrong.
    The attribute type fields must contain the fully qualified class name, not the relative class name.


  3. Class loader problems.
    Remember that if you are using the instantiate() or create() method to create the model MBean, then the class loader of the MBeanServer is being used.









    Ru-Brd



    No comments: