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 good starting point.
http://cvs.sourceforge.net/viewcvs.py/mx4j/mx4j/src/core/mx4j/AbstractDynamicMBean.java?view=markup