summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Ross2012-09-11 07:39:46 (EDT)
committer Thomas Watson2012-09-11 11:00:59 (EDT)
commita4835983ff42069b0cde7da988f8fe68caacb116 (patch)
treea71ce7978789a777eee1fc9a5854d20f68404488
parentb89784d3c1750372551dd77c25868293f67ee3d0 (diff)
downloadrt.equinox.framework-a4835983ff42069b0cde7da988f8fe68caacb116.zip
rt.equinox.framework-a4835983ff42069b0cde7da988f8fe68caacb116.tar.gz
rt.equinox.framework-a4835983ff42069b0cde7da988f8fe68caacb116.tar.bz2
Refactored based on decision that the builder would not be API, at least for now, since all of the known entry providers currently reside in the module. The remaining API is the resolution report and its listener.
Added the filtered_by_hook and singleton entries along with tests. Fixed issue in ModuleResolver.ResolveProcess.selectSingletons where a loop was executing unnecessarily and adding a duplicate entry to the report.
-rw-r--r--bundles/org.eclipse.osgi.container.tests/manifests/resolution.report.a.MF2
-rw-r--r--bundles/org.eclipse.osgi.container.tests/manifests/resolution.report.a.v1.MF3
-rw-r--r--bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/AbstractTest.java7
-rw-r--r--bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/ResolutionReportTest.java185
-rw-r--r--bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/TestModuleContainer.java21
-rw-r--r--bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyContainerAdaptor.java14
-rw-r--r--bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyResolverHook.java43
-rw-r--r--bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyResolverHookFactory.java58
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java3
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java48
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolverHookFactory.java22
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ResolutionReport.java50
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ResolutionReportBuilder.java48
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReport.java19
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReportEntry.java20
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReportReader.java18
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java3
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java36
18 files changed, 331 insertions, 269 deletions
diff --git a/bundles/org.eclipse.osgi.container.tests/manifests/resolution.report.a.MF b/bundles/org.eclipse.osgi.container.tests/manifests/resolution.report.a.MF
new file mode 100644
index 0000000..7dd050d
--- /dev/null
+++ b/bundles/org.eclipse.osgi.container.tests/manifests/resolution.report.a.MF
@@ -0,0 +1,2 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: resolution.report.a; singleton:=true
diff --git a/bundles/org.eclipse.osgi.container.tests/manifests/resolution.report.a.v1.MF b/bundles/org.eclipse.osgi.container.tests/manifests/resolution.report.a.v1.MF
new file mode 100644
index 0000000..e7a8988
--- /dev/null
+++ b/bundles/org.eclipse.osgi.container.tests/manifests/resolution.report.a.v1.MF
@@ -0,0 +1,3 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: resolution.report.a; singleton:=true
+Bundle-Version: 1.0.0
diff --git a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/AbstractTest.java b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/AbstractTest.java
index e44674b..1c0bcfc 100644
--- a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/AbstractTest.java
+++ b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/AbstractTest.java
@@ -21,6 +21,7 @@ import org.eclipse.osgi.util.ManifestElement;
import org.junit.After;
import org.junit.Before;
import org.osgi.framework.*;
+import org.osgi.framework.hooks.resolver.ResolverHook;
public abstract class AbstractTest {
protected Set<ServiceRegistration<?>> serviceRegistrations;
@@ -42,7 +43,11 @@ public abstract class AbstractTest {
}
protected DummyContainerAdaptor createDummyAdaptor() {
- return new DummyContainerAdaptor(new DummyCollisionHook(false), new DummyResolverHookFactory(), Collections.<String, String> emptyMap());
+ return new DummyContainerAdaptor(new DummyCollisionHook(false), Collections.<String, String> emptyMap());
+ }
+
+ protected DummyContainerAdaptor createDummyAdaptor(ResolverHook hook) {
+ return new DummyContainerAdaptor(new DummyCollisionHook(false), Collections.<String, String> emptyMap(), new DummyResolverHookFactory(hook));
}
protected Bundle getBundle() {
diff --git a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/ResolutionReportTest.java b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/ResolutionReportTest.java
index e03a0f8..61d705f 100644
--- a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/ResolutionReportTest.java
+++ b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/ResolutionReportTest.java
@@ -11,91 +11,150 @@
package org.eclipse.osgi.container.tests;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
import java.util.*;
-import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.osgi.container.Module;
import org.eclipse.osgi.container.ModuleContainer;
-import org.eclipse.osgi.container.tests.dummys.DummyContainerAdaptor;
-import org.eclipse.osgi.container.tests.dummys.DummyResolverHookFactory;
+import org.eclipse.osgi.container.tests.dummys.*;
import org.eclipse.osgi.framework.report.ResolutionReport;
-import org.eclipse.osgi.framework.report.ResolutionReportReader;
import org.junit.Test;
import org.osgi.framework.Constants;
-import org.osgi.framework.wiring.*;
+import org.osgi.framework.wiring.BundleRevision;
+import org.osgi.framework.wiring.FrameworkWiring;
+import org.osgi.resource.Resource;
+import org.osgi.service.resolver.ResolutionException;
public class ResolutionReportTest extends AbstractTest {
- private static class ResolverHookFactory implements org.osgi.framework.hooks.resolver.ResolverHookFactory {
- private AtomicBoolean receivedCallback;
-
- public ResolverHookFactory(AtomicBoolean receivedCallback) {
- this.receivedCallback = receivedCallback;
- }
-
- @Override
- public org.osgi.framework.hooks.resolver.ResolverHook begin(Collection<BundleRevision> triggers) {
- return new ResolverHook(receivedCallback);
- }
+ @Test
+ public void testResolutionReportListenerService() throws Exception {
+ DummyResolverHook hook = new DummyResolverHook();
+ registerService(org.osgi.framework.hooks.resolver.ResolverHookFactory.class, new DummyResolverHookFactory(hook));
+ getSystemBundle().adapt(FrameworkWiring.class).resolveBundles(Collections.singleton(getSystemBundle()));
+ assertEquals("No resolution report listener callback", 1, hook.getResolutionReports().size());
+ assertNotNull("Resolution report was null", hook.getResolutionReports().get(0));
}
- private static class ResolverHook implements org.osgi.framework.hooks.resolver.ResolverHook, ResolutionReportReader {
- private final AtomicBoolean receivedCallback;
-
- public ResolverHook(AtomicBoolean receivedCallback) {
- this.receivedCallback = receivedCallback;
- }
-
- @Override
- public void end() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void filterResolvable(Collection<BundleRevision> candidates) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void filterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates) {
- // TODO Auto-generated method stub
-
- }
+ @Test
+ public void testResolutionReportListenerModule() throws Exception {
+ DummyResolverHook hook = new DummyResolverHook();
+ DummyContainerAdaptor adaptor = createDummyAdaptor(hook);
+ ModuleContainer container = adaptor.getContainer();
+ Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container);
+ container.resolve(Arrays.asList(systemBundle), true);
+ assertEquals("No resolution report listener callback", 1, hook.getResolutionReports().size());
+ assertNotNull("Resolution report was null", hook.getResolutionReports().get(0));
+ }
- @Override
- public void filterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates) {
- // TODO Auto-generated method stub
+ @Test
+ public void testResolutionReportBuilder() {
+ org.eclipse.osgi.container.ResolutionReport.Builder builder = new org.eclipse.osgi.container.ResolutionReport.Builder();
+ ResolutionReport report = builder.build();
+ assertNotNull("Resolution report was null", report);
+ }
+ @Test
+ public void testFilteredByResolverHook() throws Exception {
+ DummyResolverHook hook = new DummyResolverHook() {
+ @Override
+ public void filterResolvable(Collection<BundleRevision> candidates) {
+ candidates.clear();
+ }
+ };
+ DummyContainerAdaptor adaptor = createDummyAdaptor(hook);
+ ModuleContainer container = adaptor.getContainer();
+ Module module = installDummyModule("resolution.report.a.MF", "resolution.report.a", container);
+ try {
+ container.resolve(Collections.singleton(module), true);
+ fail("Resolution should not have succeeded");
+ } catch (ResolutionException e) {
+ // Okay.
}
+ ResolutionReport report = hook.getResolutionReports().get(0);
+ Map<Resource, List<ResolutionReport.Entry>> resourceToEntries = report.getEntries();
+ assertNotNull("No entries", resourceToEntries);
+ assertEquals("Wrong number of total entries", 1, resourceToEntries.size());
+ List<ResolutionReport.Entry> entries = resourceToEntries.get(module.getCurrentRevision());
+ assertNotNull("No entry for resource", entries);
+ assertEquals("Wrong number of entries", 1, entries.size());
+ ResolutionReport.Entry entry = entries.get(0);
+ assertEquals("Wrong type", ResolutionReport.Entry.Type.FILTERED_BY_HOOK, entry.getType());
+ }
- @Override
- public void read(ResolutionReport report) {
- receivedCallback.set(true);
+ @Test
+ public void testFilteredBySingletonNoneResolved() throws Exception {
+ DummyResolverHook hook = new DummyResolverHook();
+ DummyContainerAdaptor adaptor = createDummyAdaptor(hook);
+ ModuleContainer container = adaptor.getContainer();
+ Module resolutionReporta = installDummyModule("resolution.report.a.MF", "resolution.report.a", container);
+ Module resolutionReportaV1 = installDummyModule("resolution.report.a.v1.MF", "resolution.report.a.v1", container);
+ try {
+ container.resolve(Arrays.asList(resolutionReporta, resolutionReportaV1), true);
+ fail("Resolution should not have succeeded");
+ } catch (ResolutionException e) {
+ // Okay.
}
+ ResolutionReport report = hook.getResolutionReports().get(0);
+ Map<Resource, List<ResolutionReport.Entry>> resourceToEntries = report.getEntries();
+ assertNotNull("No entries", resourceToEntries);
+ assertEquals("Wrong number of total entries", 1, resourceToEntries.size());
+ List<ResolutionReport.Entry> entries = resourceToEntries.get(resolutionReporta.getCurrentRevision());
+ assertNotNull("No entry for resource", entries);
+ assertEquals("Wrong number of entries", 1, entries.size());
+ ResolutionReport.Entry entry = entries.get(0);
+ assertEquals("Wrong type", ResolutionReport.Entry.Type.SINGLETON, entry.getType());
}
@Test
- public void testResolutionReportReadCallback() throws Exception {
- AtomicBoolean receivedCallback = new AtomicBoolean(false);
- registerService(org.osgi.framework.hooks.resolver.ResolverHookFactory.class, new ResolverHookFactory(receivedCallback));
-
- getSystemBundle().adapt(FrameworkWiring.class).resolveBundles(Collections.singleton(getSystemBundle()));
-
- // DummyContainerAdaptor adaptor = createDummyAdaptor();
- // ModuleContainer container = adaptor.getContainer();
- // Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container);
- // container.resolve(Arrays.asList(systemBundle), true);
- assertTrue("Did not receive a resolution report callback", receivedCallback.get());
+ public void testFilteredBySingletonHighestVersionResolved() throws Exception {
+ DummyResolverHook hook = new DummyResolverHook();
+ DummyContainerAdaptor adaptor = createDummyAdaptor(hook);
+ ModuleContainer container = adaptor.getContainer();
+ Module resolutionReporta = installDummyModule("resolution.report.a.MF", "resolution.report.a", container);
+ Module resolutionReportaV1 = installDummyModule("resolution.report.a.v1.MF", "resolution.report.a.v1", container);
+ container.resolve(Arrays.asList(resolutionReportaV1), true);
+ hook.getResolutionReports().clear();
+ try {
+ container.resolve(Arrays.asList(resolutionReporta), true);
+ fail("Resolution should not have succeeded");
+ } catch (ResolutionException e) {
+ // Okay.
+ }
+ ResolutionReport report = hook.getResolutionReports().get(0);
+ Map<Resource, List<ResolutionReport.Entry>> resourceToEntries = report.getEntries();
+ assertNotNull("No entries", resourceToEntries);
+ assertEquals("Wrong number of total entries", 1, resourceToEntries.size());
+ List<ResolutionReport.Entry> entries = resourceToEntries.get(resolutionReporta.getCurrentRevision());
+ assertNotNull("No entry for resource", entries);
+ assertEquals("Wrong number of entries", 1, entries.size());
+ ResolutionReport.Entry entry = entries.get(0);
+ assertEquals("Wrong type", ResolutionReport.Entry.Type.SINGLETON, entry.getType());
}
@Test
- public void testResolutionReportWriteCallback() throws Exception {
- DummyContainerAdaptor adaptor = createDummyAdaptor();
+ public void testFilteredBySingletonLowestVersionResolved() throws Exception {
+ DummyResolverHook hook = new DummyResolverHook();
+ DummyContainerAdaptor adaptor = createDummyAdaptor(hook);
ModuleContainer container = adaptor.getContainer();
- Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container);
- container.resolve(Arrays.asList(systemBundle), true);
- assertEquals("No resolution report write callback", 1, ((DummyResolverHookFactory) adaptor.getResolverHookFactory()).getWriteCount());
+ Module resolutionReporta = installDummyModule("resolution.report.a.MF", "resolution.report.a", container);
+ container.resolve(Arrays.asList(resolutionReporta), true);
+ hook.getResolutionReports().clear();
+ Module resolutionReportaV1 = installDummyModule("resolution.report.a.v1.MF", "resolution.report.a.v1", container);
+ try {
+ container.resolve(Arrays.asList(resolutionReportaV1), true);
+ fail("Resolution should not have succeeded");
+ } catch (ResolutionException e) {
+ // Okay.
+ }
+ ResolutionReport report = hook.getResolutionReports().get(0);
+ Map<Resource, List<ResolutionReport.Entry>> resourceToEntries = report.getEntries();
+ assertNotNull("No entries", resourceToEntries);
+ assertEquals("Wrong number of total entries", 1, resourceToEntries.size());
+ List<ResolutionReport.Entry> entries = resourceToEntries.get(resolutionReportaV1.getCurrentRevision());
+ assertNotNull("No entry for resource", entries);
+ assertEquals("Wrong number of entries", 1, entries.size());
+ ResolutionReport.Entry entry = entries.get(0);
+ assertEquals("Wrong type", ResolutionReport.Entry.Type.SINGLETON, entry.getType());
}
}
diff --git a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/TestModuleContainer.java b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/TestModuleContainer.java
index 575026f..fecca58 100644
--- a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/TestModuleContainer.java
+++ b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/TestModuleContainer.java
@@ -30,6 +30,7 @@ import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.*;
import org.osgi.framework.hooks.resolver.ResolverHook;
+import org.osgi.framework.hooks.resolver.ResolverHookFactory;
import org.osgi.framework.namespace.ExecutionEnvironmentNamespace;
import org.osgi.framework.namespace.PackageNamespace;
import org.osgi.framework.wiring.*;
@@ -350,7 +351,7 @@ public class TestModuleContainer {
@Test
public void testInstallCollision02() throws BundleException, IOException {
- DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(true), new DummyResolverHookFactory(), Collections.<String, String> emptyMap());
+ DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(true), Collections.<String, String> emptyMap());
ModuleContainer container = adaptor.getContainer();
installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container);
installDummyModule("b1_v1.MF", "b1_a", container);
@@ -387,7 +388,7 @@ public class TestModuleContainer {
@Test
public void testUpdateCollision03() throws BundleException, IOException {
- DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(true), new DummyResolverHookFactory(), Collections.<String, String> emptyMap());
+ DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(true), Collections.<String, String> emptyMap());
ModuleContainer container = adaptor.getContainer();
Module b1_v1 = installDummyModule("b1_v1.MF", "b1_v1", container);
installDummyModule("b1_v2.MF", "b1_v2", container);
@@ -415,10 +416,10 @@ public class TestModuleContainer {
@Test
public void testSingleton02() throws BundleException, IOException, ResolutionException {
- ModuleResolverHookFactory resolverHookFactory = new ModuleResolverHookFactory() {
+ ResolverHookFactory resolverHookFactory = new ResolverHookFactory() {
@Override
- public ResolverHook begin(Collection<BundleRevision> triggers, ResolutionReportBuilder builder) {
+ public ResolverHook begin(Collection<BundleRevision> triggers) {
return new ResolverHook() {
@Override
@@ -445,7 +446,7 @@ public class TestModuleContainer {
};
}
};
- DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(false), resolverHookFactory, Collections.<String, String> emptyMap());
+ DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(false), Collections.<String, String> emptyMap());
ModuleContainer container = adaptor.getContainer();
Module s1 = installDummyModule("singleton1_v1.MF", "s1_v1", container);
@@ -482,10 +483,10 @@ public class TestModuleContainer {
@Test
public void testSingleton04() throws BundleException, IOException, ResolutionException {
final Collection<BundleRevision> disabled = new ArrayList<BundleRevision>();
- ModuleResolverHookFactory resolverHookFactory = new ModuleResolverHookFactory() {
+ ResolverHookFactory resolverHookFactory = new ResolverHookFactory() {
@Override
- public ResolverHook begin(Collection<BundleRevision> triggers, ResolutionReportBuilder builder) {
+ public ResolverHook begin(Collection<BundleRevision> triggers) {
return new ResolverHook() {
@Override
@@ -512,7 +513,7 @@ public class TestModuleContainer {
};
}
};
- DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(false), resolverHookFactory, Collections.<String, String> emptyMap());
+ DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(false), Collections.<String, String> emptyMap());
ModuleContainer container = adaptor.getContainer();
Module s1_v1 = installDummyModule("singleton1_v1.MF", "s1_v1", container);
@@ -1089,7 +1090,7 @@ public class TestModuleContainer {
Map<String, String> configuration = new HashMap<String, String>();
configuration.put(Constants.FRAMEWORK_BEGINNING_STARTLEVEL, "100");
- DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(false), new DummyResolverHookFactory(), configuration);
+ DummyContainerAdaptor adaptor = new DummyContainerAdaptor(new DummyCollisionHook(false), configuration);
ModuleContainer container = adaptor.getContainer();
DummyModuleDatabase database = adaptor.getDatabase();
@@ -1304,7 +1305,7 @@ public class TestModuleContainer {
}
private DummyContainerAdaptor createDummyAdaptor() {
- return new DummyContainerAdaptor(new DummyCollisionHook(false), new DummyResolverHookFactory(), Collections.<String, String> emptyMap());
+ return new DummyContainerAdaptor(new DummyCollisionHook(false), Collections.<String, String> emptyMap());
}
private Module installDummyModule(String manifestFile, String location, ModuleContainer container) throws BundleException, IOException {
diff --git a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyContainerAdaptor.java b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyContainerAdaptor.java
index 1f014d4..f47d857 100644
--- a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyContainerAdaptor.java
+++ b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyContainerAdaptor.java
@@ -17,19 +17,23 @@ import org.eclipse.osgi.container.Module.Settings;
import org.eclipse.osgi.container.tests.dummys.DummyModuleDatabase.DummyContainerEvent;
import org.eclipse.osgi.container.tests.dummys.DummyModuleDatabase.DummyModuleEvent;
import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.hooks.resolver.ResolverHookFactory;
public class DummyContainerAdaptor extends ModuleContainerAdaptor {
-
private final ModuleCollisionHook collisionHook;
- private final ModuleResolverHookFactory resolverHookFactory;
private final Map<String, String> configuration;
private final DummyModuleDatabase moduleDatabase;
private final ModuleContainer container;
+ private final ResolverHookFactory resolverHookFactory;
+
+ public DummyContainerAdaptor(ModuleCollisionHook collisionHook, Map<String, String> configuration) {
+ this(collisionHook, configuration, new DummyResolverHookFactory());
+ }
- public DummyContainerAdaptor(ModuleCollisionHook collisionHook, ModuleResolverHookFactory resolverHookFactory, Map<String, String> configuration) {
+ public DummyContainerAdaptor(ModuleCollisionHook collisionHook, Map<String, String> configuration, ResolverHookFactory resolverHookFactory) {
this.collisionHook = collisionHook;
- this.resolverHookFactory = resolverHookFactory;
this.configuration = configuration;
+ this.resolverHookFactory = resolverHookFactory;
this.moduleDatabase = new DummyModuleDatabase(this);
this.container = new ModuleContainer(this, moduleDatabase);
}
@@ -40,7 +44,7 @@ public class DummyContainerAdaptor extends ModuleContainerAdaptor {
}
@Override
- public ModuleResolverHookFactory getResolverHookFactory() {
+ public ResolverHookFactory getResolverHookFactory() {
return resolverHookFactory;
}
diff --git a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyResolverHook.java b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyResolverHook.java
new file mode 100644
index 0000000..a1bec42
--- /dev/null
+++ b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyResolverHook.java
@@ -0,0 +1,43 @@
+package org.eclipse.osgi.container.tests.dummys;
+
+import java.util.*;
+import org.eclipse.osgi.framework.report.ResolutionReport;
+import org.osgi.framework.hooks.resolver.ResolverHook;
+import org.osgi.framework.wiring.*;
+
+public class DummyResolverHook implements ResolutionReport.Listener, ResolverHook {
+ private final List<ResolutionReport> reports = new ArrayList<ResolutionReport>();
+
+ @Override
+ public void filterResolvable(Collection<BundleRevision> candidates) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void filterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void filterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void end() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void handleResolutionReport(ResolutionReport report) {
+ reports.add(report);
+ }
+
+ public List<ResolutionReport> getResolutionReports() {
+ return reports;
+ }
+}
diff --git a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyResolverHookFactory.java b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyResolverHookFactory.java
index 7188a39..4e02ff5 100644
--- a/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyResolverHookFactory.java
+++ b/bundles/org.eclipse.osgi.container.tests/src/org/eclipse/osgi/container/tests/dummys/DummyResolverHookFactory.java
@@ -1,55 +1,27 @@
-/*******************************************************************************
- * Copyright (c) 2012 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
package org.eclipse.osgi.container.tests.dummys;
import java.util.Collection;
-import org.eclipse.osgi.container.ModuleResolverHookFactory;
-import org.eclipse.osgi.container.ResolutionReportBuilder;
import org.osgi.framework.hooks.resolver.ResolverHook;
-import org.osgi.framework.wiring.*;
+import org.osgi.framework.hooks.resolver.ResolverHookFactory;
+import org.osgi.framework.wiring.BundleRevision;
-public class DummyResolverHookFactory implements ModuleResolverHookFactory {
- private int writeCount;
+public class DummyResolverHookFactory implements ResolverHookFactory {
+ private final ResolverHook hook;
- @Override
- public ResolverHook begin(Collection<BundleRevision> triggers, ResolutionReportBuilder builder) {
- writeCount++;
- return new ResolverHook() {
- @Override
- public void filterResolvable(Collection<BundleRevision> candidates) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void filterSingletonCollisions(BundleCapability singleton, Collection<BundleCapability> collisionCandidates) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void filterMatches(BundleRequirement requirement, Collection<BundleCapability> candidates) {
- // TODO Auto-generated method stub
-
- }
+ public DummyResolverHookFactory() {
+ this(new DummyResolverHook());
+ }
- @Override
- public void end() {
- // TODO Auto-generated method stub
+ public DummyResolverHookFactory(ResolverHook hook) {
+ this.hook = hook;
+ }
- }
- };
+ @Override
+ public ResolverHook begin(Collection<BundleRevision> triggers) {
+ return hook;
}
- public int getWriteCount() {
- return writeCount;
+ public ResolverHook getHook() {
+ return hook;
}
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java
index 877fc10..20684ff 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java
@@ -17,6 +17,7 @@ import org.apache.felix.resolver.ResolverImpl;
import org.eclipse.osgi.container.Module.Settings;
import org.osgi.framework.Constants;
import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.hooks.resolver.ResolverHookFactory;
import org.osgi.service.resolver.Resolver;
/**
@@ -96,7 +97,7 @@ public abstract class ModuleContainerAdaptor {
* Returns the resolver hook factory the container will use.
* @return the resolver hook factory the container will use.
*/
- public abstract ModuleResolverHookFactory getResolverHookFactory();
+ public abstract ResolverHookFactory getResolverHookFactory();
/**
* Publishes the specified container event.
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
index 87ceac6..f290222 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
@@ -14,6 +14,8 @@ import java.security.Permission;
import java.util.*;
import org.apache.felix.resolver.ResolverImpl;
import org.eclipse.osgi.container.ModuleRequirement.DynamicModuleRequirement;
+import org.eclipse.osgi.framework.report.ResolutionReport.Entry;
+import org.eclipse.osgi.framework.report.ResolutionReport.Entry.Type;
import org.eclipse.osgi.internal.container.Converters;
import org.osgi.framework.*;
import org.osgi.framework.hooks.resolver.ResolverHook;
@@ -585,7 +587,7 @@ final class ModuleResolver {
threadResolving.set(Boolean.TRUE);
try {
try {
- hook = adaptor.getResolverHookFactory().begin(Converters.asListBundleRevision((List<? extends BundleRevision>) triggers), null);
+ hook = adaptor.getResolverHookFactory().begin(Converters.asListBundleRevision((List<? extends BundleRevision>) triggers));
} catch (RuntimeException e) {
if (e.getCause() instanceof BundleException) {
BundleException be = (BundleException) e.getCause();
@@ -595,9 +597,10 @@ final class ModuleResolver {
}
throw e;
}
+ ResolutionReport.Builder builder = new ResolutionReport.Builder();
try {
- filterResolvable();
- selectSingletons();
+ filterResolvable(builder);
+ selectSingletons(builder);
Map<Resource, List<Wire>> extensionWirings = resolveFrameworkExtensions();
if (!extensionWirings.isEmpty()) {
return extensionWirings;
@@ -613,6 +616,8 @@ final class ModuleResolver {
}
return resolver.resolve(this);
} finally {
+ if (hook instanceof ResolutionReport.Listener)
+ ((ResolutionReport.Listener) hook).handleResolutionReport(builder.build());
hook.end();
}
} finally {
@@ -674,13 +679,15 @@ final class ModuleResolver {
}
- private void filterResolvable() {
+ private void filterResolvable(ResolutionReport.Builder builder) {
Collection<ModuleRevision> enabledCandidates = new ArrayList<ModuleRevision>(unresolved);
hook.filterResolvable(Converters.asListBundleRevision((List<? extends BundleRevision>) enabledCandidates));
disabled.removeAll(enabledCandidates);
+ for (ModuleRevision revision : disabled)
+ builder.addEntry(revision, Entry.Type.FILTERED_BY_HOOK);
}
- private void selectSingletons() {
+ private void selectSingletons(ResolutionReport.Builder builder) {
Map<String, Collection<ModuleRevision>> selectedSingletons = new HashMap<String, Collection<ModuleRevision>>();
for (ModuleRevision revision : unresolved) {
if (!isSingleton(revision) || disabled.contains(revision))
@@ -718,28 +725,32 @@ final class ModuleResolver {
disabled.add(singleton);
// TODO add resolver diagnostics here
//state.addResolverError(singleton.getBundleDescription(), ResolverError.SINGLETON_SELECTION, collision.getBundleDescription().toString(), null);
+ builder.addEntry(singleton, Type.SINGLETON);
break;
}
if (!pickOneToResolve.contains(collision))
pickOneToResolve.add(collision);
}
- // need to make sure the bundle does not collide from the POV of another entry
- for (Map.Entry<ModuleRevision, Collection<ModuleRevision>> collisionEntry : collisionMap.entrySet()) {
- if (collisionEntry.getKey() != singleton && collisionEntry.getValue().contains(singleton)) {
- if (selected.contains(collisionEntry.getKey())) {
- // Must fail since there is already a selected bundle for which the singleton bundle is a collision
- disabled.add(singleton);
- // TODO add resolver diagnostics here
- // state.addResolverError(singleton.getBundleDescription(), ResolverError.SINGLETON_SELECTION, collisionEntry.getKey().getBundleDescription().toString(), null);
- break;
+ if (!disabled.contains(singleton)) {
+ // need to make sure the bundle does not collide from the POV of another entry
+ for (Map.Entry<ModuleRevision, Collection<ModuleRevision>> collisionEntry : collisionMap.entrySet()) {
+ if (collisionEntry.getKey() != singleton && collisionEntry.getValue().contains(singleton)) {
+ if (selected.contains(collisionEntry.getKey())) {
+ // Must fail since there is already a selected bundle for which the singleton bundle is a collision
+ disabled.add(singleton);
+ // TODO add resolver diagnostics here
+ // state.addResolverError(singleton.getBundleDescription(), ResolverError.SINGLETON_SELECTION, collisionEntry.getKey().getBundleDescription().toString(), null);
+ builder.addEntry(singleton, Type.SINGLETON);
+ break;
+ }
+ if (!pickOneToResolve.contains(collisionEntry.getKey()))
+ pickOneToResolve.add(collisionEntry.getKey());
}
- if (!pickOneToResolve.contains(collisionEntry.getKey()))
- pickOneToResolve.add(collisionEntry.getKey());
}
}
if (!disabled.contains(singleton)) {
pickOneToResolve.add(singleton);
- selected.add(pickOneToResolve(pickOneToResolve));
+ selected.add(pickOneToResolve(pickOneToResolve, builder));
}
}
}
@@ -771,7 +782,7 @@ final class ModuleResolver {
return result;
}
- private ModuleRevision pickOneToResolve(Collection<ModuleRevision> pickOneToResolve) {
+ private ModuleRevision pickOneToResolve(Collection<ModuleRevision> pickOneToResolve, ResolutionReport.Builder builder) {
ModuleRevision selectedVersion = null;
for (ModuleRevision singleton : pickOneToResolve) {
if (selectedVersion == null)
@@ -786,6 +797,7 @@ final class ModuleResolver {
disabled.add(singleton);
// TODO add resolver diagnostic here.
// state.addResolverError(singleton.getBundleDescription(), ResolverError.SINGLETON_SELECTION, selectedVersion.getBundleDescription().toString(), null);
+ builder.addEntry(singleton, Type.SINGLETON);
}
}
return selectedVersion;
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolverHookFactory.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolverHookFactory.java
deleted file mode 100644
index 4181e07..0000000
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolverHookFactory.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osgi.container;
-
-import java.util.Collection;
-import org.osgi.framework.hooks.resolver.ResolverHook;
-import org.osgi.framework.wiring.BundleRevision;
-
-/**
- * @since 3.10
- */
-public interface ModuleResolverHookFactory {
- public ResolverHook begin(Collection<BundleRevision> triggers, ResolutionReportBuilder builder);
-}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ResolutionReport.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ResolutionReport.java
new file mode 100644
index 0000000..4a1fad9
--- /dev/null
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ResolutionReport.java
@@ -0,0 +1,50 @@
+package org.eclipse.osgi.container;
+
+import java.util.*;
+import org.osgi.resource.Resource;
+
+/**
+ * @since 3.10
+ */
+public class ResolutionReport implements org.eclipse.osgi.framework.report.ResolutionReport {
+ public static class Builder {
+ private final Map<Resource, List<Entry>> resourceToEntries = new HashMap<Resource, List<Entry>>();
+
+ public void addEntry(Resource resource, Entry.Type type) {
+ List<Entry> entries = resourceToEntries.get(resource);
+ if (entries == null) {
+ entries = new ArrayList<Entry>();
+ resourceToEntries.put(resource, entries);
+ }
+ entries.add(new EntryImpl(type));
+ }
+
+ public ResolutionReport build() {
+ return new ResolutionReport(resourceToEntries);
+ }
+ }
+
+ private static class EntryImpl implements Entry {
+ private final Type type;
+
+ EntryImpl(Type type) {
+ this.type = type;
+ }
+
+ @Override
+ public Type getType() {
+ return type;
+ }
+ }
+
+ private final Map<Resource, List<ResolutionReport.Entry>> entries;
+
+ ResolutionReport(Map<Resource, List<ResolutionReport.Entry>> entries) {
+ this.entries = Collections.unmodifiableMap(new HashMap<Resource, List<ResolutionReport.Entry>>(entries));
+ }
+
+ @Override
+ public Map<Resource, List<Entry>> getEntries() {
+ return entries;
+ }
+}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ResolutionReportBuilder.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ResolutionReportBuilder.java
deleted file mode 100644
index ab8ec09..0000000
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ResolutionReportBuilder.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osgi.container;
-
-import org.eclipse.osgi.framework.report.ResolutionReport;
-import org.eclipse.osgi.framework.report.ResolutionReportEntry;
-import org.osgi.resource.Resource;
-
-/**
- * @since 3.10
- */
-public class ResolutionReportBuilder {
- public ResolutionReport build() {
- return new ResolutionReport() {
- @Override
- public boolean hasNext() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public ResolutionReportEntry next() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void remove() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public ResolutionReportEntry getResolutionReport(Resource resource) {
- // TODO Auto-generated method stub
- return null;
- }
- };
- }
-}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReport.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReport.java
index 59abd8c..ee55b60 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReport.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReport.java
@@ -10,12 +10,25 @@
*******************************************************************************/
package org.eclipse.osgi.framework.report;
-import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import org.osgi.resource.Resource;
/**
* @since 3.10
*/
-public interface ResolutionReport extends Iterator<ResolutionReportEntry> {
- public ResolutionReportEntry getResolutionReport(Resource resource);
+public interface ResolutionReport {
+ public interface Entry {
+ enum Type {
+ FILTERED_BY_HOOK, SINGLETON
+ }
+
+ Type getType();
+ }
+
+ public interface Listener {
+ void handleResolutionReport(ResolutionReport report);
+ }
+
+ Map<Resource, List<Entry>> getEntries();
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReportEntry.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReportEntry.java
deleted file mode 100644
index d00e718..0000000
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReportEntry.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osgi.framework.report;
-
-import org.osgi.resource.Resource;
-
-/**
- * @since 3.10
- */
-public interface ResolutionReportEntry {
- public Resource getResource();
-}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReportReader.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReportReader.java
deleted file mode 100644
index 93c0709..0000000
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/framework/report/ResolutionReportReader.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osgi.framework.report;
-
-/**
- * @since 3.10
- */
-public interface ResolutionReportReader {
- public void read(ResolutionReport report);
-}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
index 6878d6a..db11fa3 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxContainerAdaptor.java
@@ -17,6 +17,7 @@ import org.eclipse.osgi.internal.loader.*;
import org.eclipse.osgi.storage.BundleInfo.Generation;
import org.eclipse.osgi.storage.Storage;
import org.osgi.framework.*;
+import org.osgi.framework.hooks.resolver.ResolverHookFactory;
import org.osgi.framework.namespace.HostNamespace;
import org.osgi.framework.wiring.BundleRevision;
import org.osgi.service.resolver.ResolutionException;
@@ -64,7 +65,7 @@ public class EquinoxContainerAdaptor extends ModuleContainerAdaptor {
}
@Override
- public ModuleResolverHookFactory getResolverHookFactory() {
+ public ResolverHookFactory getResolverHookFactory() {
return hooks.getResolverHookFactory();
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java
index 30b1f6c..162355b 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/OSGiFrameworkHooks.java
@@ -13,11 +13,11 @@ package org.eclipse.osgi.internal.framework;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.*;
-import org.eclipse.osgi.container.*;
+import org.eclipse.osgi.container.Module;
+import org.eclipse.osgi.container.ModuleCollisionHook;
import org.eclipse.osgi.container.namespaces.EquinoxNativeCodeNamespace;
import org.eclipse.osgi.framework.internal.core.Msg;
import org.eclipse.osgi.framework.report.ResolutionReport;
-import org.eclipse.osgi.framework.report.ResolutionReportReader;
import org.eclipse.osgi.internal.baseadaptor.ArrayMap;
import org.eclipse.osgi.internal.debug.Debug;
import org.eclipse.osgi.internal.serviceregistry.*;
@@ -30,7 +30,7 @@ import org.osgi.framework.wiring.*;
class OSGiFrameworkHooks {
static final String collisionHookName = CollisionHook.class.getName();
- private final ModuleResolverHookFactory resolverHookFactory;
+ private final ResolverHookFactory resolverHookFactory;
private final ModuleCollisionHook collisionHook;
OSGiFrameworkHooks(EquinoxContainer container) {
@@ -38,7 +38,7 @@ class OSGiFrameworkHooks {
collisionHook = new BundleCollisionHook(container);
}
- public ModuleResolverHookFactory getResolverHookFactory() {
+ public ResolverHookFactory getResolverHookFactory() {
return resolverHookFactory;
}
@@ -127,7 +127,7 @@ class OSGiFrameworkHooks {
* This class is not thread safe and expects external synchronization.
*
*/
- static class CoreResolverHookFactory implements ModuleResolverHookFactory {
+ static class CoreResolverHookFactory implements ResolverHookFactory {
// need a tuple to hold the service reference and hook object
// do not use a map for performance reasons; no need to hash based on a key.
static class HookReference {
@@ -171,13 +171,13 @@ class OSGiFrameworkHooks {
}
}
- public ResolverHook begin(Collection<BundleRevision> triggers, ResolutionReportBuilder builder) {
+ public ResolverHook begin(Collection<BundleRevision> triggers) {
if (debug.DEBUG_HOOKS) {
Debug.println("ResolverHook.begin"); //$NON-NLS-1$
}
ServiceRegistry registry = container.getServiceRegistry();
if (registry == null) {
- return new CoreResolverHook(Collections.<HookReference> emptyList(), builder);
+ return new CoreResolverHook(Collections.<HookReference> emptyList());
}
Module systemModule = container.getStorage().getModuleContainer().getModule(0);
BundleContextImpl context = (BundleContextImpl) EquinoxContainer.secureAction.getContext(systemModule.getBundle());
@@ -196,7 +196,7 @@ class OSGiFrameworkHooks {
} catch (Throwable t) {
// need to force an end call on the ResolverHooks we got and release them
try {
- new CoreResolverHook(hookRefs, builder).end();
+ new CoreResolverHook(hookRefs).end();
} catch (Throwable endError) {
// we are already in failure mode; just continue
}
@@ -205,16 +205,16 @@ class OSGiFrameworkHooks {
}
}
}
- return new CoreResolverHook(hookRefs, builder);
+ return new CoreResolverHook(hookRefs);
}
- class CoreResolverHook implements ResolverHook {
- private final ResolutionReportBuilder builder;
+ class CoreResolverHook implements ResolutionReport.Listener, ResolverHook {
private final List<HookReference> hooks;
- CoreResolverHook(List<HookReference> hooks, ResolutionReportBuilder builder) {
+ private volatile ResolutionReport report;
+
+ CoreResolverHook(List<HookReference> hooks) {
this.hooks = hooks;
- this.builder = builder;
}
public void filterResolvable(Collection<BundleRevision> candidates) {
@@ -310,7 +310,6 @@ class OSGiFrameworkHooks {
HookReference missingHook = null;
Throwable endError = null;
HookReference endBadHook = null;
- ResolutionReport report = null;
for (Iterator<HookReference> iHooks = hooks.iterator(); iHooks.hasNext();) {
HookReference hookRef = iHooks.next();
// We do not remove unregistered services here because we are going to remove all of them at the end
@@ -319,8 +318,8 @@ class OSGiFrameworkHooks {
missingHook = hookRef;
} else {
try {
- if (hookRef.hook instanceof ResolutionReportReader)
- ((ResolutionReportReader) hookRef.hook).read(report);
+ if (hookRef.hook instanceof ResolutionReport.Listener)
+ ((ResolutionReport.Listener) hookRef.hook).handleResolutionReport(report);
hookRef.hook.end();
} catch (Throwable t) {
// Must continue on to the next hook.end method
@@ -343,6 +342,11 @@ class OSGiFrameworkHooks {
hooks.clear();
}
}
+
+ @Override
+ public void handleResolutionReport(ResolutionReport report) {
+ this.report = report;
+ }
}
}
}