View Javadoc

1   package com.atlassian.plugin.loaders;
2   
3   import java.io.File;
4   import java.util.List;
5   
6   import com.atlassian.plugin.DefaultPluginArtifactFactory;
7   import com.atlassian.plugin.PluginArtifact.AllowsReference.ReferenceMode;
8   import com.atlassian.plugin.PluginArtifactFactory;
9   import com.atlassian.plugin.event.PluginEventManager;
10  import com.atlassian.plugin.factories.PluginFactory;
11  import com.atlassian.plugin.util.EnumUtils;
12  
13  /**
14   * A PluginLoader which manages plugins specified by a roster file.
15   *
16   * @see RosterFileScanner
17   * @since v3.0.24
18   */
19  public class RosterFilePluginLoader extends ScanningPluginLoader
20  {
21      public static String getReferenceModePropertyName()
22      {
23          return RosterFilePluginLoader.class.getName() + ".referenceMode";
24      }
25  
26      private static ReferenceMode referenceModeFromProperty()
27      {
28          final String propertyName = getReferenceModePropertyName();
29          return EnumUtils.enumValueFromProperty(propertyName, ReferenceMode.values(), ReferenceMode.FORBID_REFERENCE);
30      }
31  
32      /**
33       * Create a RosterFilePluginLoader which loads a given roster file to locate plugins.
34       *
35       * @param rosterFile the file to load the plugin roster from, as per {@link RosterFileScanner}.
36       * @param pluginFactories the factories used to convert PluginArtifacts to Plugins.
37       * @param pluginEventManager the event manager for the plugin system.
38       */
39      public RosterFilePluginLoader(final File rosterFile,
40              final List<PluginFactory> pluginFactories,
41              final PluginEventManager pluginEventManager)
42      {
43          this(rosterFile, pluginFactories, referenceModeFromProperty(), pluginEventManager);
44      }
45  
46      /**
47       * Create a RosterFilePluginLoader which loads a given roster file to locate plugins.
48       *
49       * @param rosterFile the file to load the plugin roster from, as per {@link RosterFileScanner}.
50       * @param pluginFactories the factories used to convert PluginArtifacts to Plugins.
51       * @param referenceMode the ReferenceMode to use for the implicit {@link DefaultPluginArtifactFactory}.
52       * @param pluginEventManager the event manager for the plugin system.
53       */
54      public RosterFilePluginLoader(final File rosterFile,
55              final List<PluginFactory> pluginFactories,
56              final ReferenceMode referenceMode,
57              final PluginEventManager pluginEventManager)
58      {
59          this(rosterFile, pluginFactories, new DefaultPluginArtifactFactory(referenceMode), pluginEventManager);
60      }
61  
62      /**
63       * Create a RosterFilePluginLoader which loads a given roster file to locate plugins.
64       *
65       * @param rosterFile the file to load the plugin roster from, as per {@link RosterFileScanner}.
66       * @param pluginFactories the factories used to convert PluginArtifacts to Plugins.
67       * @param pluginArtifactFactory the factory used to convert URIs to PluginArtifacts.
68       * @param pluginEventManager the event manager for the plugin system.
69       */
70      public RosterFilePluginLoader(final File rosterFile,
71              final List<PluginFactory> pluginFactories,
72              final PluginArtifactFactory pluginArtifactFactory,
73              final PluginEventManager pluginEventManager)
74      {
75          super(new RosterFileScanner(rosterFile), pluginFactories, pluginArtifactFactory, pluginEventManager);
76      }
77  }