org.eclipse.jetty.xml
Class XmlConfiguration

java.lang.Object
  extended by org.eclipse.jetty.xml.XmlConfiguration

public class XmlConfiguration
extends 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.

The actual XML file format may be changed (eg to spring XML) by implementing the ConfigurationProcessorFactory interfaces to be found by the ServiceLoader by using the DTD and first tag element in the file. Note that DTD will be null if validation is off.


Constructor Summary
XmlConfiguration(InputStream configuration)
          Constructor.
XmlConfiguration(String configuration)
          Constructor.
XmlConfiguration(URL configuration)
          Constructor.
 
Method Summary
 Object configure()
          Configure an object.
 Object configure(Object obj)
          Configure an object.
 Map<String,Object> getIdMap()
           
 Map<String,String> getProperties()
           
static void main(String[] args)
          Run the XML configurations as a main application.
 void setIdMap(Map<String,Object> map)
          Deprecated. use getIdMap().put(...)
 void setProperties(Map<String,String> map)
          Deprecated. use getProperties().putAll(...)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlConfiguration

public XmlConfiguration(URL configuration)
                 throws SAXException,
                        IOException
Constructor. Reads the XML configuration file.

Parameters:
configuration -
Throws:
SAXException
IOException

XmlConfiguration

public XmlConfiguration(String configuration)
                 throws SAXException,
                        IOException
Constructor.

Parameters:
configuration - String of XML configuration commands excluding the normal XML preamble. The String should start with a " Throws:
SAXException
IOException

XmlConfiguration

public XmlConfiguration(InputStream configuration)
                 throws SAXException,
                        IOException
Constructor.

Parameters:
configuration - An input stream containing a complete e.g. configuration file
Throws:
SAXException
IOException
Method Detail

getIdMap

public Map<String,Object> getIdMap()

setIdMap

public void setIdMap(Map<String,Object> map)
Deprecated. use getIdMap().put(...)


setProperties

public void setProperties(Map<String,String> map)
Deprecated. use getProperties().putAll(...)


getProperties

public Map<String,String> getProperties()

configure

public Object configure(Object obj)
                 throws Exception
Configure an object.

Apply the XML configuration script to the passed object.

Parameters:
obj - The object to be configured, which must be of a type or super type of the class attribute of the Configure element.
Throws:
Exception

configure

public Object configure()
                 throws 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:
Exception

main

public static void main(String[] args)
                 throws Exception
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 Resources.
Throws:
Exception


Copyright © 1995-2011 Mort Bay Consulting. All Rights Reserved.