XML-based configuration utilities for Eclipse Jetty providing IoC mechanism for component configuration.
npx @tessl/cli install tessl/maven-org-eclipse-jetty--jetty-xml@12.0.0XML-based configuration utilities for Eclipse Jetty providing an Inversion of Control (IoC) mechanism for component configuration. The library enables declarative configuration of Jetty components and general Java objects through XML files, supporting property substitution, bean ID management, and extensible configuration processing.
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-xml</artifactId>
<version>12.0.21</version>
</dependency>import org.eclipse.jetty.xml.XmlConfiguration;
import org.eclipse.jetty.xml.XmlParser;
import org.eclipse.jetty.xml.XmlAppendable;import org.eclipse.jetty.xml.XmlConfiguration;
import org.eclipse.jetty.util.resource.Resource;
// Load and apply XML configuration
Resource xmlResource = Resource.newResource("jetty-config.xml");
XmlConfiguration config = new XmlConfiguration(xmlResource);
// Configure a new object from XML
Object configuredObject = config.configure();
// Or configure an existing object
MyServer server = new MyServer();
config.configure(server);
// Share configuration state between multiple XML files
XmlConfiguration config2 = new XmlConfiguration(
Resource.newResource("jetty-config2.xml"),
config.getIdMap(), // Share object IDs
config.getProperties() // Share properties
);The Jetty XML configuration system is built around several key components:
Core functionality for loading XML configuration files and applying them to Java objects through reflection-based dependency injection.
class XmlConfiguration {
XmlConfiguration(Resource resource);
XmlConfiguration(Resource resource, Map<String, Object> idMap, Map<String, String> properties);
Object configure() throws Exception;
Object configure(Object obj) throws Exception;
Map<String, Object> getIdMap();
Map<String, String> getProperties();
}Advanced XML parsing capabilities with validation, entity resolution, and DOM-like tree processing.
class XmlParser {
XmlParser();
XmlParser(boolean validating);
Node parse(String url) throws IOException, SAXException;
Node parse(File file) throws IOException, SAXException;
Node parse(InputStream in) throws IOException, SAXException;
void setValidating(boolean validating);
void addCatalog(URI catalogXml);
}Utilities for programmatically generating well-formed XML with proper indentation and encoding.
class XmlAppendable {
XmlAppendable(OutputStream out);
XmlAppendable openTag(String tag);
XmlAppendable openTag(String tag, Map<String, String> attributes);
XmlAppendable closeTag();
XmlAppendable tag(String tag, String content);
XmlAppendable content(String s);
}Extensible configuration processing system supporting custom configuration formats and processors.
interface ConfigurationProcessor {
void init(Resource resource, XmlParser.Node root, XmlConfiguration configuration);
Object configure(Object obj) throws Exception;
Object configure() throws Exception;
}
interface ConfigurationProcessorFactory {
ConfigurationProcessor getConfigurationProcessor(String dtd, String tag);
}class XmlConfigurationException extends IllegalStateException {
XmlConfigurationException(String s);
XmlConfigurationException(String message, Throwable cause);
}
class XmlParser.Node {
String getTag();
String getAttribute(String name);
Node get(String tag);
Iterator<Node> iterator(String tag);
}
class XmlParser.Attribute {
String getName();
String getValue();
}
class BaseClassCatalog implements Catalog, EntityResolver {
static BaseClassCatalog load(URI uriToCatalogXml, Class<?> baseClass);
String matchPublic(String publicId);
String matchSystem(String systemId);
}
class EnvironmentBuilder {
EnvironmentBuilder(String name);
void addClassPath(String... classPaths);
void addModulePath(String modulePath);
Environment build();
}