if( log.isDebugEnabled() && workDir != null)
log.debug(sm.getString("webappLoader.deploy", workDir.getAbsolutePath()));
classLoader.setWorkDir(workDir);
WebResourceRoot resources = context.getResources();
// Setting up the class repository (/WEB-INF/classes), if it exists
String classesPath = "/WEB-INF/classes";
WebResource classes = resources.getResource(classesPath);
if (classes.isDirectory()) {
if(log.isDebugEnabled())
log.debug(sm.getString("webappLoader.classDeploy", classesPath,
classes.getURL().toExternalForm()));
// Adding the repository to the class loader
classLoader.setRepository(classesPath + "/", classes);
loaderRepositories.add(classesPath + "/" );
}
// Setting up the JAR repository (/WEB-INF/lib), if it exists
// TODO Simplify this in a similar manner to WEB-INF/classes
String libPath = "/WEB-INF/lib";
classLoader.setJarPath(libPath);
WebResource libDir = resources.getResource(libPath);
if (libDir.isDirectory()) {
boolean copyJars = false;
String absoluteLibPath = libDir.getCanonicalPath();
File destDir = null;
if (absoluteLibPath != null) {
destDir = new File(absoluteLibPath);
} else {
copyJars = true;
destDir = new File(workDir, libPath);
if (!destDir.mkdirs() && !destDir.isDirectory()) {
throw new IOException(
sm.getString("webappLoader.mkdirFailure"));
}
}
WebResource[] jars = resources.listResources(libPath);
for (WebResource jar : jars) {
String jarName = jar.getName();
if (!jarName.endsWith(".jar"))