ClassLoader classLoader;
NodeList classpathElements = document.getDocumentElement().getElementsByTagName("classpath");
if (classpathElements.getLength() < 1) {
classLoader = getParentClassLoader(applicationContext);
} else if (classpathElements.getLength() > 1) {
throw new FatalBeanException("Expected only classpath element but found " + classpathElements.getLength());
} else {
Element classpathElement = (Element) classpathElements.item(0);
String fileDelegation = classpathElement.getAttribute("file");
if (fileDelegation != null) {
URL url = getResource(fileDelegation);
if (url != null) {
try {
DocumentBuilder builder = new SourceTransformer().createDocumentBuilder();
Document doc = builder.parse(url.toString());
classLoader = getClassLoader(applicationContext, reader, doc);
return classLoader;
} catch (Exception e) {
throw new FatalBeanException("Unable to load " + url + " file.", e);
}
}
}
// Delegation mode