throws IOException,XMLException
{
Document doc = docLoader.load(location);
Element top = doc.getDocumentElement();
if (!top.getName().equals(COMPONENT)) {
throw new XMLException("Expecting "+COMPONENT+" 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(DEFINE);
while (appdefElements.hasNext()) {
Element appdefE = appdefElements.next();
String name = appdefE.getAttributeValue("name");
String className = appdefE.getAttributeValue("class");
String ref = appdefE.getAttributeValue("ref");
if (ref!=null) {
ClassLoader theLoader = loaders.get(ref.trim());
if (theLoader==null) {
throw new XMLException("Cannot find definition: "+ref);
}
if (className==null || name==null) {
continue;
}
try {
Class cdef = theLoader.loadClass(className);
definitions.put(name,cdef);
} catch (ClassNotFoundException ex) {
throw new XMLException("Cannot find class: "+ex.getMessage(),ex);
}
continue;
}
if (name!=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());
}
}
ClassLoader theLoader = this.getClass().getClassLoader();
if (libraries.size()!=0) {
URL [] list = new URL[libraries.size()];
list = libraries.toArray(list);
theLoader = new URLClassLoader(list,this.getClass().getClassLoader());
LOG.fine("ClassLoader: "+name+" -> "+theLoader);
LOG.fine(" Libraries: "+libraries);
loaders.put(name, theLoader);
}
if (className!=null) {
try {
Class cdef = theLoader.loadClass(className);
definitions.put(name,cdef);
} catch (ClassNotFoundException ex) {
throw new XMLException("Cannot find class: "+ex.getMessage(),ex);
}
}
} else if (name!=null) {
LOG.warning("The 'class' attribute is missing on the definition of '"+name+"'");
}