* @return
*/
private static ClassLoader createApplicationLibrariesClassLoader(
ClassLoader parentClassLoader, URL[] urlList, String moduleId) {
if( urlList != null ) {
ClassLoaderChain appChain = new ClassLoaderChain(parentClassLoader);
appChain.setName("Application library chain for " + moduleId);
for(URL url:urlList){
try {
ClassLoader urlLoader = classLoaderRegistry.get(url.toURI());
//if this library has already been referred in a different application and been
//loaded, share this library by reusing the same classloader.
if(urlLoader == null) {
urlLoader = new ASURLClassLoader(new URL[]{url}, parentClassLoader);
classLoaderRegistry.put(url.toURI(),urlLoader);
}
appChain.addToList(urlLoader);
} catch (URISyntaxException e) {
_logger.log(Level.FINE, "Error while resolving " + url + " to URI");
_logger.log(Level.WARNING, e.getMessage());
}
}
//Finally suffix the optional chain. The optional chain is suffixed to the appchain
//to enable an administrator to override libraries in the optional chain via
//the libraris deploy-time attribute.
ClassLoader optionalChain = PELaunch.getOptionalChain();
appChain.addToList(optionalChain);
return appChain;
}
return null;
}