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.mortbay.xml
Class XmlConfiguration

    java.lang.Object
      org.mortbay.xml.XmlConfiguration

    public class XmlConfiguration

extends java.lang.Object

Configure Objects from XML. This class reads an XML file conforming to the configure.dtd DTD and uses it to configure and object by calling set, put or other methods on the object.

Author:
  Greg Wilkins (gregw)

Constructor Summary
`XmlConfiguration(java.io.InputStream configuration)` Constructor.
`XmlConfiguration(java.lang.String configuration)` Constructor.
`XmlConfiguration(java.net.URL configuration)` Constructor.

Method Summary
`java.lang.Object` | `configure()` Configure an object.
`void` | `configure(java.lang.Object obj)` Configure an object.
`java.util.Map` | `getIdMap()`
`java.util.Map` | `getProperties()`
`static void` | `main(java.lang.String[] args)` Run the XML configurations as a main application.
`void` | `setIdMap(java.util.Map map)`
`void` | `setProperties(java.util.Map map)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### XmlConfiguration

    public XmlConfiguration(java.net.URL configuration)
                     throws org.xml.sax.SAXException,
                            java.io.IOException

  Constructor. Reads the XML configuration file.

  Parameters:
    `configuration` -
  Throws:
    `org.xml.sax.SAXException`
    `java.io.IOException`

### XmlConfiguration

    public XmlConfiguration(java.lang.String configuration)
                     throws org.xml.sax.SAXException,
                            java.io.IOException

  Constructor.

  Parameters:
    `configuration` - String of XML configuration commands excluding the normal XML preamble. The String should start with a " Throws:
    `org.xml.sax.SAXException`
    `java.io.IOException`

### XmlConfiguration

    public XmlConfiguration(java.io.InputStream configuration)
                     throws org.xml.sax.SAXException,
                            java.io.IOException

  Constructor.

  Parameters:
    `configuration` - An input stream containing a complete e.g. configuration file
  Throws:
    `org.xml.sax.SAXException`
    `java.io.IOException`

Method Detail

### getIdMap

    public java.util.Map getIdMap()

### setIdMap

    public void setIdMap(java.util.Map map)

### setProperties

    public void setProperties(java.util.Map map)

### getProperties

    public java.util.Map getProperties()

### configure

    public void configure(java.lang.Object obj)
                   throws java.lang.Exception

  Configure an object. If the object is of the approprate class, the XML configuration script is applied to the object.

  Parameters:
    `obj` - The object to be configured.
  Throws:
    `java.lang.Exception`

### configure

    public java.lang.Object configure()
                               throws java.lang.Exception

  Configure an object. If the configuration has an ID, an object is looked up by ID and it's type check. Otherwise a new object is created.

  Returns:
    The newly created configured object.
  Throws:
    `java.lang.Exception`

### main

    public static void main(java.lang.String[] args)

  Run the XML configurations as a main application. The command line is used to obtain properties files (must be named '*.properties') and XmlConfiguration files.

  Any property file on the command line is added to a combined Property instance that is passed to each configuration file via `setProperties(Map)`.

  Each configuration file on the command line is used to create a new XmlConfiguration instance and the `configure()` method is used to create the configured object. If the resulting object is an instance of `LifeCycle`, then it is started.

  Any IDs created in a configuration are passed to the next configuration file on the command line using `getIdMap()` and `setIdMap(Map)`. This allows objects with IDs created in one config file to be referenced in subsequent config files on the command line.

  Parameters:
    `args` - array of property and xml configuration filenames or `Resource`s.

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 © 1995-2010 Mort Bay Consulting. All Rights Reserved.