1 package com.atlassian.plugin.osgi.bridge;
2
3 import org.osgi.framework.BundleActivator;
4 import org.osgi.framework.BundleContext;
5 import org.osgi.framework.ServiceReference;
6 import org.springframework.osgi.context.event.OsgiBundleApplicationContextListener;
7 import com.atlassian.plugin.event.PluginEventManager;
8
9 public class BridgeActivator implements BundleActivator
10 {
11 public void start(BundleContext bundleContext) throws Exception
12 {
13
14 ServiceReference ref = bundleContext.getServiceReference(PluginEventManager.class.getName());
15 if (ref == null)
16 {
17 throw new IllegalStateException("The PluginEventManager service must be exported from the application");
18 }
19 PluginEventManager pluginEventManager = (PluginEventManager) bundleContext.getService(ref);
20
21 bundleContext.registerService(
22 OsgiBundleApplicationContextListener.class.getName(),
23 new SpringOsgiEventBridge(pluginEventManager),
24 null);
25 }
26
27 public void stop(BundleContext bundleContext) throws Exception
28 {
29 }
30 }