org.merlotxml.merlot.plugin
Class PluginClassLoader

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--org.merlotxml.merlot.plugin.PluginClassLoader

public class PluginClassLoader
extends java.lang.ClassLoader

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.

Version:
$Id: PluginClassLoader.java,v 1.12 2000/07/30 06:43:17 timm Exp $
Author:
Kelly Campbell, Tim McCune

Field Summary
protected  java.util.Hashtable _classes
          Classes we've already loaded
protected  java.util.List _embeddedZipFiles
          A list of zip files that were embedded in the main plugin zip file
protected  java.io.File _sourcedir
          This class loader originated from a source directory
protected  java.util.zip.ZipFile _sourcezip
          This class loader originated from a zip/jar file
protected static java.lang.String CLASSEXT
           
protected static java.lang.String DIR_CLASSES
           
protected static java.lang.String DIR_LIB
           
protected static char FILESEP
           
protected static java.lang.String FILESEPSTR
           
 
Constructor Summary
PluginClassLoader(java.io.File sourcedir)
          Constructor from a source directory or zipfile
 
Method Summary
protected  void copyEmbeddedZipFiles(java.util.zip.ZipFile zip)
          Writes out embedded zips to temp files
protected  java.io.InputStream findResourceInLib(java.lang.Object dirzip, java.lang.String name)
          Finds resources in lib/zip files
protected  java.io.InputStream findResourceInZip(java.util.zip.ZipFile zip, java.lang.String name)
          This finds a resource and returns a stream of it from a zip file
 java.io.InputStream getResourceAsStream(java.lang.String name)
           
 java.lang.Class loadClass(java.lang.String className)
          This is a simple version for external clients since they will always want the class resolved before it is returned to them.
protected  java.lang.Class loadClass(java.lang.String className, boolean resolveIt)
          This is the required version of loadClass which is called both from loadClass above and from the internal function FindClassFromClass.
 
Methods inherited from class java.lang.ClassLoader
defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, resolveClass, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIR_CLASSES

protected static final java.lang.String DIR_CLASSES

DIR_LIB

protected static final java.lang.String DIR_LIB

FILESEP

protected static char FILESEP

FILESEPSTR

protected static java.lang.String FILESEPSTR

CLASSEXT

protected static final java.lang.String CLASSEXT

_embeddedZipFiles

protected java.util.List _embeddedZipFiles
A list of zip files that were embedded in the main plugin zip file

_classes

protected java.util.Hashtable _classes
Classes we've already loaded

_sourcedir

protected java.io.File _sourcedir
This class loader originated from a source directory

_sourcezip

protected java.util.zip.ZipFile _sourcezip
This class loader originated from a zip/jar file
Constructor Detail

PluginClassLoader

public PluginClassLoader(java.io.File sourcedir)
Constructor from a source directory or zipfile
Method Detail

loadClass

public java.lang.Class loadClass(java.lang.String className)
                          throws java.lang.ClassNotFoundException
This is a simple version for external clients since they will always want the class resolved before it is returned to them.
Overrides:
loadClass in class java.lang.ClassLoader

loadClass

protected java.lang.Class loadClass(java.lang.String className,
                                    boolean resolveIt)
                             throws java.lang.ClassNotFoundException
This is the required version of loadClass which is called both from loadClass above and from the internal function FindClassFromClass.
Overrides:
loadClass in class java.lang.ClassLoader

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String name)
Overrides:
getResourceAsStream in class java.lang.ClassLoader

findResourceInZip

protected java.io.InputStream findResourceInZip(java.util.zip.ZipFile zip,
                                                java.lang.String name)
This finds a resource and returns a stream of it from a zip file

copyEmbeddedZipFiles

protected void copyEmbeddedZipFiles(java.util.zip.ZipFile zip)
Writes out embedded zips to temp files

findResourceInLib

protected java.io.InputStream findResourceInLib(java.lang.Object dirzip,
                                                java.lang.String name)
Finds resources in lib/zip files