try {
factory.setSchema( schemaFactory.newSchema( new Source[] { new StreamSource( getClass().getClassLoader()
.getResourceAsStream( JCL_CONTEXT_SCHEMA ) ) } ) );
} catch (SAXException e) {
throw new JclContextException( e );
}
try {
DocumentBuilder builder = factory.newDocumentBuilder();
Document d = null;
if (file.startsWith( CLASSPATH ))
d = builder.parse( getClass().getClassLoader().getResourceAsStream( file.split( CLASSPATH )[1] ) );
else {
d = builder.parse( file );
}
NodeList nl = d.getElementsByTagName( ELEMENT_JCL );
for (int i = 0; i < nl.getLength(); i++) {
Node n = nl.item( i );
String name = n.getAttributes().getNamedItem( ATTRIBUTE_NAME ).getNodeValue();
JarClassLoader jcl = new JarClassLoader();
NodeList config = n.getChildNodes();
for (int j = 0; j < config.getLength(); j++) {
Node c = config.item( j );
if (c.getNodeName().equals( ELEMENT_LOADERS )) {
processLoaders( jcl, c );
} else if (c.getNodeName().equals( ELEMENT_SOURCES )) {
processSources( jcl, c );
}
}
jclContext.addJcl( name, jcl );
if (logger.isLoggable( Level.FINER ))
logger.finer( "JarClassLoader[" + name + "] loaded into context." );
}
} catch (SAXParseException e) {
JclContextException we = new JclContextException( e.getMessage() + " [" + file + " (" + e.getLineNumber()
+ ", " + e.getColumnNumber() + ")]" );
we.setStackTrace( e.getStackTrace() );
throw we;
} catch (JclContextException e) {
throw e;
} catch (Exception e) {
throw new JclContextException( e );
}
}