Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2012 EclipseSource and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: Holger Staudacher - initial API and implementation /
package com.eclipsesource.jaxrs.publisher.internal;
import  org.osgi.framework.Bundle;
import  org.osgi.framework.BundleActivator;
import  org.osgi.framework.BundleContext;
import  org.osgi.framework.BundleException;
import  org.osgi.framework.Constants;
import  org.osgi.framework.Filter;
import  org.osgi.framework.FrameworkUtil;
import  org.osgi.framework.InvalidSyntaxException;
import  org.osgi.framework.ServiceRegistration;
import  org.osgi.service.cm.ManagedService;
public class Activator implements BundleActivator {
  private ServiceRegistration<?> connectorRegistration;
  private HttpTracker httpTracker;
  private ServiceRegistration<?> configRegistration;
  public void start( BundleContext context ) throws Exception {
    System.setProperty"javax.ws.rs.ext.RuntimeDelegate"
                        "org.glassfish.jersey.server.internal.RuntimeDelegateImpl" );
     = new JAXRSConnectorcontext );
    registerConfigurationcontext );
     = context.registerService( JAXRSConnector.class.getName(), null );
    openHttpServiceTrackercontext );
    openAllServiceTrackercontext );
  }
  private void registerConfiguration( BundleContext context ) {
    Dictionary<StringStringproperties = new Hashtable<StringString>();
    properties.put( Constants.SERVICE_PID, . );
     = context.registerService( ManagedService.class.getName(),
                                                  new Configuration ),
                                                  properties );
  }
  private void startJerseyServer() throws BundleException {
    Bundle bundle = getJerseyAPIBundle();
    ifbundle.getState() != Bundle.ACTIVE ) {
      bundle.start();
    }
  }
  private void openHttpServiceTracker( BundleContext context ) {
     = new HttpTrackercontext );
    .open();
  }
  private void openAllServiceTracker( BundleContext context ) throws InvalidSyntaxException {
    Filter filter = context.createFilter( . );
     = new ResourceTrackercontextfilter );
    .open();
  }
  public void stop( BundleContext context ) throws Exception {
    .close();
    .close();
    .unregister();
    .unregister();
  }
  // For testing purpose
  Bundle getJerseyAPIBundle() {
    return FrameworkUtil.getBundle( Path.class );
  }
New to GrepCode? Check out our FAQ X