View Javadoc
1   package com.atlassian.plugin.osgi.factory;
2   
3   import com.atlassian.plugin.IllegalPluginStateException;
4   import org.osgi.framework.Bundle;
5   
6   /**
7    * Helper class that implements the methods for an OSGi plugin that has been uninstalled after being installed.
8    *
9    * @since 3.0.17
10   */
11  final class OsgiPluginDeinstalledHelper extends OsgiPluginNotInstalledHelperBase {
12      private final boolean remotePlugin;
13  
14      public OsgiPluginDeinstalledHelper(final String key, final boolean remotePlugin) {
15          super(key);
16          this.remotePlugin = remotePlugin;
17      }
18  
19      public <T> Class<T> loadClass(final String clazz, final Class<?> callingClass) {
20          final String className = (null != callingClass) ? callingClass.getCanonicalName() : "null";
21          throw new IllegalPluginStateException(
22                  " Cannot loadClass(" + clazz + ", " + className + "): " + getNotInstalledMessage() +
23                          ". This is probably because the module/plugin code is continuing to execute code after " +
24                          "it has been shutdown, for example from a finalize() method, or in response to a timer." +
25                          " Ensure all code execution ceases after PluginDisabledEvent is received.");
26      }
27  
28      public Bundle install() {
29          throw new IllegalPluginStateException("Cannot reuse Plugin instance for '" + getKey() + "'");
30      }
31  
32      protected String getNotInstalledMessage() {
33          return "This operation must occur before the plugin '" + getKey() + "' is uninstalled";
34      }
35  
36      public boolean isRemotePlugin() {
37          return remotePlugin;
38      }
39  }