com.atlassian.plugin.loaders
Class ScanningPluginLoader

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

public class ScanningPluginLoader
extends java.lang.Object
implements DynamicPluginLoader

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 Summary
protected  PluginArtifactFactory pluginArtifactFactory
           
protected  java.util.List<PluginFactory> pluginFactories
           
protected  java.util.Map<DeploymentUnit,Plugin> plugins
           
protected  Scanner scanner
           
 
Constructor Summary
ScanningPluginLoader(Scanner scanner, java.util.List<PluginFactory> pluginFactories, PluginArtifactFactory pluginArtifactFactory, PluginEventManager pluginEventManager)
          Construct a new scanning plugin loader with no default values
ScanningPluginLoader(Scanner scanner, java.util.List<PluginFactory> pluginFactories, PluginEventManager pluginEventManager)
          Constructor that provides a default plugin artifact factory `
 
Method Summary
 java.lang.String canLoad(PluginArtifact pluginArtifact)
          Determines if the artifact can be loaded by any of its deployers
protected  Plugin deployPluginFromUnit(DeploymentUnit deploymentUnit, ModuleDescriptorFactory moduleDescriptorFactory)
           
 boolean isDynamicPluginLoader()
           
 java.lang.Iterable<Plugin> loadAllPlugins(ModuleDescriptorFactory moduleDescriptorFactory)
          Loads all plugins that can be installed in the plugin system.
 java.lang.Iterable<Plugin> loadFoundPlugins(ModuleDescriptorFactory moduleDescriptorFactory)
          Load all newly found plugins that can be installed in the plugin system.
 void onShutdown(PluginFrameworkShutdownEvent event)
          Called during plugin framework shutdown
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.
 void removePlugin(Plugin plugin)
          Remove a specific plugin
 void shutDown()
          Deprecated. Since 2.0.0, shutdown will automatically occur when the plugin framework is shutdown
 boolean supportsAddition()
           
 boolean supportsRemoval()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scanner

protected final Scanner scanner

plugins

protected final java.util.Map<DeploymentUnit,Plugin> plugins

pluginFactories

protected final java.util.List<PluginFactory> pluginFactories

pluginArtifactFactory

protected final PluginArtifactFactory pluginArtifactFactory
Constructor Detail

ScanningPluginLoader

public ScanningPluginLoader(Scanner scanner,
                            java.util.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,
                            java.util.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 Detail

loadAllPlugins

public java.lang.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 java.lang.Iterable<Plugin> loadFoundPlugins(ModuleDescriptorFactory moduleDescriptorFactory)
                                            throws PluginParseException
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.
Throws:
PluginParseException - if any error occurred loading plugins

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)
                  throws PluginException
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

shutDown

@Deprecated
public void shutDown()
Deprecated. Since 2.0.0, shutdown will automatically occur when the plugin framework is shutdown


isDynamicPluginLoader

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

canLoad

public java.lang.String canLoad(PluginArtifact pluginArtifact)
                         throws PluginParseException
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

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


Copyright © 2013 Atlassian. All Rights Reserved.