Package com.atlassian.plugin.loaders
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 Summary
FieldsModifier and TypeFieldDescriptionprotected final PluginArtifactFactoryprotected final List<PluginFactory>protected final Map<DeploymentUnit,Plugin> protected final Scanner -
Constructor Summary
ConstructorsConstructorDescriptionScanningPluginLoader(Scanner scanner, List<PluginFactory> pluginFactories, PluginEventManager pluginEventManager) Constructor that provides a default plugin artifact factory `ScanningPluginLoader(Scanner scanner, List<PluginFactory> pluginFactories, PluginArtifactFactory pluginArtifactFactory, PluginEventManager pluginEventManager) Construct a new scanning plugin loader with no default values -
Method Summary
Modifier and TypeMethodDescriptioncanLoad(PluginArtifact pluginArtifact) Determines if the artifact can be loaded by any of its deployerscreateModule(Plugin plugin, Element module, ModuleDescriptorFactory moduleDescriptorFactory) If this loader is capable of loading a plugin of the type passed, attempt to create a module descriptor.protected final PlugindeployPluginFromUnit(DeploymentUnit deploymentUnit, ModuleDescriptorFactory moduleDescriptorFactory) voiddiscardPlugin(Plugin plugin) Notify the PluginLoader that the system will not be loading the given plugin.booleanloadAllPlugins(ModuleDescriptorFactory moduleDescriptorFactory) Loads all plugins that can be installed in the plugin system.loadFoundPlugins(ModuleDescriptorFactory moduleDescriptorFactory) Load all newly found plugins that can be installed in the plugin system.voidCalled during plugin framework shutdownprotected PluginpostProcess(Plugin plugin) Template method that can be used by a specificPluginLoaderto add information to aPluginafter it has been loaded.voidremovePlugin(Plugin plugin) Remove a specific pluginbooleanboolean
-
Field Details
-
scanner
-
plugins
-
pluginFactories
-
pluginArtifactFactory
-
-
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 pluginspluginFactories- The deployers that will handle turning an artifact into a pluginpluginEventManager- 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 pluginspluginFactories- The deployers that will handle turning an artifact into a pluginpluginArtifactFactory- used to create new plugin artifacts from an URLpluginEventManager- The event manager, used for listening for shutdown events- Since:
- 2.0.0
-
-
Method Details
-
loadAllPlugins
Description copied from interface:PluginLoaderLoads all plugins that can be installed in the plugin system.- Specified by:
loadAllPluginsin interfacePluginLoader- Parameters:
moduleDescriptorFactory- the factory for module descriptors- Returns:
- the list of found plugins, may be empty
-
loadFoundPlugins
Description copied from interface:PluginLoaderLoad all newly found plugins that can be installed in the plugin system. Only plugins not previously loaded will be added.- Specified by:
loadFoundPluginsin interfacePluginLoader- 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:
supportsRemovalin interfacePluginLoader- Returns:
- true if this PluginLoader tracks whether or not plugins are removed from it.
-
supportsAddition
public boolean supportsAddition()- Specified by:
supportsAdditionin interfacePluginLoader- Returns:
- true if this PluginLoader tracks whether or not plugins are added to it.
-
deployPluginFromUnit
protected final Plugin deployPluginFromUnit(DeploymentUnit deploymentUnit, ModuleDescriptorFactory moduleDescriptorFactory) -
removePlugin
Description copied from interface:PluginLoaderRemove a specific plugin- Specified by:
removePluginin interfacePluginLoader- Parameters:
plugin- - the plugin to remove- Throws:
PluginException- representing the reason for failure.
-
onShutdown
Called during plugin framework shutdown- Parameters:
event- The shutdown event
-
isDynamicPluginLoader
public boolean isDynamicPluginLoader()- Specified by:
isDynamicPluginLoaderin interfacePluginLoader- Returns:
trueif this plugin loader can load plugins dynamically
-
canLoad
Determines if the artifact can be loaded by any of its deployers- Specified by:
canLoadin interfaceDynamicPluginLoader- Parameters:
pluginArtifact- The artifact to test- Returns:
- True if this artifact can be loaded by this loader
- Throws:
PluginParseException
-
discardPlugin
Description copied from interface:DiscardablePluginLoaderNotify 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:
discardPluginin interfaceDiscardablePluginLoader
-
postProcess
Template method that can be used by a specificPluginLoaderto add information to aPluginafter 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:PluginLoaderIf 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:
createModulein interfacePluginLoader- Parameters:
plugin- that the module will be added tomodule- to createmoduleDescriptorFactory- basic factory, may be overridden- Returns:
- null if incapable of creating
-