org.pf.plugin
Class PluginRegistry

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

public class PluginRegistry
extends java.lang.Object

A special registry that is capable to hold any number of plug-ins of any type.

Version:
1.0
Author:
M.Duchrow

Constructor Summary
PluginRegistry()
          Initialize the new instance with default values.
 
Method Summary
 java.lang.Object getPlugin(java.lang.String pluginId)
          Returns the plug-in with the specified ID or null if no such plug-in can be found in the registry.
 java.lang.Object getPlugin(java.lang.String pluginId, java.lang.Class pluginType)
          Returns the plug-in with the specified ID and the given type or null if no such plug-in can be found in the registry.
 java.lang.String[] getPluginIDsOfType(java.lang.Class pluginType)
          Returns the IDs of all plug-ins that are of the specified type.
 java.lang.Object[] getPluginsOfType(java.lang.Class pluginType)
          Returns all plug-ins that are of the specified type.
 int loadPluginsFrom(java.lang.String filename)
          Load all plug-ins that are defined in any library in the specified file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PluginRegistry

public PluginRegistry()
Initialize the new instance with default values.

Method Detail

loadPluginsFrom

public int loadPluginsFrom(java.lang.String filename)
Load all plug-ins that are defined in any library in the specified file.

Parameters:
filename - The name of the file(s) where the plug-in defeinition is looked up
Returns:
The number of plug-ins that have been loaded to the registry

getPlugin

public java.lang.Object getPlugin(java.lang.String pluginId)
Returns the plug-in with the specified ID or null if no such plug-in can be found in the registry. If more than one plug-in is registered under the same ID the result is the first one found.

Parameters:
pluginId - The identifier of the plug-in (must not be null)
Returns:
An instance of the found plug-in or null

getPlugin

public java.lang.Object getPlugin(java.lang.String pluginId,
                                  java.lang.Class pluginType)
Returns the plug-in with the specified ID and the given type or null if no such plug-in can be found in the registry.

Parameters:
pluginId - The identifier of the plug-in (must not be null)
pluginType - The type of the plug-in (must not be null)
Returns:
An instance of the found plug-in or null

getPluginsOfType

public java.lang.Object[] getPluginsOfType(java.lang.Class pluginType)
Returns all plug-ins that are of the specified type. That also implies plug-ins that are subclasses or implementors of the given type.

Parameters:
pluginType - The type the plug-ins to look for must comply with
Returns:
An array of found plug-in instances (never null)

getPluginIDsOfType

public java.lang.String[] getPluginIDsOfType(java.lang.Class pluginType)
Returns the IDs of all plug-ins that are of the specified type. That also implies plug-ins that are subclasses or implementors of the given type.

Parameters:
pluginType - The type the plug-ins to look for must comply with
Returns:
An array of IDs (never null)