Example #1
0
  public void activate() {
    try {
      // we need to call the activator ourselves as this bundle is included in the lib folder
      com.sun.jersey.core.osgi.Activator jerseyActivator = new com.sun.jersey.core.osgi.Activator();
      BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
      try {
        jerseyActivator.start(bundleContext);
      } catch (Exception e) {
        logger.error("Could not start Jersey framework", e);
      }

      httpPort = Integer.parseInt(bundleContext.getProperty("jetty.port"));
      httpSSLPort = Integer.parseInt(bundleContext.getProperty("jetty.port.ssl"));

      httpService.registerServlet(
          CV_SERVLET_ALIAS, new AtmosphereServlet(), getJerseyServletParams(), createHttpContext());

      logger.info("Started Cometvisu API at " + CV_SERVLET_ALIAS);

      if (discoveryService != null) {
        discoveryService.registerService(getDefaultServiceDescription());
        discoveryService.registerService(getSSLServiceDescription());
      }
    } catch (ServletException se) {
      throw new RuntimeException(se);
    } catch (NamespaceException se) {
      throw new RuntimeException(se);
    }
  }
Example #2
0
  public void deactivate() {
    if (this.httpService != null) {
      httpService.unregister(CV_SERVLET_ALIAS);
      logger.info("Stopped CometVisu API");
    }

    if (discoveryService != null) {
      discoveryService.unregisterService(getDefaultServiceDescription());
      discoveryService.unregisterService(getSSLServiceDescription());
    }
  }