View Javadoc

1   package com.atlassian.plugins.rest.module;
2   
3   import javax.ws.rs.ext.RuntimeDelegate;
4   
5   import org.osgi.framework.BundleActivator;
6   import org.osgi.framework.BundleContext;
7   import org.slf4j.Logger;
8   import org.slf4j.LoggerFactory;
9   import org.springframework.beans.factory.DisposableBean;
10  import org.springframework.beans.factory.InitializingBean;
11  
12  import com.sun.jersey.server.impl.provider.RuntimeDelegateImpl;
13  
14  public class Activator implements InitializingBean, DisposableBean {
15      private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
16  
17      private final BundleActivator coreActivator = new com.sun.jersey.core.osgi.Activator();
18      private final BundleContext bundleContext;
19  
20      public Activator(BundleContext bundleContext) {
21          this.bundleContext = bundleContext;
22      }
23  
24      public void afterPropertiesSet() throws Exception {
25          coreActivator.start(bundleContext);
26  
27          LOG.debug("jersey-server bundle activator registering JAX-RS RuntimeDelegate instance");
28          RuntimeDelegate.setInstance(new RuntimeDelegateImpl());
29      }
30  
31      public void destroy() throws Exception {
32          coreActivator.stop(bundleContext);
33      }
34  }