org.opennms.bb.dp.poller.plugins
Class JARClassLoader

java.lang.Object
  |
  +--java.lang.ClassLoader
        |
        +--org.opennms.bb.dp.poller.plugins.JARClassLoader

public class JARClassLoader
extends ClassLoader

This class is responsible for loading plugin classes from jar files.

Version:
$Revision: 1.2 $
Author:
Jason Johns, OpenNMS

Inner Class Summary
static class JARClassLoader.JAR
          Adapted from the JARClassLoader.java source from the jEdit project.
 
Inner classes inherited from class java.lang.ClassLoader
ClassLoader.NativeLibrary
 
Field Summary
private  JARClassLoader.JAR m_jar
          A jar file read from disk
private  ZipFile m_zipFile
          Used to open a jar file and load it
 
Fields inherited from class java.lang.ClassLoader
bootstrapClassPath, classes, defaultDomain, defaultPermissions, getClassLoaderPerm, initialized, loadedLibraryNames, nativeLibraries, nativeLibraryContext, nocerts, package2certs, packages, parent, scl, sclSet, sys_paths, systemNativeLibraries, usr_paths
 
Constructor Summary
JARClassLoader(String path)
          Constructor, loads any classes from a jar file on the filesystem.
 
Method Summary
static String fileToClass(String name)
          Adapted from the JARClassLoader.java source from the jEdit project.
 JARClassLoader.JAR getJar()
          This method returns the jar file that was created
private  Class loadClassFromZip(String fileName, boolean resolveIt)
          Adapted from the JARClassLoader.java source from the jEdit project.
private  void loadPluginClass(String aClassName, JARClassLoader.JAR aJar)
          This method gets a newly constructed class from the jar file and creates a new instance of it and loads it into a JAR file object.
 
Methods inherited from class java.lang.ClassLoader
, addClass, check, checkCerts, checkPackageAccess, compareCerts, copyFrom, defineClass, defineClass, defineClass, defineClass0, definePackage, findBootstrapClass, findBootstrapClass0, findClass, findLibrary, findLoadedClass, findNative, findResource, findResources, findSystemClass, getBootstrapClassPath, getBootstrapResource, getBootstrapResources, getCallerClassLoader, getDefaultDomain, getGetClassLoaderPerm, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, initializePath, isAncestor, loadClass, loadClass, loadClassInternal, loadLibrary, loadLibrary0, removeSystemClassLoader, resolveClass, resolveClass0, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

m_jar

private JARClassLoader.JAR m_jar
A jar file read from disk

m_zipFile

private ZipFile m_zipFile
Used to open a jar file and load it
Constructor Detail

JARClassLoader

public JARClassLoader(String path)
               throws IOException
Constructor, loads any classes from a jar file on the filesystem.
Parameters:
String - path, the path of the jar file to open
Method Detail

fileToClass

public static String fileToClass(String name)
Adapted from the JARClassLoader.java source from the jEdit project. Converts a file name to a class name. All slash characters are replaced with periods and the trailing '.class' is removed.
Parameters:
name - The file name

getJar

public JARClassLoader.JAR getJar()
This method returns the jar file that was created
Returns:
JAR, a newly constructed jar file

loadClassFromZip

private Class loadClassFromZip(String fileName,
                               boolean resolveIt)
                        throws ClassNotFoundException
Adapted from the JARClassLoader.java source from the jEdit project.

loadPluginClass

private void loadPluginClass(String aClassName,
                             JARClassLoader.JAR aJar)
This method gets a newly constructed class from the jar file and creates a new instance of it and loads it into a JAR file object.
Parameters:
String - aClassName, the name of the class in the jar file
JAR - aJar, the JAR object to add the class instance to