1 package com.atlassian.plugin.factories;
2
3 import com.atlassian.plugin.ModuleDescriptorFactory;
4 import com.atlassian.plugin.Plugin;
5 import com.atlassian.plugin.PluginArtifact;
6 import com.atlassian.plugin.PluginParseException;
7 import com.atlassian.plugin.loaders.classloading.DeploymentUnit;
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 * @deprecated Since 2.2.0, use {@link #create(PluginArtifact,ModuleDescriptorFactory)} instead
34 */
35 Plugin create(DeploymentUnit deploymentUnit, ModuleDescriptorFactory moduleDescriptorFactory) throws PluginParseException;
36
37 /**
38 * Deploys the plugin artifact by instantiating the plugin and configuring it. Should only be called if the respective
39 * {@link #canCreate(PluginArtifact)} call returned the plugin key
40 *
41 * @param pluginArtifact the plugin artifact to deploy
42 * @param moduleDescriptorFactory the factory for the module descriptors
43 * @return the plugin loaded from the plugin artifact, or an UnloadablePlugin instance if loading fails.
44 * @throws com.atlassian.plugin.PluginParseException if the plugin could not be parsed
45 * @since 2.2.0
46 */
47 Plugin create(PluginArtifact pluginArtifact, ModuleDescriptorFactory moduleDescriptorFactory) throws PluginParseException;
48 }