View Javadoc
1   package com.atlassian.plugin.manager;
2   
3   import com.atlassian.plugin.ModuleDescriptor;
4   import com.atlassian.plugin.ModuleDescriptorFactory;
5   import com.atlassian.plugin.Plugin;
6   import com.atlassian.plugin.PluginAccessor;
7   import com.atlassian.plugin.PluginArtifact;
8   import com.atlassian.plugin.PluginController;
9   import com.atlassian.plugin.PluginException;
10  import com.atlassian.plugin.PluginParseException;
11  import com.atlassian.plugin.PluginRegistry;
12  import com.atlassian.plugin.event.PluginEventManager;
13  import com.atlassian.plugin.scope.ScopeManager;
14  import org.dom4j.Element;
15  
16  import java.util.Set;
17  
18  public class ProductPluginAccessor extends ForwardingPluginAccessor implements PluginAccessor {
19      /**
20       * A noop implementation of PluginController with only {@link PluginController#disablePluginWithoutPersisting(String)}
21       * implemented as a noop and all other methods throwing {@link UnsupportedOperationException}
22       * <p>
23       * This is to decouple PluginAccessor from PluginController (see PLUG-304 for original coupling reasons)
24       */
25      private static PluginController noopDisablePluginPluginController = new PluginController() {
26          @Override
27          public void enablePlugins(final String... keys) {
28              throw new UnsupportedOperationException("Not implemented");
29          }
30  
31          @Override
32          public void disablePlugin(final String key) {
33              throw new UnsupportedOperationException("Not implemented");
34          }
35  
36          @Override
37          public void disablePluginWithoutPersisting(final String key) {
38          }
39  
40          @Override
41          public void enablePluginModule(final String completeKey) {
42              throw new UnsupportedOperationException("Not implemented");
43          }
44  
45          @Override
46          public void disablePluginModule(final String completeKey) {
47              throw new UnsupportedOperationException("Not implemented");
48          }
49  
50          @Override
51          public Set<String> installPlugins(final PluginArtifact... pluginArtifacts) throws PluginParseException {
52              throw new UnsupportedOperationException("Not implemented");
53          }
54  
55          @Override
56          public void uninstall(final Plugin plugin) throws PluginException {
57              throw new UnsupportedOperationException("Not implemented");
58          }
59  
60          @Override
61          public void revertRestartRequiredChange(final String pluginKey) throws PluginException {
62              throw new UnsupportedOperationException("Not implemented");
63          }
64  
65          @Override
66          public int scanForNewPlugins() throws PluginParseException {
67              throw new UnsupportedOperationException("Not implemented");
68          }
69  
70          @Override
71          public ModuleDescriptor<?> addDynamicModule(final Plugin plugin, final Element module) {
72              throw new UnsupportedOperationException("Not implemented");
73          }
74  
75          @Override
76          public void removeDynamicModule(final Plugin plugin, final ModuleDescriptor<?> module) {
77              throw new UnsupportedOperationException("Not implemented");
78          }
79      };
80  
81      public ProductPluginAccessor(final PluginRegistry.ReadOnly pluginRegistry,
82                                   final PluginPersistentStateStore store,
83                                   final ModuleDescriptorFactory moduleDescriptorFactory,
84                                   final PluginEventManager pluginEventManager) {
85          super(new EnabledModuleCachingPluginAccessor(
86                  new ProductPluginAccessorBase(pluginRegistry,
87                          store,
88                          moduleDescriptorFactory,
89                          pluginEventManager),
90                  pluginEventManager,
91                  noopDisablePluginPluginController));
92      }
93  
94      /**
95       * @deprecated in 5.0 for removal in 6.0 when {@link ScopeManager} will be removed. Use
96       *             {@link ProductPluginAccessor(com.atlassian.plugin.PluginRegistry.ReadOnly,
97       *             PluginPersistentStateStore, ModuleDescriptorFactory, PluginEventManager)} instead.
98       */
99      @Deprecated
100     public ProductPluginAccessor(final PluginRegistry.ReadOnly pluginRegistry,
101                                  final PluginPersistentStateStore store,
102                                  final ModuleDescriptorFactory moduleDescriptorFactory,
103                                  final PluginEventManager pluginEventManager,
104                                  final ScopeManager ignored) {
105         this(pluginRegistry, store, moduleDescriptorFactory, pluginEventManager);
106     }
107 }