org.processmining.framework.plugin
Class PluginCollection

java.lang.Object
  extended by org.processmining.framework.plugin.PluginCollection
Direct Known Subclasses:
AnalysisPluginCollection, ConvertingPluginCollection, ExportPluginCollection, ImportPluginCollection, MiningPluginCollection, RecommendationCollection, ScaleCollection

public abstract class PluginCollection
extends java.lang.Object

Defines a collection of plugins of a certain type.

This class is declared abstract, because subclasses need to specify which type of plugins are accepted by the particular collection (i.e. they should override the abstract isValidPlugin method).

Subclasses should also be implemented using the singleton pattern. This means that there is only a single collection of algorithms during the execution of the program.

In general, a subclass will look as follows:


 public class MyCollection extends PluginCollection {
     private static MyCollection instance = null;

     protected MyCollection() {}

     public static MyCollection getInstance() {
         if (instance == null) {
            instance = new MyCollection();
         }
         return instance;
     }

     public boolean isValidPlugin(Plugin plugin) {
         return plugin instanceof MyPlugin;
     }
 }
 

Version:
1.0
Author:
Peter van den Brand

Constructor Summary
protected PluginCollection()
           
 
Method Summary
protected  void addPlugin(Plugin plugin, java.lang.String sortName, ProMSplash splash)
           
 Plugin get(int index)
          Get a plugin by its index in the collection.
 Plugin get(java.lang.String name)
          Get a plugin by its name.
 Plugin getByKey(java.lang.String key)
          Get a plugin by its name.
 java.util.ArrayList<Plugin> getPlugins()
          Return the whole plugin collection.
abstract  boolean isValidPlugin(Plugin plugin)
          Subclasses should implement this method to check whether this Plugin object is valid for this collection.
 void loadFromIni(java.lang.String filename, ProMSplash splash)
          Load plugins from ini file.
protected  void loadPlugin(java.lang.String name, java.lang.String sortName, ProMSplash splash)
          Loads a single plugin.
 int size()
          Number of plugins in the collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PluginCollection

protected PluginCollection()
Method Detail

isValidPlugin

public abstract boolean isValidPlugin(Plugin plugin)
Subclasses should implement this method to check whether this Plugin object is valid for this collection. For instance, a collection of MiningPlugin's might do something like return plugin instanceof MiningPlugin; Plugins are only loaded when they are valid according to this method (i.e. it returns true).

Parameters:
plugin - the plugin to check whether it is valid
Returns:
true if the plugin may be added to the collection, false otherwise.

loadFromIni

public void loadFromIni(java.lang.String filename,
                        ProMSplash splash)
Load plugins from ini file. Each line in the ini file should be of the form Key=Value Plugins in the plugin collection are sorted based on the Key in the ini file. The Value should be the full class name of the plugin to load.

Parameters:
filename - ini file to load plugins from
splash - splashscreen to write messages to

size

public int size()
Number of plugins in the collection.

Returns:
number of plugins in the collection

get

public Plugin get(int index)
Get a plugin by its index in the collection.

Parameters:
index - the index of the plugin in the list (in the range [0..size() - 1])
Returns:
the plugin

getPlugins

public java.util.ArrayList<Plugin> getPlugins()
Return the whole plugin collection.

Returns:
the plugins

get

public Plugin get(java.lang.String name)
Get a plugin by its name.

Parameters:
name - the name of the plugin to get
Returns:
the plugin if it's found in the collection, null otherwise

getByKey

public Plugin getByKey(java.lang.String key)
Get a plugin by its name.

Parameters:
name - the name of the plugin to get
Returns:
the plugin if it's found in the collection, null otherwise

addPlugin

protected void addPlugin(Plugin plugin,
                         java.lang.String sortName,
                         ProMSplash splash)

loadPlugin

protected void loadPlugin(java.lang.String name,
                          java.lang.String sortName,
                          ProMSplash splash)
Loads a single plugin. Loading errors are printed in the standard error stream.

Parameters:
name - the class name of the plugin to load
sortName - the sort key
splash - the splashscreen to write messages to