public final class

PluginClassLoader

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

Class Overview

A class loader used to load classes and resources from a given plugin.

Summary

Public Constructors
PluginClassLoader(File pluginFile)
PluginClassLoader(File pluginFile, ClassLoader parent)
PluginClassLoader(File pluginFile, ClassLoader parent, File tempDirectory)
Public Methods
void close()
URL getLocalResource(String name)
Gets the resource from this classloader only
URL getResource(String name)
Load the named resource from this plugin.
Protected Methods
synchronized Class<?> loadClass(String name, boolean resolve)
This implementation of loadClass uses a child first delegation model rather than the standard parent first.
[Expand]
Inherited Methods
From class java.lang.ClassLoader
From class java.lang.Object

Public Constructors

public PluginClassLoader (File pluginFile)

Parameters
pluginFile file reference to the jar for this plugin

public PluginClassLoader (File pluginFile, ClassLoader parent)

Parameters
pluginFile file reference to the jar for this plugin
parent the parent class loader

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

Public Methods

public void close ()

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

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.

Parameters
name the name of the resource.
Returns
  • the URL to the resource, null if the resource was not found.

Protected Methods

protected synchronized Class<?> loadClass (String name, boolean resolve)

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 loadClass(String, boolean) mechanism.

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