diff options
author | Thomas Watson | 2016-12-15 21:29:12 +0000 |
---|---|---|
committer | Thomas Watson | 2016-12-15 21:29:12 +0000 |
commit | 58531484f1d8f944df8180960854d870524fd94b (patch) | |
tree | 6a3bd5dc556a70e0641024d0ddcd25cebbc7daaa /bundles | |
parent | 0d254aa5f9c7a1a3fdb2d4fd78bcbc8a197c4f8b (diff) | |
download | rt.equinox.framework-58531484f1d8f944df8180960854d870524fd94b.tar.gz rt.equinox.framework-58531484f1d8f944df8180960854d870524fd94b.tar.xz rt.equinox.framework-58531484f1d8f944df8180960854d870524fd94b.zip |
Bug 509318 - Update resolver implementation to latest from apache
Change-Id: I6898a735b29127d71d1ba285106062315f978f88
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
Diffstat (limited to 'bundles')
3 files changed, 74 insertions, 34 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java index e26a78c0d..6741e52be 100644 --- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java +++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/container/TestModuleContainer.java @@ -2665,6 +2665,51 @@ public class TestModuleContainer extends AbstractTest { } @Test + public void testMultiHostFragmentWithOverlapImport() throws BundleException { + DummyContainerAdaptor adaptor = createDummyAdaptor(); + ModuleContainer container = adaptor.getContainer(); + + // install an exporter + Map<String, String> exporterManifest = new HashMap<String, String>(); + exporterManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); + exporterManifest.put(Constants.BUNDLE_SYMBOLICNAME, "exporter"); + exporterManifest.put(Constants.BUNDLE_VERSION, "1.0"); + exporterManifest.put(Constants.EXPORT_PACKAGE, "exporter"); + installDummyModule(exporterManifest, "exporter", container); + + // install a fragment to the exporter + Map<String, String> exporterFragManifest = new HashMap<String, String>(); + exporterFragManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); + exporterFragManifest.put(Constants.BUNDLE_SYMBOLICNAME, "exporter.frag"); + exporterFragManifest.put(Constants.EXPORT_PACKAGE, "exporter.frag"); + exporterFragManifest.put(Constants.FRAGMENT_HOST, "exporter"); + installDummyModule(exporterFragManifest, "exporter.frag", container); + + // install a host that imports the exporter + Map<String, String> hostManifest = new HashMap<String, String>(); + hostManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); + hostManifest.put(Constants.BUNDLE_SYMBOLICNAME, "host"); + hostManifest.put(Constants.BUNDLE_VERSION, "1.0"); + hostManifest.put(Constants.IMPORT_PACKAGE, "exporter"); + installDummyModule(hostManifest, "host10", container); + hostManifest.put(Constants.BUNDLE_VERSION, "1.1"); + installDummyModule(hostManifest, "host11", container); + hostManifest.put(Constants.BUNDLE_VERSION, "1.2"); + installDummyModule(hostManifest, "host12", container); + + // install a fragment that also imports the exporter + Map<String, String> hostFragManifest = new HashMap<String, String>(); + hostFragManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2"); + hostFragManifest.put(Constants.BUNDLE_SYMBOLICNAME, "host.frag"); + hostFragManifest.put(Constants.FRAGMENT_HOST, "host"); + hostFragManifest.put(Constants.IMPORT_PACKAGE, "exporter; version=0.0"); + Module hostFrag = installDummyModule(hostFragManifest, "host.frag", container); + + ResolutionReport report = container.resolve(Arrays.asList(hostFrag), true); + Assert.assertNull("Failed to resolve test.", report.getResolutionException()); + } + + @Test public void testModuleWiringToString() throws BundleException { DummyContainerAdaptor adaptor = createDummyAdaptor(); ModuleContainer container = adaptor.getContainer(); diff --git a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java index 1afed36c3..29b2b7b10 100755 --- a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java +++ b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java @@ -834,6 +834,30 @@ class Candidates } // Step 4 + // First copy candidates for wrapped requirements to the host. + for (WrappedResource hostResource : hostResources) { + for (Requirement r : hostResource.getRequirements(null)) + { + Requirement origReq = ((WrappedRequirement) r).getDeclaredRequirement(); + CandidateSelector cands = m_candidateMap.get(origReq); + if (cands != null) + { + if (cands instanceof ShadowList) + { + m_candidateMap.put(r, ShadowList.deepCopy((ShadowList) cands)); + } else { + m_candidateMap.put(r, cands.copy()); + } + for (Capability cand : cands.getRemainingCandidates()) + { + Set<Requirement> dependents = m_dependentMap.get(cand); + dependents.remove(origReq); + dependents.add(r); + } + } + } + } + for (WrappedResource hostResource : hostResources) { // Replaces capabilities from fragments with the capabilities @@ -918,28 +942,6 @@ class Candidates } } } - - // Copy candidates for fragment requirements to the host. - for (Requirement r : hostResource.getRequirements(null)) - { - Requirement origReq = ((WrappedRequirement) r).getDeclaredRequirement(); - CandidateSelector cands = m_candidateMap.get(origReq); - if (cands != null) - { - if (cands instanceof ShadowList) - { - m_candidateMap.put(r, ShadowList.deepCopy((ShadowList) cands)); - } else { - m_candidateMap.put(r, cands.copy()); - } - for (Capability cand : cands.getRemainingCandidates()) - { - Set<Requirement> dependents = m_dependentMap.get(cand); - dependents.remove(origReq); - dependents.add(r); - } - } - } } // Lastly, verify that all mandatory revisions are still diff --git a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/util/ShadowList.java b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/util/ShadowList.java index f69025fdc..a91ba30ee 100755 --- a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/util/ShadowList.java +++ b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/util/ShadowList.java @@ -27,36 +27,29 @@ import org.osgi.service.resolver.ResolveContext; public class ShadowList extends CandidateSelector { - public static ShadowList createShadowList(CandidateSelector original) { + public static ShadowList createShadowList(CandidateSelector original) { if (original instanceof ShadowList) { throw new IllegalArgumentException("Cannot create a ShadowList using another ShadowList."); } - return new ShadowList(original); + return new ShadowList(original.unmodifiable, original.unmodifiable, original.isUnmodifiable); } public static ShadowList deepCopy(ShadowList original) { - List<Capability> originalCopy = new ArrayList<Capability>(original.m_original); - return new ShadowList(original.unmodifiable, originalCopy, original.isUnmodifiable); + return new ShadowList(original.unmodifiable, original.m_original, original.isUnmodifiable); } private final List<Capability> m_original; - private ShadowList(CandidateSelector original) - { - super(original); - m_original = new ArrayList<Capability>(original.getRemainingCandidates()); - } - private ShadowList(CandidateSelector shadow, List<Capability> original) { super(shadow); m_original = original; } - public ShadowList(List<Capability> unmodifiable, List<Capability> originalCopy, AtomicBoolean isUnmodifiable) { + private ShadowList(List<Capability> unmodifiable, List<Capability> original, AtomicBoolean isUnmodifiable) { super(unmodifiable, isUnmodifiable); - m_original = originalCopy; + m_original = new ArrayList<Capability>(original); } public ShadowList copy() { |