View Javadoc

1   package com.atlassian.plugin.factories;
2   
3   import com.atlassian.plugin.loaders.classloading.DeploymentUnit;
4   import com.atlassian.plugin.ModuleDescriptorFactory;
5   import com.atlassian.plugin.PluginParseException;
6   import com.atlassian.plugin.Plugin;
7   import com.atlassian.plugin.PluginArtifact;
8   
9   /**
10   * Creates the plugin artifact and deploys it into the appropriate plugin management system
11   * @since 2.0.0
12   */
13  public interface PluginFactory
14  {
15      /**
16       * Determines if this factory can handle this artifact.
17       *
18       * @param pluginArtifact The artifact to test
19       * @return The plugin key, null if it cannot load the plugin
20       * @throws com.atlassian.plugin.PluginParseException If there are exceptions parsing the plugin configuration when
21       * the deployer should have been able to deploy the plugin
22       */
23      String canCreate(PluginArtifact pluginArtifact) throws PluginParseException;
24  
25      /**
26       * Deploys the deployment unit by instantiating the plugin and configuring it.  Should only be called if the respective
27       * {@link #canCreate(PluginArtifact)} call returned the plugin key
28       *
29       * @param deploymentUnit the unit to deploy
30       * @param moduleDescriptorFactory the factory for the module descriptors
31       * @return the plugin loaded from the deployment unit, or an UnloadablePlugin instance if loading fails.
32       * @throws com.atlassian.plugin.PluginParseException if the plugin could not be parsed
33       */
34      Plugin create(DeploymentUnit deploymentUnit, ModuleDescriptorFactory moduleDescriptorFactory) throws PluginParseException;
35  }