Class ClassLoaderFactory


  • public final class ClassLoaderFactory
    extends java.lang.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.
    Author:
    Craig R. McClanahan
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      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:
      static java.lang.ClassLoader createClassLoader​(java.util.List<ClassLoaderFactory.Repository> repositories, java.lang.ClassLoader parent)
      Create and return a new class loader, based on the configuration defaults and the specified directory paths:
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ClassLoaderFactory

        public ClassLoaderFactory()
    • Method Detail

      • createClassLoader

        public static java.lang.ClassLoader createClassLoader​(java.io.File[] unpacked,
                                                              java.io.File[] packed,
                                                              java.lang.ClassLoader parent)
                                                       throws java.lang.Exception
        Create and return a new class loader, based on the configuration defaults and the specified directory paths:
        Parameters:
        unpacked - Array of pathnames to unpacked directories that should be added to the repositories of the class loader, or null for no unpacked directories to be considered
        packed - Array of pathnames to directories containing JAR files that should be added to the repositories of the class loader, or null for no directories of JAR files to be considered
        parent - Parent class loader for the new class loader, or null for the system class loader.
        Returns:
        the new class loader
        Throws:
        java.lang.Exception - if an error occurs constructing the class loader
      • createClassLoader

        public static java.lang.ClassLoader createClassLoader​(java.util.List<ClassLoaderFactory.Repository> repositories,
                                                              java.lang.ClassLoader parent)
                                                       throws java.lang.Exception
        Create and return a new class loader, based on the configuration defaults and the specified directory paths:
        Parameters:
        repositories - List of class directories, jar files, jar directories or URLS that should be added to the repositories of the class loader.
        parent - Parent class loader for the new class loader, or null for the system class loader.
        Returns:
        the new class loader
        Throws:
        java.lang.Exception - if an error occurs constructing the class loader