org.pf.plugin
Class PluginCollector

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

public class PluginCollector
extends java.lang.Object

The responsibility of this class is to detect all properties files with a specific name on a given classpath and load the defined classes that fit to a given class/interface into a class regitry.

Since version 1.3 it is possible to specify a system property named "org.pf.plugin.path" to define the path on which the plugin collector must search for plug-ins.

Since version 1.4 it is also possible to load all plugin definitions from a single file that is looked-up via the standard classloader mechanism getResourceStream().

Version:
1.4
Author:
Manfred Duchrow

Field Summary
static boolean DEBUG
           
 
Constructor Summary
PluginCollector()
          Initialize the new instance with default values.
PluginCollector(ClassRegistry registry)
          Initialize the new instance with a class registry.
 
Method Summary
 ClassRegistry getClassRegistry()
          Returns the class registry that contains all loaded plugins
 ClassRegistry loadPlugins(java.lang.String filename)
          Load the class definitions from all files with the given name that can be found in the system classpath.
 ClassRegistry loadPlugins(java.lang.String filename, Classpath classpath)
          Load the class definitions from all files with the given name that can be found in the specified classpath.
 ClassRegistry loadPlugins(java.lang.String filename, java.lang.String classpath)
          Load the class definitions from all files with the given name that can be found in the specified classpath.
 ClassRegistry loadPluginsViaClassLoader(java.lang.String filename)
          Load the class definitions from the file with the given name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static boolean DEBUG
Constructor Detail

PluginCollector

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


PluginCollector

public PluginCollector(ClassRegistry registry)
Initialize the new instance with a class registry.

Method Detail

getClassRegistry

public ClassRegistry getClassRegistry()
Returns the class registry that contains all loaded plugins


loadPluginsViaClassLoader

public ClassRegistry loadPluginsViaClassLoader(java.lang.String filename)
Load the class definitions from the file with the given name. The file will be searched for utilizing the classloader of this class.

Parameters:
filename - The name of the properties file that contains the class definitions
Returns:
The class registry that contains the new definitions if the file has been found.

loadPlugins

public ClassRegistry loadPlugins(java.lang.String filename)
Load the class definitions from all files with the given name that can be found in the system classpath.

Parameters:
filename - The name of the properties file that contains the class definitions
Returns:
The class registry that contains the new definitions from all the files that have been found.

loadPlugins

public ClassRegistry loadPlugins(java.lang.String filename,
                                 java.lang.String classpath)
Load the class definitions from all files with the given name that can be found in the specified classpath.

Parameters:
filename - The name of the properties file that contains the class definitions
classpath - The classpath the specified filename to be looked up in

loadPlugins

public ClassRegistry loadPlugins(java.lang.String filename,
                                 Classpath classpath)
Load the class definitions from all files with the given name that can be found in the specified classpath.

Parameters:
filename - The name of the properties file that contains the class definitions
classpath - The classpath on which to lookup the the specified filename