Class ScanningPluginLoader

java.lang.Object
com.atlassian.plugin.loaders.ScanningPluginLoader
All Implemented Interfaces:
DiscardablePluginLoader, DynamicPluginLoader, PluginLoader
Direct Known Subclasses:
BundledPluginLoader, DirectoryPluginLoader, RosterFilePluginLoader

public class ScanningPluginLoader extends Object implements DynamicPluginLoader, DiscardablePluginLoader
Plugin loader that delegates the detection of plugins to a Scanner instance. The scanner may monitor the contents of a directory on disk, a database, or any other place plugins may be hidden.
Since:
2.1.0
  • Field Details

  • Constructor Details

    • ScanningPluginLoader

      public ScanningPluginLoader(Scanner scanner, List<PluginFactory> pluginFactories, PluginEventManager pluginEventManager)
      Constructor that provides a default plugin artifact factory `
      Parameters:
      scanner - The scanner to use to detect new plugins
      pluginFactories - The deployers that will handle turning an artifact into a plugin
      pluginEventManager - The event manager, used for listening for shutdown events
      Since:
      2.0.0
    • ScanningPluginLoader

      public ScanningPluginLoader(Scanner scanner, List<PluginFactory> pluginFactories, PluginArtifactFactory pluginArtifactFactory, PluginEventManager pluginEventManager)
      Construct a new scanning plugin loader with no default values
      Parameters:
      scanner - The scanner to use to detect new plugins
      pluginFactories - The deployers that will handle turning an artifact into a plugin
      pluginArtifactFactory - used to create new plugin artifacts from an URL
      pluginEventManager - The event manager, used for listening for shutdown events
      Since:
      2.0.0
  • Method Details

    • loadAllPlugins

      public Iterable<Plugin> loadAllPlugins(ModuleDescriptorFactory moduleDescriptorFactory)
      Description copied from interface: PluginLoader
      Loads all plugins that can be installed in the plugin system.
      Specified by:
      loadAllPlugins in interface PluginLoader
      Parameters:
      moduleDescriptorFactory - the factory for module descriptors
      Returns:
      the list of found plugins, may be empty
    • loadFoundPlugins

      public Iterable<Plugin> loadFoundPlugins(ModuleDescriptorFactory moduleDescriptorFactory)
      Description copied from interface: PluginLoader
      Load all newly found plugins that can be installed in the plugin system. Only plugins not previously loaded will be added.
      Specified by:
      loadFoundPlugins in interface PluginLoader
      Parameters:
      moduleDescriptorFactory - the factory for module descriptors
      Returns:
      all plugins, now loaded by the pluginLoader, which have been discovered and added since the last time a check was performed.
    • supportsRemoval

      public boolean supportsRemoval()
      Specified by:
      supportsRemoval in interface PluginLoader
      Returns:
      true if this PluginLoader tracks whether or not plugins are removed from it.
    • supportsAddition

      public boolean supportsAddition()
      Specified by:
      supportsAddition in interface PluginLoader
      Returns:
      true if this PluginLoader tracks whether or not plugins are added to it.
    • deployPluginFromUnit

      protected final Plugin deployPluginFromUnit(DeploymentUnit deploymentUnit, ModuleDescriptorFactory moduleDescriptorFactory)
    • removePlugin

      public void removePlugin(Plugin plugin)
      Description copied from interface: PluginLoader
      Remove a specific plugin
      Specified by:
      removePlugin in interface PluginLoader
      Parameters:
      plugin - - the plugin to remove
      Throws:
      PluginException - representing the reason for failure.
    • onShutdown

      public void onShutdown(PluginFrameworkShutdownEvent event)
      Called during plugin framework shutdown
      Parameters:
      event - The shutdown event
    • isDynamicPluginLoader

      public boolean isDynamicPluginLoader()
      Specified by:
      isDynamicPluginLoader in interface PluginLoader
      Returns:
      true if this plugin loader can load plugins dynamically
    • canLoad

      public String canLoad(PluginArtifact pluginArtifact)
      Determines if the artifact can be loaded by any of its deployers
      Specified by:
      canLoad in interface DynamicPluginLoader
      Parameters:
      pluginArtifact - The artifact to test
      Returns:
      True if this artifact can be loaded by this loader
      Throws:
      PluginParseException
    • discardPlugin

      public void discardPlugin(Plugin plugin)
      Description copied from interface: DiscardablePluginLoader
      Notify the PluginLoader that the system will not be loading the given plugin. This instructs the PluginLoader to discard any resources associated with the Plugin.
      Specified by:
      discardPlugin in interface DiscardablePluginLoader
    • postProcess

      protected Plugin postProcess(Plugin plugin)
      Template method that can be used by a specific PluginLoader to add information to a Plugin after it has been loaded.
      Parameters:
      plugin - a plugin that has been loaded
      Since:
      v2.2.0
    • createModule

      public ModuleDescriptor<?> createModule(Plugin plugin, Element module, ModuleDescriptorFactory moduleDescriptorFactory)
      Description copied from interface: PluginLoader
      If this loader is capable of loading a plugin of the type passed, attempt to create a module descriptor. Add that module descriptor to the plugin.

      If capable, always return a ModuleDescriptor, even if it indicates a failure case. Caller is responsible for handling exceptional ModuleDescriptor.

      Specified by:
      createModule in interface PluginLoader
      Parameters:
      plugin - that the module will be added to
      module - to create
      moduleDescriptorFactory - basic factory, may be overridden
      Returns:
      null if incapable of creating