com.atlassian.plugin.loaders
Class ScanningPluginLoader

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

public class ScanningPluginLoader
extends 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  List<PluginFactory> pluginFactories
           
protected  Map<DeploymentUnit,Plugin> plugins
           
protected  Scanner scanner
           
 
Constructor Summary
ScanningPluginLoader(Scanner scanner, List<PluginFactory> pluginFactories, PluginArtifactFactory pluginArtifactFactory, PluginEventManager pluginEventManager)
          Construct a new scanning plugin loader with no default values
ScanningPluginLoader(Scanner scanner, List<PluginFactory> pluginFactories, PluginEventManager pluginEventManager)
          Constructor that provides a default plugin artifact factory
 
Method Summary
 Collection<Plugin> addFoundPlugins(ModuleDescriptorFactory moduleDescriptorFactory)
           
 String canLoad(PluginArtifact pluginArtifact)
          Determines if the artifact can be loaded by any of its deployers
protected  Plugin deployPluginFromUnit(DeploymentUnit deploymentUnit, ModuleDescriptorFactory moduleDescriptorFactory)
           
 Collection<Plugin> loadAllPlugins(ModuleDescriptorFactory moduleDescriptorFactory)
           
 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 Map<DeploymentUnit,Plugin> plugins

pluginFactories

protected final List<PluginFactory> pluginFactories

pluginArtifactFactory

protected final PluginArtifactFactory pluginArtifactFactory
Constructor Detail

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 Detail

loadAllPlugins

public Collection<Plugin> loadAllPlugins(ModuleDescriptorFactory moduleDescriptorFactory)
Specified by:
loadAllPlugins in interface PluginLoader

deployPluginFromUnit

protected Plugin deployPluginFromUnit(DeploymentUnit deploymentUnit,
                                      ModuleDescriptorFactory moduleDescriptorFactory)

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.

addFoundPlugins

public Collection<Plugin> addFoundPlugins(ModuleDescriptorFactory moduleDescriptorFactory)
                                   throws PluginParseException
Specified by:
addFoundPlugins in interface PluginLoader
Returns:
all plugins, now loaded by the pluginLoader, which have been discovered and added since the last time a check was performed.
Throws:
PluginParseException

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


canLoad

public 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 © 2010 Atlassian. All Rights Reserved.