站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 4.0.1 sp1 Cache API Documentation 英文版文档

PropertyConfigurator (JBossCache API) - JBoss 4.0.1 sp1 Cache API Documentation 英文版文档


org.jboss.cache
Class PropertyConfigurator

java.lang.Object
  extended byorg.jboss.cache.PropertyConfigurator

public class PropertyConfigurator
extends Object

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

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

PropertyConfigurator

public PropertyConfigurator()
Method Detail

loadDocument

protected Element loadDocument(String location)
                        throws ConfigureException
Throws:
ConfigureException

loadDocument

protected Element loadDocument(InputStream is)
                        throws ConfigureException
Throws:
ConfigureException

getMBeanElement

protected Element getMBeanElement(Element root)
                           throws ConfigureException
Throws:
ConfigureException

configure

public void configure(Object objToConfigure,
                      String configFile)
               throws ConfigureException
Configure the object based on the config xml file.

Parameters:
objToConfigure - Object that needs configuration.
configFile - xml file name that exists in the class path.
Throws:
ConfigureException - when the configuration attempt fails.

configure

public void configure(Object objToConfigure,
                      InputStream is)
               throws ConfigureException
Configure the object based on the config xml file.

Parameters:
objToConfigure - Object that needs configuration.
is - InputStream for the configuration xml file.
Throws:
ConfigureException - when the configuration attempt fails.

main

public static void main(String[] args)


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.