net.sourceforge.cruisecontrol
Class PluginRegistry

java.lang.Object
  extended bynet.sourceforge.cruisecontrol.PluginRegistry
All Implemented Interfaces:
java.io.Serializable

public final class PluginRegistry
extends java.lang.Object
implements java.io.Serializable

Handles "registering" plugins that will be used by the CruiseControl configuration file. A PluginRegistry can have a parent registry, which it will query for a plugin if it's not defined in the registry itself. This is used to enable projects to have their own plugins and override the classname for a specific plugin, like the labelincrementer. The root-registry contains the default list of plugins, i.e. those that are already registered like AntBuilder that don't have to be registered separately in the configuration file. The registry keeps track of the plugin configurations in order to allow full plugin preconfigurations (default properties + nested elements).

See Also:
PluginXMLHelper, Serialized Form

Method Summary
static PluginRegistry createRegistry()
           
static PluginRegistry createRegistry(PluginRegistry parent)
           
 java.lang.Class getPluginClass(java.lang.String pluginName)
           
 java.lang.String getPluginClassname(java.lang.String pluginName)
           
 org.jdom.Element getPluginConfig(java.lang.String pluginName)
          Get the plugin configuration particular to this plugin, merged with the parents
 PluginDetail[] getPluginDetails()
           
 java.lang.String getPluginName(java.lang.Class pluginClass)
           
 PluginType[] getPluginTypes()
           
 java.lang.Class instanciatePluginClass(java.lang.String pluginClassname, java.lang.String pluginName)
           
 boolean isPluginRegistered(java.lang.String pluginName)
           
 void register(org.jdom.Element pluginElement)
          Registers the given plugin, including plugin configuration.
 void register(java.lang.String pluginName, java.lang.String pluginClassname)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createRegistry

public static PluginRegistry createRegistry()
Returns:
PluginRegistry with the ROOTREGISTRY as its parent.

createRegistry

public static PluginRegistry createRegistry(PluginRegistry parent)
Returns:
PluginRegistry with the specified registry as its parent.

register

public void register(java.lang.String pluginName,
                     java.lang.String pluginClassname)
Parameters:
pluginName - The name for the plugin, e.g. ant. Note that plugin names are always treated as case insensitive, so Ant, ant, and AnT are all treated as the same plugin.
pluginClassname - The fully qualified classname for the plugin class, e.g. net.sourceforge.cruisecontrol.builders.AntBuilder.

register

public void register(org.jdom.Element pluginElement)
              throws CruiseControlException
Registers the given plugin, including plugin configuration.

Parameters:
pluginElement - the JDom element that contains the plugin definition.
Throws:
CruiseControlException

getPluginClassname

public java.lang.String getPluginClassname(java.lang.String pluginName)
Returns:
Returns null if no plugin has been registered with the specified name, otherwise a String representing the fully qualified classname for the plugin class. Note that plugin names are always treated as case insensitive, so Ant, ant, and AnT are all treated as the same plugin. Note: a parent name->class mapping can be overridden by children registries.

getPluginClass

public java.lang.Class getPluginClass(java.lang.String pluginName)
                               throws CruiseControlException
Returns:
Returns null if no plugin has been registered with the specified name, otherwise the Class representing the plugin class. Note that plugin names are always treated as case insensitive, so Ant, ant, and AnT are all treated as the same plugin.
Throws:
CruiseControlException - If the class provided cannot be loaded.

instanciatePluginClass

public java.lang.Class instanciatePluginClass(java.lang.String pluginClassname,
                                              java.lang.String pluginName)
                                       throws CruiseControlException
Parameters:
pluginClassname -
pluginName -
Returns:
instantiate the Class representing the plugin class name.
Throws:
CruiseControlException - If the class provided cannot be loaded.

getPluginName

public java.lang.String getPluginName(java.lang.Class pluginClass)

getPluginDetails

public PluginDetail[] getPluginDetails()
                                throws CruiseControlException
Throws:
CruiseControlException

getPluginTypes

public PluginType[] getPluginTypes()

isPluginRegistered

public boolean isPluginRegistered(java.lang.String pluginName)
Returns:
True if this registry or its parent contains an entry for the plugin specified by the name. The name is the short name for the plugin, not the classname, e.g. ant. Note that plugin names are always treated as case insensitive, so Ant, ant, and AnT are all treated as the same plugin.
Throws:
java.lang.NullPointerException - If a null pluginName is passed, then a NullPointerException will occur. It's recommended to not pass a null pluginName.

getPluginConfig

public org.jdom.Element getPluginConfig(java.lang.String pluginName)
Get the plugin configuration particular to this plugin, merged with the parents

Throws:
java.lang.NullPointerException - if pluginName is null