ClassLoaderFactorypublic final class ClassLoaderFactory extends Object Utility class for building class loaders for Catalina. The factory
method requires the following parameters in order to build a new class
loader (with suitable defaults in all cases):
- A set of directories containing unpacked classes (and resources)
that should be included in the class loader's
repositories.
- A set of directories containing classes and resources in JAR files.
Each readable JAR file discovered in these directories will be
added to the class loader's repositories.
ClassLoader instance that should become the parent of
the new class loader.
|
Fields Summary |
---|
private static com.sun.org.apache.commons.logging.Log | log | private static int | debugDebugging detail level for processing the startup. |
Methods Summary |
---|
public static java.lang.ClassLoader | createClassLoader(java.io.File[] unpacked, java.io.File[] packed, java.lang.ClassLoader parent)Create and return a new class loader, based on the configuration
defaults and the specified directory paths:
return createClassLoader(unpacked, packed, null, parent);
| public static java.lang.ClassLoader | createClassLoader(java.io.File[] unpacked, java.io.File[] packed, java.net.URL[] urls, java.lang.ClassLoader parent)Create and return a new class loader, based on the configuration
defaults and the specified directory paths:
if (log.isDebugEnabled())
log.debug("Creating new class loader");
// Construct the "class path" for this class loader
ArrayList list = new ArrayList();
// Add unpacked directories
if (unpacked != null) {
for (int i = 0; i < unpacked.length; i++) {
File file = unpacked[i];
if (!file.exists() || !file.canRead())
continue;
if (log.isDebugEnabled())
log.debug(" Including directory or JAR "
+ file.getAbsolutePath());
URL url = new URL("file", null,
file.getCanonicalPath() + File.separator);
list.add(url.toString());
}
}
// Add packed directory JAR files
if (packed != null) {
for (int i = 0; i < packed.length; i++) {
File directory = packed[i];
if (!directory.isDirectory() || !directory.exists() ||
!directory.canRead())
continue;
String filenames[] = directory.list();
for (int j = 0; j < filenames.length; j++) {
String filename = filenames[j].toLowerCase();
if (!filename.endsWith(".jar"))
continue;
File file = new File(directory, filenames[j]);
if (log.isDebugEnabled())
log.debug(" Including jar file " + file.getAbsolutePath());
URL url = new URL("file", null,
file.getCanonicalPath());
list.add(url.toString());
}
}
}
// Add remote URLs
if (urls != null) {
for (int i = 0; i < urls.length; i++) {
list.add(urls[i].toString());
}
}
// Construct the class loader itself
String array[] = (String[]) list.toArray(new String[list.size()]);
StandardClassLoader classLoader = null;
if (parent == null)
classLoader = new StandardClassLoader(array);
else
classLoader = new StandardClassLoader(array, parent);
classLoader.setDelegate(true);
return (classLoader);
| public static int | getDebug()Return the debugging detail level.
// ------------------------------------------------------ Static Properties
return (debug);
| public static void | setDebug(int newDebug)Set the debugging detail level.
debug = newDebug;
|
|