Class PluginToolkit

java.lang.Object
org.jorigin.plugin.PluginToolkit

public class PluginToolkit extends Object
This class is a toolkit used for helping plugin management. Using this class, user can scan and load a list of plugins related to a given package (setPluginPackage(String)) from given locations on the system (addPluginDir(String), addPluginDir(File)). The plugin loading is launched via the loadPlugins() method.
Since:
1.0.0
Version:
"1.0.14" - b202111241200L
Author:
Julien SEINTURIER - Université de Toulon / CNRS LIS umr 7020 - github.com/jorigin/jcommon (contact@jorigin.org)
  • Field Details

    • idListenerList

      protected EventListenerList idListenerList
      The attached listeners.
  • Constructor Details

    • PluginToolkit

      public PluginToolkit()
      Constuct a new default plugin toolkit.
  • Method Details

    • addPluginDir

      public boolean addPluginDir(String pluginDir)
      Add a new path in the plugin search path.
      Parameters:
      pluginDir - the path to insert in the plugin search list.
      Returns:
      boolean true if the plugin search dir is added, false otherwise.
    • addPluginDir

      public boolean addPluginDir(File pluginDir)
      Add a new path in the plugin search path.
      Parameters:
      pluginDir - the path to insert in the plugin search list.
      Returns:
      boolean true if the plugin search dir is added, false otherwise.
    • removePluginDir

      public boolean removePluginDir(String pluginDir)
      Remove the given path from the plugin search path list.
      Parameters:
      pluginDir - the plugin directory to remove.
      Returns:
      true if the directory is succesfully removed, false otherwise.
    • removePluginDir

      public boolean removePluginDir(File pluginDir)
      Remove the given path from the plugin search path list.
      Parameters:
      pluginDir - the plugin directory to remove.
      Returns:
      true if the directory is succesfully removed, false otherwise.
    • setPluginPackage

      public void setPluginPackage(String pluginPackage)
      Set the core package of the plugins.
      Parameters:
      pluginPackage - the core package of the plugins
    • addPluginToolkitListener

      public void addPluginToolkitListener(PluginToolkitListener l)
      Add a Plugin Toolkit Listener to this plugin toolkit
      Parameters:
      l - the listener to add to the toolkit
      See Also:
    • removePluginToolkitListener

      public void removePluginToolkitListener(PluginToolkitListener l)
      Remove a Plugin Toolkit Listener from this plugin toolkit
      Parameters:
      l - the listener to remove
      See Also:
    • fireEvent

      protected void fireEvent(PluginToolkitEvent e)
      Fire a new plugin toolkit event to all registered listeners
      Parameters:
      e - the event to fire.
      See Also:
    • loadPlugins

      public ArrayList<IPlugin> loadPlugins()
      Load all plugins available in the locations given to the toolkit. This method scan the available locations and looks for plugins with given package name. When available plugins are detected, the method instanciate them and store the instanciated plugins in the returned list.
      Returns:
      ArrayList<IPlugin> the plugins availables and instanciated.
      See Also: