View Javadoc
1   package com.atlassian.plugin.loaders;
2   
3   import com.atlassian.plugin.ModuleDescriptor;
4   import com.atlassian.plugin.ModuleDescriptorFactory;
5   import com.atlassian.plugin.Plugin;
6   import com.atlassian.plugin.PluginException;
7   import com.atlassian.plugin.PluginParseException;
8   import org.dom4j.Element;
9   
10  /**
11   * Handles loading and unloading plugin artifacts from a location
12   */
13  public interface PluginLoader {
14      /**
15       * Loads all plugins that can be installed in the plugin system.
16       *
17       * @param moduleDescriptorFactory the factory for module descriptors
18       * @return the list of found plugins, may be empty
19       * @throws PluginParseException if any error occurred loading plugins
20       */
21      Iterable<Plugin> loadAllPlugins(ModuleDescriptorFactory moduleDescriptorFactory) throws PluginParseException;
22  
23      /**
24       * Load all newly found plugins that can be installed in the plugin system. Only plugins not previously loaded will
25       * be added.
26       *
27       * @param moduleDescriptorFactory the factory for module descriptors
28       * @return a list of newly discovered plugins since the last time plugins were loaded
29       * @throws PluginParseException if any error occurred loading plugins
30       */
31      Iterable<Plugin> loadFoundPlugins(ModuleDescriptorFactory moduleDescriptorFactory) throws PluginParseException;
32  
33      /**
34       * @return true if this PluginLoader tracks whether or not plugins are added to it.
35       */
36      boolean supportsAddition();
37  
38      /**
39       * @return true if this PluginLoader tracks whether or not plugins are removed from it.
40       */
41      boolean supportsRemoval();
42  
43      /**
44       * Remove a specific plugin
45       */
46      void removePlugin(Plugin plugin) throws PluginException;
47  
48      /**
49       * @return {@code true} if this plugin loader can load plugins dynamically
50       * @since 3.0
51       */
52      boolean isDynamicPluginLoader();
53  
54      /**
55       * If this loader is capable of loading a plugin of the type passed, attempt to create a module descriptor. Add that
56       * module descriptor to the plugin.
57       * <p>
58       * If capable, always return a ModuleDescriptor, even if it indicates a failure case. Caller is responsible for
59       * handling exceptional {@link com.atlassian.plugin.ModuleDescriptor}.
60       *
61       * @param plugin                  that the module will be added to
62       * @param module                  to create
63       * @param moduleDescriptorFactory basic factory, may be overridden
64       * @return null if incapable of creating
65       * @since 4.0.0
66       */
67      ModuleDescriptor<?> createModule(Plugin plugin, Element module, ModuleDescriptorFactory moduleDescriptorFactory);
68  }