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:
else if (attrName.equals("bar"))
throw new AttributeNotFoundException(attrName);
There should be an easier way.
The AbstractDynamicMBean class defined by the MX4J project would be a good starting point.