public class PluginClassLoader extends URLClassLoader
Class loader which loads the classes requested by the plugins. It first tries
to search in the classpath, then it requests the class to the parent
classloader, then it searches in the owns plugins' library dir, and if all
these methods fail, it tries to load the class from any of the depended
plugins. Finally, if this also fails, the other classloaders provided in the
addLoaders method are requested to load the class.
The class loader can also be used to load resources from the plugin's
directory by using the getResource() method.
| Constructor and Description |
|---|
PluginClassLoader(URL[] jars,
String baseDir,
ClassLoader cl,
List<PluginClassLoader> pluginLoaders) |
PluginClassLoader(URL[] jars,
String baseDir,
ClassLoader cl,
PluginClassLoader[] pluginLoaders)
Creates a new PluginClassLoader object.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addLoaders(ArrayList classLoaders)
Adds other classloader to use when all the normal methods fail.
|
void |
addPluginClassLoader(PluginClassLoader pluginClassLoader) |
String |
getBaseDir()
Gets the plugin's base Iterator
|
protected PermissionCollection |
getPermissions(CodeSource codesource) |
String |
getPluginName()
Returns the name of the plugin (the name of the directory containing the
plugin).
|
URL |
getResource(String res)
Gets the requested resource.
|
Enumeration<URL> |
getResources(String name) |
protected Class |
loadClass(String name,
boolean resolve)
Carga la clase
|
protected Class |
singleLoadClass(String name) |
String |
toString() |
addURL, close, definePackage, findClass, findResource, findResources, getResourceAsStream, getURLs, newInstance, newInstancedefineClass, defineClassclearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSignerspublic PluginClassLoader(URL[] jars, String baseDir, ClassLoader cl, PluginClassLoader[] pluginLoaders) throws IOException
jars - Array with the search paths where classes will be searchedbaseDir - Base directory for this plugin. This is the directory
which will be used as basedir in the getResources method.cl - The parent classloader of this classloader. It will be used to
search classes before trying to search in the plugin's directorypluginLoaders - The classloaders of the depended plugins.IOExceptionpublic PluginClassLoader(URL[] jars, String baseDir, ClassLoader cl, List<PluginClassLoader> pluginLoaders) throws IOException
IOExceptionprotected Class singleLoadClass(String name) throws ClassNotFoundException
ClassNotFoundExceptionprotected Class loadClass(String name, boolean resolve) throws ClassNotFoundException
loadClass in class ClassLoadername - Nombre de la claseresolve - Si se ha de resolver la clase o noClassNotFoundException - Si no se pudo encontrar la clasepublic URL getResource(String res)
getResource in class ClassLoaderres - An absolute or relative path to the requested resource.public Enumeration<URL> getResources(String name) throws IOException
getResources in class ClassLoaderIOExceptionpublic String getPluginName()
protected PermissionCollection getPermissions(CodeSource codesource)
getPermissions in class URLClassLoaderpublic String getBaseDir()
public static void addLoaders(ArrayList classLoaders)
classLoaders - An ArrayList of ClassLoaders which will be used to
load classes when all the normal methods fail.public void addPluginClassLoader(PluginClassLoader pluginClassLoader)