ConfigurationAdmin configurationAdmin = getTrackedService(ConfigurationAdmin.class);
if (configurationAdmin == null) {
return;
}
final BundleServiceImpl bundleService = new BundleServiceImpl(bundleContext);
register(BundleService.class, bundleService);
bundleStateServicesTracker = new ServiceTracker<BundleStateService, BundleStateService>(
bundleContext, BundleStateService.class, new ServiceTrackerCustomizer<BundleStateService, BundleStateService>() {
@Override
public BundleStateService addingService(ServiceReference<BundleStateService> reference) {
BundleStateService service = bundleContext.getService(reference);
bundleService.registerBundleStateService(service);
return service;
}
@Override
public void modifiedService(ServiceReference<BundleStateService> reference, BundleStateService service) {
}
@Override
public void removedService(ServiceReference<BundleStateService> reference, BundleStateService service) {
bundleService.unregisterBundleStateService(service);
bundleContext.ungetService(reference);
}
}
);
bundleStateServicesTracker.open();