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

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

public class PluginLoader
extends ClassLoader

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

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

Inner Class Summary
static class PluginLoader.Plugin
          Adapted from the JARClassLoader.java source from the jEdit project.
 
Inner classes inherited from class java.lang.ClassLoader
ClassLoader.NativeLibrary
 
Field Summary
private  File m_directory
           
private  HashMap m_plugins
           
private static String PLUGIN_PREFIX
           
 
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
PluginLoader()
           
 
Method Summary
 PluginLoader.Plugin fileLoader(String path)
           
static String fileToClass(String name)
          Adapted from the JARClassLoader.java source from the jEdit project.
 HashMap getPlugins()
           
 PluginLoader.Plugin jarLoader(String aPath)
          loads any classes from a jar file on the filesystem.
 Class loadClassFromFile(String aFileName, boolean resolveIt)
           
private  Class loadClassFromZip(String aFileName, ZipFile aZipFile, boolean resolveIt)
          Adapted from the JARClassLoader.java source from the jEdit project.
 void loadFromDirectory(String aDirectory)
           
 void loadFromJar(String aDirectory)
           
 ServiceMonitor retrieveServiceMonitor(String aServiceName)
           
 
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_plugins

private HashMap m_plugins

m_directory

private File m_directory

PLUGIN_PREFIX

private static final String PLUGIN_PREFIX
Constructor Detail

PluginLoader

public PluginLoader()
Method Detail

loadFromJar

public void loadFromJar(String aDirectory)

loadFromDirectory

public void loadFromDirectory(String aDirectory)

retrieveServiceMonitor

public ServiceMonitor retrieveServiceMonitor(String aServiceName)

getPlugins

public HashMap getPlugins()

fileLoader

public PluginLoader.Plugin fileLoader(String path)

loadClassFromFile

public Class loadClassFromFile(String aFileName,
                               boolean resolveIt)
                        throws ClassNotFoundException

jarLoader

public PluginLoader.Plugin jarLoader(String aPath)
                              throws IOException
loads any classes from a jar file on the filesystem.
Parameters:
String - path, the path of the jar file to open

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

loadClassFromZip

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