Parse the XML configuration information and
make it available to clients.
try {
// Request DOM Implementation and Xerces Parser
Builder builder =
new DOMBuilder("org.jdom.adapters.XercesDOMAdapter");
// Get the Configuration Document, with validation
Document doc = builder.build(in);
// Get the root element
Element root = doc.getRootElement();
// Get the JavaXML namespace
Namespace ns = Namespace.getNamespace("JavaXML",
"http://www.oreilly.com/catalog/javaxml/");
// Load the hostname, port, and handler class
hostname = root.getChild("hostname", ns).getContent();
driverClass = root.getChild("parserClass", ns).getContent();
portNumber =
Integer.parseInt(root.getChild("port", ns).getContent());
// Get the handlers
List handlerElements =
root.getChild("xmlrpc-server", ns)
.getChild("handlers", ns)
.getChildren("handler", ns);
Iterator i = handlerElements.iterator();
while (i.hasNext()) {
Element current = (Element)i.next();
handlers.put(current.getChild("identifier", ns).getContent(),
current.getChild("class", ns).getContent());
}
} catch (JDOMException e) {
throw new IOException(e.getMessage());
}