com.valhalla.pluginmanager
Class PluginLoader

java.lang.Object
  extended byjava.lang.ClassLoader
      extended bycom.valhalla.pluginmanager.PluginLoader

public class PluginLoader
extends java.lang.ClassLoader

This class supports the loading of custom plugins from jar files. The main class in the Jar should be named after the jar filename and should be in the "package" String passed to the PluginLoader package. For example, the plugin LookAndFeel would be in a jar file called LookAndFeel.jar, and if the package parameter was com.valhalla.jbother.plugins there would need to be a class called com.valhalla.jbother.plugins.LookAndFeelin the jar file

Version:
1.0
Author:
Adam Olsen

Nested Class Summary
 
Nested classes inherited from class java.lang.ClassLoader
 
Field Summary
 
Fields inherited from class java.lang.ClassLoader
 
Method Summary
 void findPlugins(java.lang.String d)
          Reads in all the available plugins and the information about them
static int getAPIVersion()
          Gets the current plugin API version
 java.util.ArrayList getAvailablePlugins()
           
 java.util.ArrayList getInstalledPlugins()
           
static PluginLoader getInstance()
          Gets the singleton of this class
 java.util.ArrayList getInvalidPlugins()
           
protected  java.util.Hashtable getLoadedClasses()
           
 java.util.Hashtable getLoadedPlugins()
           
static PluginLoader getNewInstance()
           
 PluginJAR getPlugin(java.lang.String name)
          Returns the jar file for the specified plugin name
 java.io.InputStream getResourceAsStream(java.lang.String resource)
          Gets a resource as a stream
 java.lang.Class loadClass(java.lang.String className, boolean resolveIt)
          Loads the Class out of the plugin file
 void loadPlugins()
          Attempts to load the available plugins
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static PluginLoader getInstance()
Gets the singleton of this class

Returns:
the PluginLoader singleton

getNewInstance

public static PluginLoader getNewInstance()

getLoadedPlugins

public java.util.Hashtable getLoadedPlugins()
Returns:
a list of currently loaded plugins

getAvailablePlugins

public java.util.ArrayList getAvailablePlugins()
Returns:
a list of available plugins

getInstalledPlugins

public java.util.ArrayList getInstalledPlugins()
Returns:
a list of installed plugins

getInvalidPlugins

public java.util.ArrayList getInvalidPlugins()
Returns:
a list of invalid plugins

getPlugin

public PluginJAR getPlugin(java.lang.String name)
Returns the jar file for the specified plugin name

Parameters:
name - the plugin name
Returns:
the jar file corresponding to the name

getAPIVersion

public static int getAPIVersion()
Gets the current plugin API version

Returns:
the current plugin API version

loadPlugins

public void loadPlugins()
Attempts to load the available plugins


findPlugins

public void findPlugins(java.lang.String d)
Reads in all the available plugins and the information about them


getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String resource)
Gets a resource as a stream

Parameters:
resource - the resource to get
Returns:
the stream

getLoadedClasses

protected java.util.Hashtable getLoadedClasses()

loadClass

public java.lang.Class loadClass(java.lang.String className,
                                 boolean resolveIt)
                          throws java.lang.ClassNotFoundException
Loads the Class out of the plugin file

Parameters:
className - the class name to load
resolveIt - true to resolve the class (load dependancies)
Returns:
the Class if it was found
Throws:
ClassNotFoundException - if the class could not be found in the system or any of the plugin files
java.lang.ClassNotFoundException