Class PluginClassLoader

java.lang.Object
java.lang.ClassLoader
com.atlassian.plugin.classloader.PluginClassLoader

public final class PluginClassLoader extends ClassLoader
A class loader used to load classes and resources from a given plugin.
See Also:
  • Constructor Details

    • PluginClassLoader

      public PluginClassLoader(File pluginFile)
      Parameters:
      pluginFile - file reference to the jar for this plugin
    • PluginClassLoader

      public PluginClassLoader(File pluginFile, ClassLoader parent)
      Parameters:
      pluginFile - file reference to the jar for this plugin
      parent - the parent class loader
    • PluginClassLoader

      public PluginClassLoader(File pluginFile, ClassLoader parent, File tempDirectory)
      Parameters:
      pluginFile - file reference to the jar for this plugin
      parent - the parent class loader
      tempDirectory - the temporary directory to store inner jars
      Since:
      2.0.2
  • Method Details

    • loadClass

      protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
      This implementation of loadClass 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, boolean) mechanism.
      Overrides:
      loadClass in class ClassLoader
      Parameters:
      name - Class to load
      resolve - true to resolve all class dependencies when loaded
      Returns:
      Class for the provided name
      Throws:
      ClassNotFoundException - if the class cannot be found in this class loader or its parent
    • getResource

      public URL getResource(String name)
      Load the named resource from this plugin. This implementation checks the plugin's contents first then delegates to the system loaders.
      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.
    • getLocalResource

      public URL getLocalResource(String name)
      Gets the resource from this classloader only
      Parameters:
      name - the name of the resource
      Returns:
      the URL to the resource, null if the resource was not found
    • close

      public void close()
    • getPluginInnerJars

      public List<File> getPluginInnerJars()