{
DocumentLoader loader = new SAXDocumentLoader();
Document doc = loader.load(location);
Element top = doc.getDocumentElement();
if (!top.getName().equals(SERVER)) {
throw new XMLException("Expecting "+SERVER+" but found "+top.getName());
}
String value = top.getAttributeValue("autoconf-check");
if (value!=null) {
autoconfCheck = Long.parseLong(value) * 1000;
}
Element keyStoreE = top.getFirstElementNamed(KEYSTORE);
if (keyStoreE!=null) {
URI fileRef = keyStoreE.getBaseURI().resolve(keyStoreE.getAttributeValue("file"));
this.keyStorePath = new File(fileRef.getSchemeSpecificPart());
this.keyStorePassword = keyStoreE.getAttributeValue("password");
}
Iterator<Element> appdefElements = top.getElementsByName(APPDEF);
while (appdefElements.hasNext()) {
Element appdefE = appdefElements.next();
String name = appdefE.getAttributeValue("name");
String className = appdefE.getAttributeValue("class");
if (name!=null && className!=null) {
List<URL> libraries = new ArrayList<URL>();
Iterator<Element> libraryElements = appdefE.getElementsByName(LIBRARY);
while (libraryElements.hasNext()) {
Element libE = libraryElements.next();
String href = libE.getAttributeValue("href");
if (href!=null) {
URI u = libE.getBaseURI().resolve(href);
libraries.add(u.toURL());
}
}
try {
Class cdef = null;
if (libraries.size()==0) {
cdef = this.getClass().forName(className);
} else {
URL [] list = new URL[libraries.size()];
list = libraries.toArray(list);
ClassLoader urlLoader = new URLClassLoader(list,this.getClass().getClassLoader());
cdef = urlLoader.loadClass(className);
}
AppDef def = new AppDef(name,cdef);
appDefs.put(name,def);
} catch (ClassNotFoundException ex) {
throw new XMLException("Cannot find class: "+ex.getMessage(),ex);
}
}
}
Iterator<Element> interfaceElements = top.getElementsByName(INTERFACE);
while (interfaceElements.hasNext()) {