unbbayes.util.extension.manager
Class UnBBayesPluginContextHolder

java.lang.Object
  extended by unbbayes.util.extension.manager.UnBBayesPluginContextHolder

public class UnBBayesPluginContextHolder
extends Object

This is a class that holds a virtually static (singleton) instance of plugin manager used by UnBBayes core. This class can be used to access plugin utility.

Author:
Shou Matsumoto

Nested Class Summary
static interface UnBBayesPluginContextHolder.OnReloadActionListener
          An interface to represent a listener, containing UnBBayesPluginContextHolder.OnReloadActionListener.onReload(EventObject) which shall be called on every plugin reload events (e.g.
 
Constructor Summary
protected UnBBayesPluginContextHolder()
          Default constructor is protected in order to help subclasses.
 
Method Summary
 void addListener(UnBBayesPluginContextHolder.OnReloadActionListener listener)
          Adds a new UnBBayesPluginContextHolder.OnReloadActionListener into this plugin holder.
 Map<String,Set<String>> getErroneousPluginIDDependencyMap()
          This method obtains a map containing an erroneous plugin ID as a key, mapped to a set of plugin ID's of the dependencies causing its erroneous state.
 Map<String,Set<String>> getErroneousPluginIDDependencyMap(String extensionPointPluginID)
          This method obtains a map containing an erroneous plugin ID as a key, mapped to a set of plugin ID's of the dependencies causing its erroneous state.
 Collection<String> getErroneousRequisiteID(org.java.plugin.registry.PluginDescriptor descr)
          This method checks if a given plugin descriptor is a valid plugin.
 List<UnBBayesPluginContextHolder.OnReloadActionListener> getOnReloadListeners()
           
 String getPluginCoreID()
          The ID of the core plugin.
 org.java.plugin.PluginManager getPluginManager()
          Return a singleton instance of plugin manager used by UnBBayes
 String getPluginsDirectoryName()
           
 boolean isInitialized()
          Tells us if the plugin infrastructure is already initialized (published).
static UnBBayesPluginContextHolder newInstance()
          Obtains a singleton instance of UnBBayesPluginContextHolder
 void notifyReload(Object origin)
          Triggers every listeners at getOnReloadListeners().
 void publishPlugins()
          Loads plugins situated at getPluginsDirectoryName() folder and publish them (make them usable).
 void setOnReloadListeners(List<UnBBayesPluginContextHolder.OnReloadActionListener> onReloadListeners)
           
 void setPluginCoreID(String newPluginCoreID)
          The ID of the core plugin.
protected  void setPluginManager(org.java.plugin.PluginManager pluginManager)
           
 void setPluginsDirectoryName(String pluginsDirectoryName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnBBayesPluginContextHolder

protected UnBBayesPluginContextHolder()
Default constructor is protected in order to help subclasses. This constructor initializes the values of some attributes, such as pluginsDirectoryName, plugin manager or pluginCoreID

Method Detail

newInstance

public static UnBBayesPluginContextHolder newInstance()
Obtains a singleton instance of UnBBayesPluginContextHolder

Returns:

getPluginManager

public org.java.plugin.PluginManager getPluginManager()
Return a singleton instance of plugin manager used by UnBBayes

Returns:
a singleton instance of plugin manager.

publishPlugins

public void publishPlugins()
                    throws IOException
Loads plugins situated at getPluginsDirectoryName() folder and publish them (make them usable).

Throws:
IOException

getPluginsDirectoryName

public String getPluginsDirectoryName()
Returns:
the pluginsDirectoryName

setPluginsDirectoryName

public void setPluginsDirectoryName(String pluginsDirectoryName)
Parameters:
pluginsDirectoryName - the pluginsDirectoryName to set

getPluginCoreID

public String getPluginCoreID()
The ID of the core plugin.

Returns:
the pluginCoreID

setPluginCoreID

public void setPluginCoreID(String newPluginCoreID)
The ID of the core plugin.

Parameters:
pluginCoreID - the pluginCoreID to set

isInitialized

public boolean isInitialized()
Tells us if the plugin infrastructure is already initialized (published). publishPlugins() initializes the plugins.

Returns:
true if the plugins were published. False otherwise.

notifyReload

public void notifyReload(Object origin)
Triggers every listeners at getOnReloadListeners().

Parameters:
origin - : object that originated the notify event.

addListener

public void addListener(UnBBayesPluginContextHolder.OnReloadActionListener listener)
Adds a new UnBBayesPluginContextHolder.OnReloadActionListener into this plugin holder. These listeners will be trigged by notifyReload(Object)

Parameters:
listener -
See Also:
notifyReload(Object)

getOnReloadListeners

public List<UnBBayesPluginContextHolder.OnReloadActionListener> getOnReloadListeners()
Returns:
the onReloadListeners

setOnReloadListeners

public void setOnReloadListeners(List<UnBBayesPluginContextHolder.OnReloadActionListener> onReloadListeners)
Parameters:
onReloadListeners - the onReloadListeners to set

setPluginManager

protected void setPluginManager(org.java.plugin.PluginManager pluginManager)
Parameters:
pluginManager - the pluginManager to set

getErroneousRequisiteID

public Collection<String> getErroneousRequisiteID(org.java.plugin.registry.PluginDescriptor descr)
This method checks if a given plugin descriptor is a valid plugin. If not valid, it returns a collection containing all plugin IDs that caused the descr to fail.

Parameters:
descr - : descriptor of the plugin to perform sanity check.
Returns:
non null collection. This is a collection containing all plugin IDs that caused the descr to fail.

getErroneousPluginIDDependencyMap

public Map<String,Set<String>> getErroneousPluginIDDependencyMap()
                                                          throws IOException
This method obtains a map containing an erroneous plugin ID as a key, mapped to a set of plugin ID's of the dependencies causing its erroneous state. You may use getPluginManager()'s methods to extract the plugin descriptor from these IDs.

Returns:
: non-null map from plugin ID to all its erroneous dependencies (also, plugin IDs)
Throws:
IOException - : when a I/O access or plugin publish cannot be done.

getErroneousPluginIDDependencyMap

public Map<String,Set<String>> getErroneousPluginIDDependencyMap(String extensionPointPluginID)
                                                          throws IOException
This method obtains a map containing an erroneous plugin ID as a key, mapped to a set of plugin ID's of the dependencies causing its erroneous state. You may use getPluginManager()'s methods to extract the plugin descriptor from these IDs.

Parameters:
extensionPointPluginID - : this is the plugin ID from where this method will look for connected extension points. If null, the getPluginCoreID() will be used. All extension points connected to this extensionPointPluginID will be checked
Returns:
: non-null map from plugin ID to all its erroneous dependencies (also, plugin IDs)
Throws:
IOException - : when a I/O access or plugin publish cannot be done.


Copyright © 2001-2010 University of Brasilia - UnB. All Rights Reserved.