On 11/24/12 17:03, Gareth Collins wrote:
Hello,I am trying to understand how the R5 resolver works with bundles which export and import the same package (e.g. as felix bundles that implement OSGi enterprise/compendium services do). So I found the org.apache.felix.resolver.test.Main class and added a couple of my own scenarios: scenario 6: private static List<Resource> populateScenario6( Map<Resource, Wiring> wirings, Map<Requirement, List<Capability>> candMap) { wirings.clear(); candMap.clear(); ResourceImpl a = new ResourceImpl("A"); a.addCapability(new PackageCapability(a, "A")); a.addRequirement(new PackageRequirement(a, "A")); ResourceImpl b = new ResourceImpl("B"); b.addCapability(new PackageCapability(b, "A")); List<Capability> capabilityList = new ArrayList<Capability>(2); capabilityList.addAll(a.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE)); capabilityList.addAll(b.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE)); candMap.put(a.getRequirements(null).get(0), capabilityList); List<Resource> resources = new ArrayList<Resource>(); resources.add(a); return resources; } scenario 7 - same as scenario 6 but with the adds to the capability list reversed. i.e.: capabilityList.addAll(b.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE)); capabilityList.addAll(a.getCapabilities(PackageNamespace.PACKAGE_NAMESPACE)); I would have expected that both scenario 6 and 7 would give me the same result (i.e. only resource A is required to satisfy the requirements). Instead it appears that the result is dependent on the capability list add order: SCENARIO 6 RESULT {osgi.identity; A=[]} SCENARIO 7 RESULT {osgi.identity; A=[osgi.wiring.package; (osgi.wiring.package=A) -> [osgi.identity; B]], osgi.identity; B=[]} This is not correct behaviour, is it?
Why would it not be correct? It is a valid resolution, isn't it? The resolver is only required to give a valid resolution or fail.
Let me know if I am missing something obvious here.
I'm not exactly sure what is going on here, but for bundles I'd expect you'd see something similar in the framework, since packages from bundles installed earlier are given preferences over bundles installed later.
Ordering has always been important in the framework, if I recall correctly, since bundle ID was used as a tie breaker if all else was equal.
-> richard
Note that I have opened a corresponding issue on the bnd/bndtools project which uses the R5 resolver: https://github.com/bndtools/bnd/issues/284 Just wanting to confirm that this is incorrect behaviour by the resolver. If it is I will open a JIRA. thanks in advance, Gareth --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
--------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

