A generic object property configurator. It reads in a user-specified xml file from class path, parses it into xml format, and finally performs reflection to configure the object through setter methods.
Here is a typical usage:
MyObject obj = new MyObject(); PropertyConfigurator config = new PropertyConfigurator(); config.configure(obj, "my.xml");
that will configure MyObject automatically based on the input xml file.
Note that this class currently supports configuration parameter as primary types, e.g., int, float, String, long, etc. In addition, it also supports org.w3c.dom.Element
type.
The tag of the xml file currently suports at the root level "mbean", "attribute" for each property, and, finally, if the attribute type is "Element", the sub-tag name is assumed to be "config".
See the tree cache xml file for example.
@author bwang