Class ClassLoaderBuilder


  • public final class ClassLoaderBuilder
    extends Object
    Class used to get the Servlet Class loader. The class loader returned is a child first class loader.
    This class is based on original code from the XINS project, by Anthony Goubard (anthony.goubard@japplis.com)
    Author:
    Paul Gregoire (mondain@gmail.com)
    • Field Detail

      • USE_CLASSPATH_LIB

        public static final int USE_CLASSPATH_LIB
        Load the Servlet code from the WAR file and use the current classpath for the libraries.
        See Also:
        Constant Field Values
      • USE_RED5_LIB

        public static final int USE_RED5_LIB
        Load the servlet code from the WAR file and try to find the libraries in the common red5 lib directory.
        See Also:
        Constant Field Values
      • USE_WAR_LIB

        public static final int USE_WAR_LIB
        Load the servlet code and the libraries from the WAR file. This may take some time as the libraries need to be extracted from the WAR file.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ClassLoaderBuilder

        public ClassLoaderBuilder()
    • Method Detail

      • build

        public static ClassLoader build()
        Default build uses Red5 common lib without a parent classloader.
        Returns:
        the class loader
      • build

        public static ClassLoader build​(Path path,
                                        int mode,
                                        ClassLoader parent)
        Gets a class loader based on mode.
        Parameters:
        path - the directory or file containing classes
        mode - the mode in which the servlet should be loaded. The possible values are
         USE_CURRENT_CLASSPATH, USE_CLASSPATH_LIB, USE_WAR_LIB
         
        parent - the parent class loader or null if you want the current threads class loader
        Returns:
        the Class loader to use to load the required class(es)