felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r1147238 - in /felix/trunk/framework/src/main/java/org/apache/felix/framework: BundleWiringImpl.java resolver/Candidates.java resolver/HostedCapability.java resolver/HostedRequirement.java resolver/ResolverImpl.java
Date Fri, 15 Jul 2011 16:56:53 GMT
Author: rickhall
Date: Fri Jul 15 16:56:53 2011
New Revision: 1147238

URL: http://svn.apache.org/viewvc?rev=1147238&view=rev
Log:
Modify fragment merging aglorithm to properly update dependent map
so that all caps/reqs get replaced by their corresponding synthesized
cap/req from the synthesized host module. If you don't do this, then
hosts with inter-dependencies can get invalid wires. (FELIX-3043)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Candidates.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostedCapability.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostedRequirement.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java?rev=1147238&r1=1147237&r2=1147238&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleWiringImpl.java Fri
Jul 15 16:56:53 2011
@@ -35,13 +35,12 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
 import org.apache.felix.framework.cache.JarContent;
 import org.apache.felix.framework.cache.Content;
-import org.apache.felix.framework.resolver.HostedCapability;
-import org.apache.felix.framework.resolver.HostedRequirement;
 import org.apache.felix.framework.resolver.ResolveException;
 import org.apache.felix.framework.resolver.ResourceNotFoundException;
 import org.apache.felix.framework.util.CompoundEnumeration;
@@ -50,7 +49,6 @@ import org.apache.felix.framework.util.S
 import org.apache.felix.framework.util.Util;
 import org.apache.felix.framework.util.manifestparser.ManifestParser;
 import org.apache.felix.framework.util.manifestparser.R4Library;
-import org.apache.felix.framework.wiring.BundleCapabilityImpl;
 import org.apache.felix.framework.wiring.BundleRequirementImpl;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Candidates.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Candidates.java?rev=1147238&r1=1147237&r2=1147238&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Candidates.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/Candidates.java
Fri Jul 15 16:56:53 2011
@@ -711,14 +711,21 @@ class Candidates
                 // really be attached to the original host, not the wrapper.
                 if (!c.getNamespace().equals(BundleRevision.HOST_NAMESPACE))
                 {
-                    Set<BundleRequirement> dependents =
-                        m_dependentMap.get(((HostedCapability) c).getDeclaredCapability());
+                    BundleCapability origCap =
+                        ((HostedCapability) c).getOriginalCapability();
+                    // Note that you might think we could remove the original cap
+                    // from the dependent map, but you can't since it may come from
+                    // a fragment that is attached to multiple hosts, so each host
+                    // will need to make their own copy.
+                    Set<BundleRequirement> dependents = m_dependentMap.get(origCap);
                     if (dependents != null)
                     {
+                        dependents = new HashSet<BundleRequirement>(dependents);
+                        m_dependentMap.put(c, dependents);
                         for (BundleRequirement r : dependents)
                         {
                             Set<BundleCapability> cands = m_candidateMap.get(r);
-                            cands.remove(((HostedCapability) c).getDeclaredCapability());
+                            cands.remove(origCap);
                             cands.add(c);
                         }
                     }
@@ -726,15 +733,20 @@ class Candidates
             }
 
             // Copy candidates for fragment requirements to the host.
-            // This doesn't record the reverse dependency, but that
-            // information should not be needed at this point anymore.
             for (BundleRequirement r : hostRevision.getDeclaredRequirements(null))
             {
-                SortedSet<BundleCapability> cands =
-                    m_candidateMap.get(((HostedRequirement) r).getDeclaredRequirement());
+                BundleRequirement origReq =
+                    ((HostedRequirement) r).getOriginalRequirement();
+                SortedSet<BundleCapability> cands = m_candidateMap.get(origReq);
                 if (cands != null)
                 {
                     m_candidateMap.put(r, new TreeSet<BundleCapability>(cands));
+                    for (BundleCapability cand : cands)
+                    {
+                        Set<BundleRequirement> dependents = m_dependentMap.get(cand);
+                        dependents.remove(origReq);
+                        dependents.add(r);
+                    }
                 }
             }
         }

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostedCapability.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostedCapability.java?rev=1147238&r1=1147237&r2=1147238&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostedCapability.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostedCapability.java
Fri Jul 15 16:56:53 2011
@@ -68,7 +68,7 @@ public class HostedCapability extends Bu
         return hash;
     }
 
-    public BundleCapabilityImpl getDeclaredCapability()
+    public BundleCapabilityImpl getOriginalCapability()
     {
         return m_cap;
     }

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostedRequirement.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostedRequirement.java?rev=1147238&r1=1147237&r2=1147238&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostedRequirement.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/HostedRequirement.java
Fri Jul 15 16:56:53 2011
@@ -6,9 +6,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -67,7 +67,7 @@ public class HostedRequirement extends B
         return hash;
     }
 
-    public BundleRequirementImpl getDeclaredRequirement()
+    public BundleRequirementImpl getOriginalRequirement()
     {
         return m_req;
     }

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java?rev=1147238&r1=1147237&r2=1147238&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
Fri Jul 15 16:56:53 2011
@@ -157,7 +157,7 @@ public class ResolverImpl implements Res
                         {
                             faultyRevision =
                                 ((HostedRequirement) rethrow.getRequirement())
-                                    .getDeclaredRequirement().getRevision();
+                                    .getOriginalRequirement().getRevision();
                         }
                         if (optional.remove(faultyRevision))
                         {
@@ -313,7 +313,7 @@ public class ResolverImpl implements Res
                     {
                         faultyRevision =
                             ((HostedRequirement) rethrow.getRequirement())
-                                .getDeclaredRequirement().getRevision();
+                                .getOriginalRequirement().getRevision();
                     }
                     if (revisions.remove(faultyRevision))
                     {
@@ -465,7 +465,7 @@ public class ResolverImpl implements Res
                         {
                             faultyRevision =
                                 ((HostedRequirement) rethrow.getRequirement())
-                                    .getDeclaredRequirement().getRevision();
+                                    .getOriginalRequirement().getRevision();
                         }
                         if (optional.remove(faultyRevision))
                         {
@@ -1503,7 +1503,7 @@ public class ResolverImpl implements Res
     {
         if (c instanceof HostedCapability)
         {
-            return ((HostedCapability) c).getDeclaredCapability();
+            return ((HostedCapability) c).getOriginalCapability();
         }
         return c;
     }
@@ -1512,7 +1512,7 @@ public class ResolverImpl implements Res
     {
         if (r instanceof HostedRequirement)
         {
-            return ((HostedRequirement) r).getDeclaredRequirement();
+            return ((HostedRequirement) r).getOriginalRequirement();
         }
         return r;
     }



Mime
View raw message