org.eclipse.jetty.xml
public class XmlConfiguration extends java.lang.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 and Description |
---|
XmlConfiguration(java.io.InputStream configuration)
Reads and parses the XML configuration stream.
|
XmlConfiguration(java.lang.String configuration)
Reads and parses the XML configuration string.
|
XmlConfiguration(java.net.URL configuration)
Reads and parses the XML configuration file.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
configure()
Applies the XML configuration script.
|
java.lang.Object |
configure(java.lang.Object obj)
Applies the XML configuration script to the given object.
|
java.util.Map<java.lang.String,java.lang.Object> |
getIdMap() |
java.util.Map<java.lang.String,java.lang.String> |
getProperties() |
void |
initializeDefaults(java.lang.Object object)
Initialize a new Object defaults.
|
static void |
main(java.lang.String[] args)
Run the XML configurations as a main application.
|
void |
setIdMap(java.util.Map<java.lang.String,java.lang.Object> map)
Deprecated.
use
getIdMap() .put(...) |
void |
setProperties(java.util.Map<java.lang.String,java.lang.String> map)
Deprecated.
use
getProperties() .putAll(...) |
public XmlConfiguration(java.net.URL configuration) throws org.xml.sax.SAXException, java.io.IOException
configuration
- the URL of the XML configurationjava.io.IOException
- if the configuration could not be readorg.xml.sax.SAXException
- if the configuration could not be parsedpublic XmlConfiguration(java.lang.String configuration) throws org.xml.sax.SAXException, java.io.IOException
configuration
- String of XML configuration commands excluding the normal XML preamble.
The String should start with a "<Configure ....>" element.java.io.IOException
- if the configuration could not be readorg.xml.sax.SAXException
- if the configuration could not be parsedpublic XmlConfiguration(java.io.InputStream configuration) throws org.xml.sax.SAXException, java.io.IOException
configuration
- An input stream containing a complete configuration filejava.io.IOException
- if the configuration could not be readorg.xml.sax.SAXException
- if the configuration could not be parsedpublic java.util.Map<java.lang.String,java.lang.Object> getIdMap()
@Deprecated public void setIdMap(java.util.Map<java.lang.String,java.lang.Object> map)
getIdMap()
.put(...)map
- the ID map@Deprecated public void setProperties(java.util.Map<java.lang.String,java.lang.String> map)
getProperties()
.putAll(...)map
- the properties mappublic java.util.Map<java.lang.String,java.lang.String> getProperties()
public java.lang.Object configure(java.lang.Object obj) throws java.lang.Exception
obj
- The object to be configured, which must be of a type or super type
of the class attribute of the <Configure> element.java.lang.Exception
- if the configuration failspublic java.lang.Object configure() throws java.lang.Exception
java.lang.Exception
- if the configuration failspublic void initializeDefaults(java.lang.Object object)
This method must be called by any ConfigurationProcessor
when it
creates a new instance of an object before configuring it, so that a derived
XmlConfiguration class may inject default values.
object
- public static void main(java.lang.String[] args) throws java.lang.Exception
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.
args
- array of property and xml configuration filenames or Resource
s.java.lang.Exception
- if the XML configurations cannot be runCopyright © 2014. All Rights Reserved.