|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.ClassLoader
org.merlotxml.merlot.plugin.PluginClassLoader
This classloader loads plugin classes and resources from merlot plugin jar files or plugin development directories.
When loading a class or a resource from a jar file, it first looks in the jar directly (as the normal class loader does), then it checks the classes directory, and lastly, it checks for embedded jar files located in a lib directory within the plugin jar file.
To load classes and resource from embedded jar files, the PluginClassLoader must write out jars in the lib directory to a temporary location to be used by ZipFile.
Constructor Summary | |
PluginClassLoader(java.io.File source)
Creates a new PluginClassLoader from a the specified directory or jar file |
Method Summary | |
protected void |
copyEmbeddedZipFiles(java.util.zip.ZipFile zip)
Writes out embedded zips to temp files |
protected java.lang.Class |
findClass(java.lang.String name)
|
protected java.lang.String |
findLibrary(java.lang.String libname)
|
protected java.lang.String |
findLibraryInDependencies(java.lang.String libname)
|
java.net.URL |
findResource(java.lang.String name)
Generates an URL class of the resource in a jar file or directory. |
protected java.net.URL |
findResourceInClasses(java.lang.Object dirzip,
java.lang.String name)
Finds resources in classes directory |
protected java.net.URL |
findResourceInDependencies(java.lang.String name)
|
protected java.net.URL |
findResourceInLib(java.lang.Object dirzip,
java.lang.String name)
Finds resources in lib/zip files |
protected java.net.URL |
findResourceInRoot(java.lang.Object dirzip,
java.lang.String name)
Finds resources in jar or directory root |
protected java.net.URL |
findResourceInZip(java.io.File file,
java.lang.String name)
This finds a resource and returns a stream of it from a zip file |
void |
setSource(java.io.File source)
Sets this loader's source to the given directory or jar file. |
protected java.io.File |
unpackZipFile(java.io.File f)
Unpacks a plugin file where the plugin is located |
Methods inherited from class java.lang.ClassLoader |
clearAssertionStatus, defineClass, defineClass, defineClass, definePackage, findLoadedClass, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, 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 |
public PluginClassLoader(java.io.File source)
source
- the plugin jar file or directorysetSource(File)
Method Detail |
public void setSource(java.io.File source) throws java.lang.IllegalArgumentException
source
- a directory containing the plugin.xml, dtd, and classes for a plugin, or a
jar file containing the same contents.
java.lang.IllegalArgumentException
- if the source is not a directory or readable Jar filepublic java.net.URL findResource(java.lang.String name)
<path>.<to>.<some>.<class>.<NameOfClass>.class.getResource(<resourceName>);will pass as a parameter 'name' this string value:
<path>/<to>/<some>/<class>/<resourceName>This value is used as an end of the URL. The begining depends on the source of the classes (if we use a JAR file or a directory).
name
- Name of the resource as is passed from the standard
getResource method. It is a full class name with all '.' replaced by '/'.
protected java.lang.Class findClass(java.lang.String name) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
protected java.net.URL findResourceInZip(java.io.File file, java.lang.String name)
protected void copyEmbeddedZipFiles(java.util.zip.ZipFile zip)
protected java.io.File unpackZipFile(java.io.File f) throws java.io.IOException
java.io.IOException
protected java.net.URL findResourceInLib(java.lang.Object dirzip, java.lang.String name)
protected java.net.URL findResourceInClasses(java.lang.Object dirzip, java.lang.String name)
protected java.net.URL findResourceInRoot(java.lang.Object dirzip, java.lang.String name)
protected java.net.URL findResourceInDependencies(java.lang.String name)
protected java.lang.String findLibrary(java.lang.String libname)
protected java.lang.String findLibraryInDependencies(java.lang.String libname)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |