Class PluginClassLoader
java.lang.Object
java.lang.ClassLoader
java.security.SecureClassLoader
java.net.URLClassLoader
org.pentaho.platform.plugin.services.pluginmgr.PluginClassLoader
- All Implemented Interfaces:
Closeable
,AutoCloseable
A custom implementation of
URLClassLoader
for Pentaho Platform Plugins. It is used to load plugin jars and
classes and aids in retrieving resources by providing a root directory to search for resources related to plugins.
Note: PluginClassLoader
will search for jar files in a 'lib' subdirectory under the pluginDir provided in the
constructor. Class and other resources will be visible to this classloader in either the root directory of the plugin
or in the lib folder.
- Author:
- aphillips
-
Constructor Summary
ConstructorDescriptionPluginClassLoader
(File pluginDir, ClassLoader parent) Creates a class loader for loading plugin classes and discovering resources.PluginClassLoader
(File pluginDir, Object o) Convenience method that creates aPluginClassLoader
with the current classloader as it's parent. -
Method Summary
Modifier and TypeMethodDescriptionprotected static void
protected static URL[]
getPluginUrls
(File pluginDir) Class<?>
void
setOverrideLoad
(boolean b) Controls whether or not this classloader will eagerly load a class requested byloadClass(String, boolean)
ahead of the parent classloader.toString()
Methods inherited from class java.net.URLClassLoader
addURL, close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
Constructor Details
-
PluginClassLoader
Creates a class loader for loading plugin classes and discovering resources. Jars must be located in [pluginDir]/lib.- Parameters:
pluginDir
- the root directory of the pluginparent
- the parent classloader
-
PluginClassLoader
Convenience method that creates aPluginClassLoader
with the current classloader as it's parent.- Parameters:
pluginDir
- the root directory of the plugino
- the object from which the parent classloader will be derived
-
-
Method Details
-
setOverrideLoad
public void setOverrideLoad(boolean b) Controls whether or not this classloader will eagerly load a class requested byloadClass(String, boolean)
ahead of the parent classloader. or delegate the load to the parent. If this method is not called, the default behavior will apply which is to *not* override classloading.- Parameters:
b
- if true, loadClass method will look to this loader first to load a class, otherwise, the parent classloader will be queried first.
-
getPluginUrls
-
addJars
-
getPluginDir
-
loadClass
- Overrides:
loadClass
in classClassLoader
- Throws:
ClassNotFoundException
-
toString
-