Return-Path: Delivered-To: apmail-felix-commits-archive@www.apache.org Received: (qmail 50447 invoked from network); 2 Dec 2009 21:28:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Dec 2009 21:28:13 -0000 Received: (qmail 80405 invoked by uid 500); 2 Dec 2009 21:28:13 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 80352 invoked by uid 500); 2 Dec 2009 21:28:13 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 80343 invoked by uid 99); 2 Dec 2009 21:28:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Dec 2009 21:28:12 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=BAYES_00 X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Dec 2009 21:28:10 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3E1A323888C5; Wed, 2 Dec 2009 21:27:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r886309 - /felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/prototype/ProtoResolver.java Date: Wed, 02 Dec 2009 21:27:50 -0000 To: commits@felix.apache.org From: rickhall@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091202212750.3E1A323888C5@eris.apache.org> Author: rickhall Date: Wed Dec 2 21:27:49 2009 New Revision: 886309 URL: http://svn.apache.org/viewvc?rev=886309&view=rev Log: Simplify main resolver loop. Modified: felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/prototype/ProtoResolver.java Modified: felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/prototype/ProtoResolver.java URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/prototype/ProtoResolver.java?rev=886309&r1=886308&r2=886309&view=diff ============================================================================== --- felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/prototype/ProtoResolver.java (original) +++ felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/prototype/ProtoResolver.java Wed Dec 2 21:27:49 2009 @@ -205,7 +205,8 @@ { repeat = false; - // Loop through all of the target module's imports and v + // Loop through all of the target module's imports and see + // if there is a consistent candidate provider. for (Requirement req : reqs) { // Get the current candidate capability for the current import. @@ -215,77 +216,81 @@ { continue; } + + // Find a consistent candidate. + Capability selectedCandidate = null; Iterator itExporters = exporters.iterator(); - Capability cap = itExporters.next(); -//System.out.println("+++ RESOLVING " + cap + " FOR " + module); - try + while ((selectedCandidate == null) && itExporters.hasNext()) { - // If current candidate is resolved, then try to merge - // in its constraints with the existing constraints. - if (cap.getModule().isResolved()) - { - mergeResolvedConstraints( - module, candidateMap, currentConstraintsCopy, - cap); - } - // If current candidate is the same as the module being - // resolved, then just directly add it as a constraint. - else if (cap.getModule().equals(module)) + Capability cap = itExporters.next(); +//System.out.println("+++ RESOLVING " + cap + " FOR " + module); + try { - currentConstraintsCopy.put( - (String) cap.getAttribute(Capability.PACKAGE_ATTR).getValue(), - new Blame(cap, blameModule)); + // If current candidate is resolved, then try to merge + // in its constraints with the existing constraints. + if (cap.getModule().isResolved()) + { + mergeResolvedConstraints( + module, candidateMap, currentConstraintsCopy, + cap); + } + // If current candidate is the same as the module being + // resolved, then just directly add it as a constraint. + else if (cap.getModule().equals(module)) + { + currentConstraintsCopy.put( + (String) cap.getAttribute(Capability.PACKAGE_ATTR).getValue(), + new Blame(cap, blameModule)); + } + // If the current candidate is not resolved, then try to resolve + // it, which will also merge packages while verify constraints. + else + { + resolve( + cap.getModule(), + cap, + module, + candidateMap, + currentConstraintsCopy, + cycleMap); + } + + // This candidate was consistent, so select it. + selectedCandidate = cap; } - // If the current candidate is not resolved, then try to resolve - // it, which will also merge packages while verify constraints. - else + // If we have a resolve exception, then the current candidate + // should be removed. If we are at the root, we should try the + // next permutated candidate map if there are no more candidates. + catch (ResolveException ex) { - resolve( - cap.getModule(), - cap, - module, - candidateMap, - currentConstraintsCopy, - cycleMap); - } - } - // If we have a resolve exception, then the current candidate - // should be removed. If we are at the root, we should try the - // next permutated candidate map if there are no more candidates. - catch (ResolveException ex) - { System.out.println("RE " + ex); ex.printStackTrace(); //System.out.println("Current candidate map : " + candidateMap); - // Remove offending candidate. - itExporters.remove(); + // Remove offending candidate. + itExporters.remove(); //System.out.println("Updated candidate map : " + candidateMap); - if (!itExporters.hasNext() && !req.isOptional()) - { - // TODO: PROTO RESOLVER - Maybe this should be moved. - if ((module == m_rootModule) && (m_candidatePermutations.size() > 0)) + if (!itExporters.hasNext() && !req.isOptional()) { - currentConstraintsCopy.clear(); - currentConstraintsCopy.putAll(currentConstraints); - candidateMap = m_candidatePermutations.remove(0); + // TODO: PROTO RESOLVER - Maybe this should be moved. + if ((module == m_rootModule) && (m_candidatePermutations.size() > 0)) + { + currentConstraintsCopy.clear(); + currentConstraintsCopy.putAll(currentConstraints); + candidateMap = m_candidatePermutations.remove(0); //System.out.println("+++ TRYING ALTERNATIVE: " + candidateMap); - // Flush various caches for new candidates. - m_resolvingConstraintCache.clear(); - m_verifyCache.clear(); - repeat = true; - } - else - { - candidateMap.remove(req); - throw new ResolveException("Unresolved constraint " - + req + " in " + module); + // Flush various caches for new candidates. + m_resolvingConstraintCache.clear(); + m_verifyCache.clear(); + repeat = true; + } + else + { + candidateMap.remove(req); + throw new ResolveException("Unresolved constraint " + + req + " in " + module); + } } } - else - { - repeat = true; - } - break; } } }