1 package com.atlassian.plugin.osgi.factory;
2
3 import com.atlassian.plugin.IllegalPluginStateException;
4 import com.atlassian.plugin.PluginDependencies;
5 import com.atlassian.plugin.module.ContainerAccessor;
6 import com.atlassian.plugin.osgi.container.OsgiContainerException;
7 import org.osgi.framework.Bundle;
8 import org.osgi.util.tracker.ServiceTracker;
9
10 import javax.annotation.Nonnull;
11 import java.io.InputStream;
12 import java.net.URL;
13 import java.util.Set;
14
15 import static com.google.common.base.Preconditions.checkNotNull;
16
17
18
19
20
21
22
23 abstract class OsgiPluginNotInstalledHelperBase implements OsgiPluginHelper {
24 private final String key;
25
26 OsgiPluginNotInstalledHelperBase(final String key) {
27 this.key = checkNotNull(key);
28 }
29
30 public Bundle getBundle() {
31 throw new IllegalPluginStateException(getNotInstalledMessage());
32 }
33
34 public URL getResource(final String name) {
35 throw new IllegalPluginStateException("Cannot getResource(" + name + "): " + getNotInstalledMessage());
36 }
37
38 public InputStream getResourceAsStream(final String name) {
39 throw new IllegalPluginStateException("Cannot getResourceAsStream(" + name + "): " + getNotInstalledMessage());
40 }
41
42 public ClassLoader getClassLoader() {
43 throw new IllegalPluginStateException(getNotInstalledMessage());
44 }
45
46 public void onEnable(final ServiceTracker... serviceTrackers) throws OsgiContainerException {
47 throw new IllegalPluginStateException(getNotInstalledMessage());
48 }
49
50 public void onDisable() throws OsgiContainerException {
51 throw new IllegalPluginStateException(getNotInstalledMessage());
52 }
53
54 public void onUninstall() throws OsgiContainerException {
55 throw new IllegalPluginStateException(getNotInstalledMessage());
56 }
57
58 @Nonnull
59 @Override
60 public PluginDependencies getDependencies() {
61 throw new IllegalPluginStateException(getNotInstalledMessage());
62 }
63
64 public void setPluginContainer(final Object container) {
65 throw new IllegalPluginStateException(getNotInstalledMessage());
66 }
67
68 public ContainerAccessor getContainerAccessor() {
69 throw new IllegalPluginStateException(getNotInstalledMessage());
70 }
71
72 public ContainerAccessor getRequiredContainerAccessor() {
73 throw new IllegalPluginStateException(getNotInstalledMessage());
74 }
75
76 protected String getKey() {
77 return key;
78 }
79
80 protected abstract String getNotInstalledMessage();
81 }