Top Description Inners Fields Constructors Methods
org.eclipse.jetty.xml

public Class XmlConfiguration

extends Object
Class Inheritance
Imports
java.io.Closeable, .IOException, .InputStream, java.lang.annotation.Annotation, java.lang.reflect.Array, .Constructor, .Executable, .Field, .InvocationTargetException, .Method, .Modifier, .Parameter, java.net.InetAddress, .MalformedURLException, .URI, .URL, .UnknownHostException, java.nio.file.Files, .Path, .Paths, .StandardOpenOption, java.util.ArrayList, .Arrays, .Collection, .Collections, .Comparator, .HashMap, .HashSet, .List, .Locale, .Map, .Objects, .Properties, .Queue, .ServiceLoader, .Set, java.util.stream.Collectors, .Stream, org.eclipse.jetty.util.ConcurrentPool, .ExceptionUtil, .LazyList, .Loader, .Pool, .StringUtil, .TypeUtil, org.eclipse.jetty.util.annotation.Name, org.eclipse.jetty.util.component.ContainerLifeCycle, .Environment, .LifeCycle, org.eclipse.jetty.util.resource.Resource, .ResourceFactory, org.slf4j.Logger, .LoggerFactory, org.xml.sax.SAXException

Configures 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 interface 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.

The configuration can be parameterised with properties that are looked up via the Property XML element and set on the configuration via the map returned from getProperties()

The configuration can create and lookup beans by ID. If multiple configurations are used, then it is good practise to copy the entries from the getIdMap() of a configuration to the next configuration so that they can share an ID space for beans.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final Pool<XmlConfiguration.ConfigurationParser>
private final String
private final Map<String, Object>
private final Resource
private ConfigurationProcessor
private final Map<String, String>
private static final Class<?>[]
public static final Comparator<Executable>
private static final Logger
private static final Class<?>[]
private static final List<ConfigurationProcessorFactory>
private static final Class<?>[]

Constructor Summary

AccessConstructor and Description
public
XmlConfiguration(Resource
the Resource to the XML configuration
resource
)

Reads and parses the XML configuration file.

public
XmlConfiguration(Resource
the Resource to the XML configuration
resource
,
Map<String, Object>
Map of objects with IDs
idMap
,
Map<String, String>
Map of properties
properties
)

Reads and parses the XML configuration file.

Method Summary

Modifier and TypeMethod and Description
private static int
public Object

Returns:

the configured object
configure
(Object
The object to be configured, which must be of a type or super type of the class attribute of the <Configure> element.
obj
)

Applies the XML configuration script to the given object.

public Object

Returns:

The newly created configured object.
configure
()

Applies the XML configuration script.

public Map<String, Object>

Returns:

A modifiable map of ID strings to Objects
getIdMap
()

Get the map of ID String to Objects that is used to hold and lookup any objects by ID.

A New, Get or Call XML element may have an id attribute which will cause the resulting object to be placed into this map.

private static List<XmlParser.Node>
getNodes(XmlParser.Node node, String elementName)

public Map<String, String>

Returns:

A modifiable map of properties.
getProperties
()

Get the map of properties used by the Property XML element to parametrize configuration.

public XmlParser
public void
initializeDefaults(Object
the object to initialize defaults on
object
)

Initialize a new Object defaults.

public static void
main(final String...
array of property and xml configuration filenames or Resources.
args
)

Runs the XML configurations as a main application.

public static String
public static String

Returns:

String to resolved and normalized path, or null if dir or destPath is empty.
resolvePath
(String
the directory (should be a directory reference, does not have to exist)
dir
,
String
the destination path (can be relative or absolute, syntax depends on OS + FileSystem in use, and does not need to exist)
destPath
)

Utility method to resolve a provided path against a directory.

private void
public void
setJettyStandardIdsAndProperties(Object
The Server object to set
server
,
Path
The webapps Resource
webapp
)

Set the standard IDs and properties expected in a jetty XML file:

  • RefId Server
  • Property jetty.home
  • Property jetty.home.uri
  • Property jetty.base
  • Property jetty.base.uri
  • Property jetty.webapps
  • Property jetty.webapps.uri
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait