|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jboss.cache.PropertyConfigurator
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.
See the tree cache xml file for example.
Constructor Summary | |
PropertyConfigurator()
|
Method Summary | |
void |
configure(Object objToConfigure,
InputStream is)
Configure the object based on the config xml file. |
void |
configure(Object objToConfigure,
String configFile)
Configure the object based on the config xml file. |
protected Element |
getMBeanElement(Element root)
|
protected Element |
loadDocument(InputStream is)
|
protected Element |
loadDocument(String location)
|
static void |
main(String[] args)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PropertyConfigurator()
Method Detail |
protected Element loadDocument(String location) throws ConfigureException
ConfigureException
protected Element loadDocument(InputStream is) throws ConfigureException
ConfigureException
protected Element getMBeanElement(Element root) throws ConfigureException
ConfigureException
public void configure(Object objToConfigure, String configFile) throws ConfigureException
objToConfigure
- Object that needs configuration.configFile
- xml file name that exists in the class path.
ConfigureException
- when the configuration attempt fails.public void configure(Object objToConfigure, InputStream is) throws ConfigureException
objToConfigure
- Object that needs configuration.is
- InputStream for the configuration xml file.
ConfigureException
- when the configuration attempt fails.public static void main(String[] args)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |