com.atlassian.plugin.classloader
Class PluginClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by 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:
PluginsClassLoader

Constructor Summary
PluginClassLoader(File pluginFile)
           
PluginClassLoader(File pluginFile, ClassLoader parent)
           
PluginClassLoader(File pluginFile, ClassLoader parent, File tempDirectory)
           
 
Method Summary
 void close()
           
 URL getLocalResource(String name)
          Gets the resource from this classloader only
 List<File> getPluginInnerJars()
           
 URL getResource(String name)
          Load the named resource from this plugin.
protected  Class<?> loadClass(String name, boolean resolve)
          This implementation of loadClass uses a child first delegation model rather than the standard parent first.
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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 Detail

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()


Copyright © 2015 Atlassian. All rights reserved.