org.pentaho.platform.plugin.services.pluginmgr
Class PluginClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by org.pentaho.platform.plugin.services.pluginmgr.PluginClassLoader

public class PluginClassLoader
extends java.net.URLClassLoader

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
PluginClassLoader(java.io.File pluginDir, java.lang.ClassLoader parent)
          Creates a class loader for loading plugin classes and discovering resources.
PluginClassLoader(java.io.File pluginDir, java.lang.Object o)
          Convenience method that creates a PluginClassLoader with the current classloader as it's parent.
PluginClassLoader(java.lang.String pluginDir, java.lang.Object parent)
          Deprecated. 
 
Method Summary
 java.lang.String getPluginAbsPath()
          Deprecated. 
 java.io.File getPluginDir()
           
 boolean isPluginClass(java.lang.Class<?> clazz)
          Deprecated. 
 java.util.List<java.lang.String> listLoadedJars()
          Deprecated. 
 java.lang.Class<?> loadClass(java.lang.String name, boolean resolve)
           
 void setOverrideLoad(boolean b)
          Controls whether or not this classloader will eagerly load a class requested by loadClass(String, boolean) ahead of the parent classloader.
 java.lang.String toString()
           
 
Methods inherited from class java.net.URLClassLoader
findResource, findResources, getURLs, newInstance, newInstance
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PluginClassLoader

public PluginClassLoader(java.io.File pluginDir,
                         java.lang.ClassLoader parent)
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 plugin
parent - the parent classloader

PluginClassLoader

public PluginClassLoader(java.io.File pluginDir,
                         java.lang.Object o)
Convenience method that creates a PluginClassLoader with the current classloader as it's parent.

Parameters:
pluginDir - the root directory of the plugin
o - the object from which the parent classloader will be derived

PluginClassLoader

@Deprecated
public PluginClassLoader(java.lang.String pluginDir,
                                    java.lang.Object parent)
Deprecated. 

Method Detail

setOverrideLoad

public void setOverrideLoad(boolean b)
Controls whether or not this classloader will eagerly load a class requested by loadClass(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.

getPluginDir

public java.io.File getPluginDir()

getPluginAbsPath

@Deprecated
public java.lang.String getPluginAbsPath()
Deprecated. 


listLoadedJars

@Deprecated
public java.util.List<java.lang.String> listLoadedJars()
Deprecated. 


isPluginClass

@Deprecated
public boolean isPluginClass(java.lang.Class<?> clazz)
Deprecated. 


loadClass

public java.lang.Class<?> loadClass(java.lang.String name,
                                    boolean resolve)
                             throws java.lang.ClassNotFoundException
Overrides:
loadClass in class java.lang.ClassLoader
Throws:
java.lang.ClassNotFoundException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object