net.groboclown.util.jplugin.v2
Class PluginLoader

java.lang.Object
  |
  +--net.groboclown.util.jplugin.v2.PluginLoader

public class PluginLoader
extends Object

Entry-point for loading plugins. After all the plugins have been loaded, you should call PluginLoader.cleanup() to clean up any static cached data.


Field Summary
private  URLAnalyzer analyzer
           
private  ClassWrapper[] cachedWrappers
           
private  ClassCollection cc
           
private  int state
           
private static int STATE_INITIALIZING
           
private static int STATE_PLUGINS_LOADED
           
private  Vector urls
           
 
Constructor Summary
PluginLoader()
          Default constructor
PluginLoader(URL baseURL)
           
PluginLoader(URL[] baseURLs)
           
PluginLoader(URL[] baseURLs, boolean recurse)
           
PluginLoader(URL baseURL, boolean recurse)
           
 
Method Summary
(package private)  void ()
           
 void addFileInspector(IFileInspector ifi)
           
 void addLocationSearcher(ILocationSearcher ils)
           
 void addURL(String aURL)
           
 void addURL(String[] list)
          Add a list of URL strings which do not recurse through directories to find files.
 void addURL(String[] list, boolean recurse)
           
 void addURL(String aURL, boolean recurse)
           
 void addURL(URL aURL)
           
 void addURL(URL[] list)
           
 void addURL(URL[] list, boolean recurse)
           
 void addURL(URL aURL, boolean recurse)
           
static void cleanup()
          Static method to help clean up all the static cache information.
protected  ClassWrapper[] findClassWrappers()
          Find or cache the class wrappers.
 void findPlugins()
          Begins the search for plugin classes.
 ClassWrapper[] getPlugins(Class baseclass)
          Find all the plugins that inherit from the given class.
 ClassWrapper[] getPlugins(String attribute)
          Find all the plugins that have the given attribute.
 ClassWrapper[] getPlugins(String attribute, String val)
          Find all the plugins that have the given attribute pair, with case insensitivity.
 ClassWrapper[] getPlugins(String attribute, String val, boolean isCaseSensitive)
          Find all the plugins that have the given attribute pair.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

STATE_INITIALIZING

private static final int STATE_INITIALIZING

STATE_PLUGINS_LOADED

private static final int STATE_PLUGINS_LOADED

urls

private Vector urls

cc

private ClassCollection cc

analyzer

private URLAnalyzer analyzer

state

private int state

cachedWrappers

private ClassWrapper[] cachedWrappers
Constructor Detail

PluginLoader

public PluginLoader()
Default constructor

PluginLoader

public PluginLoader(URL baseURL)

PluginLoader

public PluginLoader(URL[] baseURLs)

PluginLoader

public PluginLoader(URL baseURL,
                    boolean recurse)

PluginLoader

public PluginLoader(URL[] baseURLs,
                    boolean recurse)
Method Detail

void ()
Overrides:
in class Object

addURL

public void addURL(URL aURL)

addURL

public void addURL(URL aURL,
                   boolean recurse)

addURL

public void addURL(URL[] list)

addURL

public void addURL(URL[] list,
                   boolean recurse)

addURL

public void addURL(String aURL)
            throws IllegalArgumentException

addURL

public void addURL(String aURL,
                   boolean recurse)
            throws IllegalArgumentException

addURL

public void addURL(String[] list)
            throws IllegalArgumentException
Add a list of URL strings which do not recurse through directories to find files.

addURL

public void addURL(String[] list,
                   boolean recurse)
            throws IllegalArgumentException

addLocationSearcher

public void addLocationSearcher(ILocationSearcher ils)

addFileInspector

public void addFileInspector(IFileInspector ifi)

findPlugins

public void findPlugins()
Begins the search for plugin classes.

getPlugins

public ClassWrapper[] getPlugins(Class baseclass)
Find all the plugins that inherit from the given class.

getPlugins

public ClassWrapper[] getPlugins(String attribute)
Find all the plugins that have the given attribute.

getPlugins

public ClassWrapper[] getPlugins(String attribute,
                                 String val)
Find all the plugins that have the given attribute pair, with case insensitivity.

getPlugins

public ClassWrapper[] getPlugins(String attribute,
                                 String val,
                                 boolean isCaseSensitive)
Find all the plugins that have the given attribute pair.
Parameters:
isCaseSensitive - true if the values must match exactly, or false if they can have different cases.

cleanup

public static void cleanup()
Static method to help clean up all the static cache information. Should be called after all references to the PluginLoaders are nulled/removed.

findClassWrappers

protected ClassWrapper[] findClassWrappers()
Find or cache the class wrappers. Must have the plugins already loaded.


Written under the LGPL