use of org.apache.karaf.util.tracker.SingleServiceTracker in project karaf by apache.
the class Activator method start.
@Override
public void start(final BundleContext context) throws Exception {
registrations = new ArrayList<>();
registrations.add(context.registerService(DumpProvider.class, new LogDumpProvider(context), null));
featuresServiceTracker = new SingleServiceTracker<>(context, FeaturesService.class, (oldFs, newFs) -> {
if (featuresProviderRegistration != null) {
featuresProviderRegistration.unregister();
featuresProviderRegistration = null;
}
if (newFs != null) {
featuresProviderRegistration = context.registerService(DumpProvider.class, new FeaturesDumpProvider(newFs), null);
}
});
featuresServiceTracker.open();
final DiagnosticDumpMBeanImpl diagnostic = new DiagnosticDumpMBeanImpl();
diagnostic.setBundleContext(context);
Hashtable<String, Object> props = new Hashtable<>();
props.put("jmx.objectname", "org.apache.karaf:type=diagnostic,name=" + System.getProperty("karaf.name"));
mbeanRegistration = context.registerService(getInterfaceNames(diagnostic), diagnostic, props);
}
Aggregations