felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r916172 - /felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
Date Thu, 25 Feb 2010 08:09:18 GMT
Author: rickhall
Date: Thu Feb 25 08:09:18 2010
New Revision: 916172

URL: http://svn.apache.org/viewvc?rev=916172&view=rev
Log:
Improve candidate consistency verification to avoid cycle issues
for reexport visibility; still not working yet.

Modified:
    felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java

Modified: felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java?rev=916172&r1=916171&r2=916172&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
(original)
+++ felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
Thu Feb 25 08:09:18 2010
@@ -416,6 +416,7 @@
         {
             cycleCount = (Integer) ((Object[]) cacheValue)[0];
             ((Object[]) cacheValue)[0] = new Integer(cycleCount.intValue() + 1);
+            cycleCount = (Integer) ((Object[]) cacheValue)[0];
             localCandidateMap = (Map) ((Object[]) cacheValue)[1];
             remainingReqs = (List) ((Object[]) cacheValue)[2];
         }
@@ -444,8 +445,8 @@
             // Add these value to the result cache so we know we are
             // in the middle of populating candidates for the current
             // module.
-            resultCache.put(
-                module, new Object[] { cycleCount, localCandidateMap, remainingReqs });
+            resultCache.put(module,
+                cacheValue = new Object[] { cycleCount, localCandidateMap, remainingReqs
});
         }
 
         // If we have requirements remaining, then find candidates for them.
@@ -498,7 +499,7 @@
         // cycle counter, otherwise record the result.
         if (cycleCount.intValue() > 0)
         {
-            ((Object[]) cacheValue)[0] = new Integer(cycleCount.intValue() + 1);
+            ((Object[]) cacheValue)[0] = new Integer(cycleCount.intValue() - 1);
         }
         else if (cycleCount.intValue() == 0)
         {
@@ -583,22 +584,45 @@
             m_invokeCounts.put(methodName, count);
         }
 
-        // If the module is in the cycle map, then just return.
-        if (cycleMap.containsKey(module))
+        Integer cycleCount = null;
+
+        Object o = cycleMap.get(module);
+
+        if (o instanceof Boolean)
         {
             return;
         }
-        cycleMap.put(module, module);
+        else if (o == null)
+        {
+            List list;
+            if (module.isResolved())
+            {
+                list = new ArrayList(module.getWires());
+            }
+            else
+            {
+                list = new ArrayList(module.getRequirements());
+            }
+            cycleMap.put(module, o = new Object[] { cycleCount = new Integer(0), list });
+            calculateExportedPackages(module, incomingReqs, modulePkgMap);
+        }
+        else
+        {
+            cycleCount = (Integer) ((Object[]) o)[0];
+            ((Object[]) o)[0] = new Integer(cycleCount.intValue() + 1);
+            cycleCount = (Integer) ((Object[]) o)[0];
+        }
 
 //System.out.println("+++ RESOLVING " + module);
-        calculateExportedPackages(module, incomingReqs, modulePkgMap);
 
         if (module.isResolved())
         {
-//            Packages pkgs = modulePkgMap.get(module);
-//            calculateResolvedPackages(module, incomingReqs, pkgs);
-            for (Wire wire : module.getWires())
+            List<Wire> wires = (List<Wire>) ((Object[]) o)[1];
+
+            while (wires.size() > 0)
             {
+                Wire wire = wires.remove(0);
+
                 // Try to resolve the candidate.
                 findConsistentCandidates(
                     wire.getCapability().getModule(),
@@ -619,10 +643,12 @@
         }
         else
         {
-            List<Requirement> reqs = new ArrayList(module.getRequirements());
-            reqs.addAll(module.getDynamicRequirements());
-            for (Requirement req : reqs)
+            List<Requirement> reqs = (List<Requirement>) ((Object[]) o)[1];
+
+            while (reqs.size() > 0)
             {
+                Requirement req = reqs.remove(0);
+
                 // Get the candidates for the current requirement.
                 Set<Capability> candCaps = candidateMap.get(req);
                 // Optional requirements may not have any candidates.
@@ -674,6 +700,18 @@
                 }
             }
         }
+
+        // If we are exiting from a cycle then decrement
+        // cycle counter, otherwise record the result.
+        if (cycleCount.intValue() > 0)
+        {
+            ((Object[]) o)[0] = new Integer(cycleCount.intValue() - 1);
+        }
+        else if (cycleCount.intValue() == 0)
+        {
+            // Record that the module was successfully populated.
+            cycleMap.put(module, Boolean.TRUE);
+        }
     }
 
     private void findConsistentDynamicCandidate(



Mime
View raw message