Class CustomClassLoader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class CustomClassLoader
    extends java.net.URLClassLoader
    Custom class loader will load the classes from the class path, CCL will load the classes from the URL first, if it cannot find the required class it will let the parent class loader do its job. Note: If the CCL is GC'ed then the associated classes will be unloaded.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addClassPath​(File dir)  
      java.lang.Class<?> loadClass​(java.lang.String name)  
      java.lang.Class<?> loadClassInternal​(java.lang.String name)  
      • Methods inherited from class java.net.URLClassLoader

        addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
      • Methods inherited from class java.security.SecureClassLoader

        defineClass, defineClass
      • Methods inherited from class java.lang.ClassLoader

        clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
      • Methods inherited from class java.lang.Object

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

      • CustomClassLoader

        public CustomClassLoader​(java.lang.ClassLoader parent)
      • CustomClassLoader

        public CustomClassLoader​(java.lang.ClassLoader parent,
                                 File classPathDir)
    • Method Detail

      • addClassPath

        public void addClassPath​(File dir)
      • loadClass

        public java.lang.Class<?> loadClass​(java.lang.String name)
                                     throws java.lang.ClassNotFoundException
        Overrides:
        loadClass in class java.lang.ClassLoader
        Throws:
        java.lang.ClassNotFoundException
      • loadClassInternal

        public java.lang.Class<?> loadClassInternal​(java.lang.String name)
                                             throws java.lang.ClassNotFoundException
        Throws:
        java.lang.ClassNotFoundException