org.schmant.plugin
Class PluginRegistry

java.lang.Object
  extended by org.schmant.plugin.PluginRegistry

public class PluginRegistry
extends Object

This is a global registry for Schmant plugins. The TaskPackage registers its Plugin objects with this registry when it is enabled. For instance, plugins are used by the EclipseWorkspace to interpret different project types.

Plugins are registered under names that are set by the plugin consumer. See the different plugin consumer's documentation. Several plugins may be registered under the same name.

Plugin objects are immutable.

Since:
0.8
Author:
Karl Gustafsson
See Also:
Plugin, TaskPackageManager

Constructor Summary
PluginRegistry()
           
 
Method Summary
static PluginRegistry get()
          Get the plugin registry.
 List<Plugin> getPlugins(String name)
          Get all plugins registered under the given name.
static PluginRegistry init()
          This is called by Launcher to setup the plugin registry.
 void registerPlugin(String name, Plugin p)
          Register a plugin.
static void tearDown(PluginRegistry previousReg)
          This is called by Launcher to tear down the plugin registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PluginRegistry

public PluginRegistry()
Method Detail

init

public static PluginRegistry init()
This is called by Launcher to setup the plugin registry.

Returns:
If there already is a plugin registry, it is returned. In that case Launcher will keep it and return it when it calls tearDown(PluginRegistry).
See Also:
tearDown(PluginRegistry)

tearDown

public static void tearDown(PluginRegistry previousReg)
This is called by Launcher to tear down the plugin registry. This prevents Launcher from leaking thread local variables to the code that calls it.

Parameters:
previousReg - If init() returned a plugin registry, it is passed in as this parameter. If not, this is set to null.
See Also:
init()

get

public static PluginRegistry get()
                          throws IllegalStateException
Get the plugin registry.

Returns:
The plugin registry.
Throws:
IllegalStateException - If this class has not yet been initialized by Launcher.

registerPlugin

public void registerPlugin(String name,
                           Plugin p)
Register a plugin.

Parameters:
name - The name of the plugin type.
p - The plugin.

getPlugins

public List<Plugin> getPlugins(String name)
Get all plugins registered under the given name.

Parameters:
name - The name of the plugin type.
Returns:
A list with registered plugins for the specified name. The list of plugins is sorted with the last inserted plugin first.