org.merlotxml.merlot.plugin
Class PluginManager

java.lang.Object
  extended byorg.merlotxml.merlot.plugin.PluginManager

public class PluginManager
extends java.lang.Object

Merlot Plugin Manager

Responsible for locating and loading all Merlot plugins, and keeping track of them.

Plugin initialization is a two-stage process. The first stage is loading the plugin configuration. This retrieves information from the plugin.xml file. The second stage is initialization which is when the plugin's resources are initialized and classes can be loaded. These two stages allow for plugins to name dependencies on other plugins, and their classloaders are linked together. However since plugins are read in filesystem order, the dependencies can't be resolved until all configs have been read.

Stage 1 is implemented by the loadPlugins() method. Stage 2 is implemented by the #initPlugins method.

NOTE: Circular plugin dependencies are not checked for, and will cause a fatal error in classloading if they exist.

Author:
Tim McCune, Kelly Campbell

Field Summary
protected static java.lang.String ERR_DUP_PLUGIN
           
protected static java.lang.String ERR_PLUGIN_NOT_RECOGNIZED
           
protected static PluginManager instance
           
static java.lang.String PLUGIN_CONFIG_FILE
           
 
Constructor Summary
protected PluginManager()
           
 
Method Summary
protected  PluginConfig createPluginConfig(java.io.InputStream input, java.io.File source, java.lang.ClassLoader cl)
           
 java.lang.String getCurrentFilePath()
           
static PluginManager getInstance()
           
 PluginConfig getPlugin(java.lang.String name)
           
 java.util.List getPlugins()
           
 void loadPlugins()
           
static void main(java.lang.String[] args)
          Tester
protected  void searchForPlugins(java.io.File dir)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERR_PLUGIN_NOT_RECOGNIZED

protected static final java.lang.String ERR_PLUGIN_NOT_RECOGNIZED
See Also:
Constant Field Values

ERR_DUP_PLUGIN

protected static final java.lang.String ERR_DUP_PLUGIN
See Also:
Constant Field Values

PLUGIN_CONFIG_FILE

public static final java.lang.String PLUGIN_CONFIG_FILE
See Also:
Constant Field Values

instance

protected static PluginManager instance
Constructor Detail

PluginManager

protected PluginManager()
Method Detail

getInstance

public static PluginManager getInstance()

getPlugins

public java.util.List getPlugins()

getPlugin

public PluginConfig getPlugin(java.lang.String name)

getCurrentFilePath

public java.lang.String getCurrentFilePath()

loadPlugins

public void loadPlugins()
                 throws PluginManagerException,
                        java.io.IOException,
                        java.lang.InstantiationException,
                        java.lang.IllegalAccessException,
                        java.lang.ClassNotFoundException,
                        DOMLiaisonImplException,
                        java.net.MalformedURLException,
                        org.xml.sax.SAXException,
                        PluginConfigException
Throws:
PluginManagerException - Thrown if a plugin's config file is in an unrecognized format
java.io.IOException - Thrown if a plugin couldn't be read
java.lang.InstantiationException - Thrown if there was a problem creating an XML parser
java.lang.IllegalAccessException - Thrown if there was a problem creating an XML parser
java.lang.ClassNotFoundException - Thrown if there was a problem creating an XML parser
DOMLiaisonImplException - Thrown if there was a problem creating an XML parser
java.net.MalformedURLException - Thrown if a plugin provided a malformed URL in its config file
org.xml.sax.SAXException - Thrown if the plugin config file contains malformed XML
PluginConfigException - Thrown if there was a plugin-specific error

searchForPlugins

protected void searchForPlugins(java.io.File dir)
                         throws PluginManagerException,
                                java.io.IOException,
                                java.lang.InstantiationException,
                                java.lang.IllegalAccessException,
                                java.lang.ClassNotFoundException,
                                DOMLiaisonImplException,
                                java.net.MalformedURLException,
                                org.xml.sax.SAXException,
                                PluginConfigException
Throws:
PluginManagerException
java.io.IOException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.ClassNotFoundException
DOMLiaisonImplException
java.net.MalformedURLException
org.xml.sax.SAXException
PluginConfigException

createPluginConfig

protected PluginConfig createPluginConfig(java.io.InputStream input,
                                          java.io.File source,
                                          java.lang.ClassLoader cl)
                                   throws PluginManagerException,
                                          java.lang.InstantiationException,
                                          java.lang.IllegalAccessException,
                                          java.lang.ClassNotFoundException,
                                          DOMLiaisonImplException,
                                          java.net.MalformedURLException,
                                          org.xml.sax.SAXException,
                                          PluginConfigException
Throws:
PluginManagerException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.ClassNotFoundException
DOMLiaisonImplException
java.net.MalformedURLException
org.xml.sax.SAXException
PluginConfigException

main

public static void main(java.lang.String[] args)
Tester