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