PluginClassLoader

public class PluginClassLoader extends URLClassLoader

A PluginClassLoader is a class loader for loading classes which stored in the libraries specified in a plugin descriptor.

Author:Hugo Y. K. Lam

See also: Plugin

Constructors

PluginClassLoader

public PluginClassLoader(Plugin plugin, URL[] urls)

Creates a new instance of PluginClassLoader.

Parameters:
  • plugin – the Plugin corresponds to this class loader.
  • urls – the search paths.

PluginClassLoader

public PluginClassLoader(Plugin plugin, URL[] urls, ClassLoader parent)

Creates a new instance of PluginClassLoader.

Parameters:
  • plugin – the Plugin corresponds to this class loader.
  • urls – the search paths.
  • parent – the parent class loader.

PluginClassLoader

public PluginClassLoader(Plugin plugin, URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory)

Creates a new instance of PluginClassLoader.

Parameters:
  • plugin – the Plugin corresponds to this class loader.
  • urls – the search paths.
  • parent – the parent class loader.
  • factory – the URL stream handler factory.

Methods

findClass

protected Class findClass(String name)

Finds and loads the class with the specified name from the URL search path. Any URLs referring to JAR files are loaded and opened as needed until the class is found. If the class is not found from the search paths of this class loader, it will be searched from the imported class loaders.

Parameters:
  • name – the name of the class.
Throws:
Returns:

the resulting class.

See also: java.lang.ClassLoader.findClass(java.lang.String)

findImportedClass

protected Class findImportedClass(String name)

Finds and loads the class with the specified name from the imported class loaders.

Parameters:
  • name – the name of the class.
Throws:
Returns:

the resulting class.

See also: java.lang.ClassLoader.findClass(java.lang.String)

findResource

public URL findResource(String name)

Finds the resource with the specified name on the URL search paths.

Parameters:
  • name – the name of the resource.
Returns:

a URL for the resource, or null if the resource could not be found.

See also: java.lang.ClassLoader.findResource(java.lang.String)

getPlugin

public Plugin getPlugin()

Gets the plugin corresponds to this class loader.

Returns:the plugin corresponds to this class loader.

importClassLoader

void importClassLoader(ClassLoader loader)

Imports a class loader.

Parameters:
  • loader – the class loader to be imported.

toString

public String toString()

Returns a string representation of this class loader.

Returns:a string representation of this class loader.

See also: java.lang.Object.toString()