Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
framework-4.0.2
-
None
Description
Proposed patch
diff --git a/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java b/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java index cc9a387..7255649 100644 --- a/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java +++ b/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java @@ -39,6 +39,7 @@ import org.apache.felix.framework.resolver.ResolverWire; import org.apache.felix.framework.util.ShrinkableCollection; import org.apache.felix.framework.util.Util; import org.apache.felix.framework.util.manifestparser.R4Library; +import org.apache.felix.framework.wiring.BundleCapabilityImpl; import org.apache.felix.framework.wiring.BundleRequirementImpl; import org.apache.felix.framework.wiring.BundleWireImpl; import org.osgi.framework.Bundle; @@ -755,6 +756,44 @@ class StatefulResolver attrs); List<BundleCapability> candidates = findProviders(req, false); + // Try to find a dynamic requirement that matches the capabilities. + BundleRequirementImpl dynReq = null; + for (int dynIdx = 0; + (candidates.size() > 0) && (dynReq == null) && (dynIdx < dynamics.size()); + dynIdx++) + { + for (Iterator<BundleCapability> itCand = candidates.iterator(); + (dynReq == null) && itCand.hasNext(); ) + { + BundleCapability cap = itCand.next(); + if (CapabilitySet.matches( + (BundleCapabilityImpl) cap, + ((BundleRequirementImpl) dynamics.get(dynIdx)).getFilter())) + { + dynReq = (BundleRequirementImpl) dynamics.get(dynIdx); + } + } + } + + // If we found a matching dynamic requirement, then filter out + // any candidates that do not match it. + if (dynReq != null) + { + for (Iterator<BundleCapability> itCand = candidates.iterator(); + itCand.hasNext(); ) + { + BundleCapability cap = itCand.next(); + if (!CapabilitySet.matches(cap, dynReq.getFilter())) + { + itCand.remove(); + } + } + } + else + { + candidates.clear(); + } + return !candidates.isEmpty();