in chef/services/src/main/java/org/jclouds/karaf/chef/services/Activator.java [50:72]
public void start(final BundleContext context) throws Exception {
registerChefServiceFactory(context);
//We use the system bundle context to avoid issues with InvalidBundleContext.
chefServiceTracker = new ServiceTracker(context.getBundle(0).getBundleContext(), ApiContext.class.getName(), null) {
@Override
public Object addingService(ServiceReference reference) {
Object obj = super.addingService(reference);
if (CHEF_TOKEN.isAssignableFrom(obj.getClass())) {
String serviceId = String.valueOf(reference.getProperty(Constants.SERVICE_ID));
registerRecipeProviderForService(context, serviceId, (ApiContext<ChefApi>) obj);
}
return obj;
}
@Override
public void removedService(ServiceReference reference, Object service) {
String serviceId = String.valueOf(reference.getProperty(Constants.SERVICE_ID));
unregisterRecipeProviderForService(context, serviceId, (ApiContext<ChefApi>) service);
super.removedService(reference, service);
}
};
chefServiceTracker.open();
}