--- a/metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/RascalMetricServiceTracker.java
+++ b/metric-providers/org.ossmeter.metricprovider.rascal/src/org/ossmeter/metricprovider/rascal/RascalBundleManifest.java
@@ -1,51 +1,49 @@
package org.ossmeter.metricprovider.rascal;
-import java.util.ArrayList;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
import java.util.List;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-import org.ossmeter.platform.IMetricProvider;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.osgi.framework.Bundle;
+import org.rascalmpl.interpreter.utils.RascalManifest;
-public class RascalMetricServiceTracker implements ServiceTrackerCustomizer<IMetricProvider, IMetricProvider> {
+/**
+ * See @link {@link RascalManifest}. This class adds support for OSGI bundles.
+ */
+public class RascalBundleManifest extends RascalManifest {
- private static RascalMetricServiceTracker instance;
-
- List<IMetricProvider> metricProviders;
-
- // To prevent instantiation
- private RascalMetricServiceTracker() {
- metricProviders = new ArrayList<IMetricProvider>();
- }
-
- public List<IMetricProvider> getRegisteredRascalMetrics() {
- return metricProviders;
- }
-
- @Override
- public IMetricProvider addingService(ServiceReference<IMetricProvider> reference) {
+ public List<String> getSourceRoots(Bundle project) {
+ return getSourceRoots(manifest(project));
+ }
+
+ public String getMainModule(Bundle project) {
+ return getMainModule(manifest(project));
+ }
+
+ public String getMainFunction(Bundle project) {
+ return getMainFunction(manifest(project));
+ }
+
+ private InputStream manifest(Bundle bundle) {
+ URL rascalMF = bundle.getResource(META_INF_RASCAL_MF);
- IMetricProvider metric = Rasctivator.getContext().getService(reference);
- metricProviders.add(metric);
-
- return metric;
- }
+ try {
+ if (rascalMF != null) {
+ return FileLocator.openStream(bundle, new Path(META_INF_RASCAL_MF), false);
+ }
+ }
+ catch (IOException e) {
+ // do nothing, it's expected that some bundles do not have RASCAL.MF files
+ }
+
+ return null;
+ }
+
+ public boolean hasManifest(Bundle bundle) {
+ return hasManifest(manifest(bundle));
+ }
+}
- @Override
- public void modifiedService(ServiceReference<IMetricProvider> reference, IMetricProvider service) {
- // TODO Nothing to do?
- }
-
- @Override
- public void removedService(ServiceReference<IMetricProvider> reference, IMetricProvider service) {
- metricProviders.remove(service);
- }
-
- public static RascalMetricServiceTracker getInstance() {
- if (instance == null) {
- instance = new RascalMetricServiceTracker();
- }
-
- return instance;
- }
-}