Class PluginClassLoader

All Implemented Interfaces:
Closeable, AutoCloseable

public class PluginClassLoader extends URLClassLoader
One instance of this class should be created by plugin manager for every available plug-in. By default, this class loader is a Parent Last ClassLoader - it loads the classes from the plugin's jars before delegating to the parent class loader. Use parentFirst to change the loading strategy.
Author:
Decebal Suiu
  • Constructor Details

  • Method Details

    • addURL

      public void addURL(URL url)
      Overrides:
      addURL in class URLClassLoader
    • addFile

      public void addFile(File file)
    • loadClass

      public Class<?> loadClass(String className) throws ClassNotFoundException
      By default, it uses a child first delegation model rather than the standard parent first. If the requested class cannot be found in this class loader, the parent class loader will be consulted via the standard ClassLoader.loadClass(String) mechanism. Use parentFirst to change the loading strategy.
      Overrides:
      loadClass in class ClassLoader
      Throws:
      ClassNotFoundException
    • getResource

      public URL getResource(String name)
      Load the named resource from this plugin. By default, this implementation checks the plugin's classpath first then delegates to the parent. Use parentFirst to change the loading strategy.
      Overrides:
      getResource in class ClassLoader
      Parameters:
      name - the name of the resource.
      Returns:
      the URL to the resource, null if the resource was not found.
    • getResources

      public Enumeration<URL> getResources(String name) throws IOException
      Overrides:
      getResources in class ClassLoader
      Throws:
      IOException