felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r906984 - /felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
Date Fri, 05 Feb 2010 15:59:13 GMT
Author: rickhall
Date: Fri Feb  5 15:59:13 2010
New Revision: 906984

URL: http://svn.apache.org/viewvc?rev=906984&view=rev
Log:
Modules that fail to resolve should continue to report failure if
referenced in a cycle.

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=906984&r1=906983&r2=906984&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
Fri Feb  5 15:59:13 2010
@@ -95,7 +95,7 @@
                 new HashMap<Requirement, Set<Capability>>();
 
             populateCandidates(state, module, candidateMap,
-                m_fwkExecEnvStr, m_fwkExecEnvSet, new HashSet<Module>());
+                m_fwkExecEnvStr, m_fwkExecEnvSet, new HashMap<Module, ResolveException>());
             m_candidatePermutations.add(candidateMap);
 
             ResolveException rethrow = null;
@@ -166,7 +166,7 @@
 
 //System.out.println("+++ DYNAMICALLY RESOLVING " + module + " - " + pkgName);
             populateDynamicCandidates(state, module, candidateMap,
-                m_fwkExecEnvStr, m_fwkExecEnvSet, new HashSet<Module>());
+                m_fwkExecEnvStr, m_fwkExecEnvSet, new HashMap<Module, ResolveException>());
             m_candidatePermutations.add(candidateMap);
             ResolveException rethrow = null;
 
@@ -366,7 +366,7 @@
     private static void populateCandidates(
         ResolverState state, Module module,
         Map<Requirement, Set<Capability>> candidateMap,
-        String fwkExecEnvStr, Set fwkExecEnvSet, Set<Module> cycles)
+        String fwkExecEnvStr, Set fwkExecEnvSet, Map<Module, ResolveException> cycles)
     {
         if (m_isInvokeCount)
         {
@@ -376,19 +376,23 @@
             m_invokeCounts.put(methodName, count);
         }
 
+        // Detect cycles.
+        if (cycles.containsKey(module))
+        {
+            if (cycles.get(module) != null)
+            {
+                throw cycles.get(module);
+            }
+            return;
+        }
+        cycles.put(module, null);
+
         // Verify that any required execution environment is satisfied.
         verifyExecutionEnvironment(fwkExecEnvStr, fwkExecEnvSet, module);
 
         // Verify that any native libraries match the current platform.
         verifyNativeLibraries(module);
 
-        // Detect cycles.
-        if (cycles.contains(module))
-        {
-            return;
-        }
-        cycles.add(module);
-
         // Store candidates in a local map first, just in case the module
         // is not resolvable.
         Map<Requirement, Set<Capability>> localCandidateMap = new HashMap();
@@ -417,8 +421,11 @@
             }
             if ((candidates.size() == 0) && !req.isOptional())
             {
-                throw new ResolveException("Unable to resolve " + module
-                    + ": missing requirement " + req, module, req);
+                ResolveException ex =
+                    new ResolveException("Unable to resolve " + module
+                        + ": missing requirement " + req, module, req);
+                cycles.put(module, ex);
+                throw ex;
             }
             else if (candidates.size() > 0)
             {
@@ -436,7 +443,7 @@
     private static void populateDynamicCandidates(
         ResolverState state, Module module,
         Map<Requirement, Set<Capability>> candidateMap,
-        String fwkExecEnvStr, Set fwkExecEnvSet, Set<Module> cycles)
+        String fwkExecEnvStr, Set fwkExecEnvSet, Map<Module, ResolveException> cycles)
     {
         if (m_isInvokeCount)
         {
@@ -447,11 +454,16 @@
         }
 
         // Detect cycles.
-        if (cycles.contains(module))
+        if (cycles.containsKey(module))
         {
+            if (cycles.get(module) != null)
+            {
+                throw cycles.get(module);
+            }
             return;
         }
-        cycles.add(module);
+        cycles.put(module, null);
+
 
         // There should be one entry in the candidate map, which are the
         // the candidates for the matching dynamic requirement. Get the
@@ -477,9 +489,9 @@
             }
         }
 
-// TODO: FELIX3 - Since we reuse the same dynamic requirement, it is possible
+// TODO: FELIX3 - Since we reuse the same dynamic requirement, is it possible
 //       that some sort of cycle could cause us to try try to match another
-//       set of candidates to the same requirement.
+//       set of candidates to the same requirement?
         if (candidates.size() == 0)
         {
             candidateMap.remove(dynReq);



Mime
View raw message