--- a/metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/Activator.java
+++ b/metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/Rasctivator.java
@@ -2,29 +2,34 @@
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+import org.ossmeter.platform.IMetricProvider;
-public class Activator implements BundleActivator {
+public class Rasctivator implements BundleActivator {
private static BundleContext context;
+
+ protected ServiceTracker<IMetricProvider, IMetricProvider> rascalTracker;
static BundleContext getContext() {
return context;
}
- /*
- * (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
- */
+ @Override
public void start(BundleContext bundleContext) throws Exception {
- Activator.context = bundleContext;
+ Rasctivator.context = bundleContext;
+
+ rascalTracker = new ServiceTracker<>(bundleContext,
+ IMetricProvider.class, RascalMetricServiceTracker.getInstance());
+
+ rascalTracker.open();
}
- /*
- * (non-Javadoc)
- * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
- */
+ @Override
public void stop(BundleContext bundleContext) throws Exception {
- Activator.context = null;
+ Rasctivator.context = null;
+
+ rascalTracker.close();
}
}