Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jboss.cache
Class PropertyConfigurator

    java.lang.Object
      org.jboss.cache.PropertyConfigurator

    public class PropertyConfigurator

extends java.lang.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(java.lang.Object objToConfigure, java.io.InputStream is)` Configure the object based on the config xml file.
`void` | `configure(java.lang.Object objToConfigure, java.lang.String configFile)` Configure the object based on the config xml file.
`protected org.w3c.dom.Element` | `getMBeanElement(org.w3c.dom.Element root)`
`protected org.w3c.dom.Element` | `loadDocument(java.io.InputStream is)`
`protected org.w3c.dom.Element` | `loadDocument(java.lang.String location)`
`static void` | `main(java.lang.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 org.w3c.dom.Element loadDocument(java.lang.String location)
                                        throws ConfigureException

  Throws:
    `ConfigureException`

### loadDocument

    protected org.w3c.dom.Element loadDocument(java.io.InputStream is)
                                        throws ConfigureException

  Throws:
    `ConfigureException`

### getMBeanElement

    protected org.w3c.dom.Element getMBeanElement(org.w3c.dom.Element root)
                                           throws ConfigureException

  Throws:
    `ConfigureException`

### configure

    public void configure(java.lang.Object objToConfigure,
                          java.lang.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(java.lang.Object objToConfigure,
                          java.io.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(java.lang.String[] args)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1998-2005 JBoss Inc . All Rights Reserved.