felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r1442683 - /felix/trunk/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java
Date Tue, 05 Feb 2013 18:11:33 GMT
Author: rickhall
Date: Tue Feb  5 18:11:33 2013
New Revision: 1442683

URL: http://svn.apache.org/viewvc?rev=1442683&view=rev
Log:
Align dynamic import pre-checking more closely with the resolver itself; this makes it
more accurate, but it is still not 100% accurate since it doesn't take into account
resolver hooks. (FELIX-3766)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java?rev=1442683&r1=1442682&r2=1442683&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java Tue
Feb  5 18:11:33 2013
@@ -761,6 +761,45 @@ 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(
+                    (BundleCapabilityImpl) cap, dynReq.getFilter()))
+                {
+                    itCand.remove();
+                }
+            }
+        }
+        else
+        {
+            candidates.clear();
+        }
+
         return !candidates.isEmpty();
     }
 



Mime
View raw message