org.eclipse.jetty.xml
类 XmlConfiguration

java.lang.Object
  继承者 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.


构造方法摘要
XmlConfiguration(InputStream configuration)
          Reads and parses the XML configuration stream.
XmlConfiguration(String configuration)
          Reads and parses the XML configuration string.
XmlConfiguration(URL configuration)
          Reads and parses the XML configuration file.
 
方法摘要
 Object configure()
          Applies the XML configuration script.
 Object configure(Object obj)
          Applies the XML configuration script to the given 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)
          已过时。 use getIdMap().put(...)
 void setProperties(Map<String,String> map)
          已过时。 use getProperties().putAll(...)
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

XmlConfiguration

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

参数:
configuration - the URL of the XML configuration
抛出:
IOException - if the configuration could not be read
SAXException - if the configuration could not be parsed

XmlConfiguration

public XmlConfiguration(String configuration)
                 throws SAXException,
                        IOException
Reads and parses the XML configuration string.

参数:
configuration - String of XML configuration commands excluding the normal XML preamble. The String should start with a "<Configure ....>" element.
抛出:
IOException - if the configuration could not be read
SAXException - if the configuration could not be parsed

XmlConfiguration

public XmlConfiguration(InputStream configuration)
                 throws SAXException,
                        IOException
Reads and parses the XML configuration stream.

参数:
configuration - An input stream containing a complete configuration file
抛出:
IOException - if the configuration could not be read
SAXException - if the configuration could not be parsed
方法详细信息

getIdMap

public Map<String,Object> getIdMap()

setIdMap

@Deprecated
public void setIdMap(Map<String,Object> map)
已过时。 use getIdMap().put(...)

参数:
map - the ID map

setProperties

@Deprecated
public void setProperties(Map<String,String> map)
已过时。 use getProperties().putAll(...)

参数:
map - the properties map

getProperties

public Map<String,String> getProperties()

configure

public Object configure(Object obj)
                 throws Exception
Applies the XML configuration script to the given object.

参数:
obj - The object to be configured, which must be of a type or super type of the class attribute of the <Configure> element.
返回:
the configured object
抛出:
Exception - if the configuration fails

configure

public Object configure()
                 throws Exception
Applies the XML configuration script. If the root element of the configuration has an ID, an object is looked up by ID and its type checked against the root element's type. Otherwise a new object of the type specified by the root element is created.

返回:
The newly created configured object.
抛出:
Exception - if the configuration fails

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.

参数:
args - array of property and xml configuration filenames or Resources.
抛出:
Exception - if the XML configurations cannot be run


Copyright © 2013. All Rights Reserved.