Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 5108792
Votes 0
Synopsis Add abstract base class to make coding DynamicMBeans easier
Category jmx:classes
Reported Against mustang
Release Fixed
State 11-Closed, Will Not Fix, request for enhancement
Priority: 4-Low
Related Bugs 5072268
Submit Date 29-SEP-2004
Description
Coding a DynamicMBean is harder than it needs to be.  Constructing the MBeanInfo completely by hand is tedious and error-prone.  The getAttributes and setAttributes methods have to be written explicitly, even if each of them just consists of calling getAttribute or setAttribute n times.  The getAttribute and setAttribute methods frequently consist of a set of lines like this:

  if (attrName.equals("foo"))
    return getFoo();
  else if (attrName.equals("bar"))
    return getBar();
  ...
  else
    throw new AttributeNotFoundException(attrName);

There should be an easier way.

The AbstractDynamicMBean class defined by the MX4J project would be a  customer  starting point.
http://cvs.sourceforge.net/viewcvs.py/mx4j/mx4j/src/core/mx4j/AbstractDynamicMBean.java?view=markup
Work Around
If you know the set of attributes and operations that you want in your dynamic MBean at compile time, you can often just put them in an MBean interface and subclass javax.management.StandardMBean to override getAttribute(String) etc with the extra functionality you need.
Evaluation
The hardest part here is getting the specification right, striking a balance between simplicity and ease of use on the one hand, and expressive power on the other.  Functionality in the base class should be justified by realistic examples of when it is useful.
  xxxxx@xxxxx   2004-09-29
In practice it appears that most cases where this might be useful are better addressed by javax.management.StandardMBean. Although if you do need to code a DynamicMBean, you often end up coding getAttributes in terms of getAttribute and setAttributes in terms of setAttribute, people don't often code DynamicMBeans so an abstract class would probably not pull its weight.
Posted Date : 2008-09-17 14:45:53.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang