You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2010/07/21 16:27:21 UTC

svn commit: r966242 - /felix/trunk/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java

Author: rickhall
Date: Wed Jul 21 14:27:20 2010
New Revision: 966242

URL: http://svn.apache.org/viewvc?rev=966242&view=rev
Log:
Required bundles that imported their own exports were not correctly exposing
their exported packages to requiring bundles. (FELIX-2479)

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

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=966242&r1=966241&r2=966242&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 Wed Jul 21 14:27:20 2010
@@ -599,7 +599,7 @@ public class ResolverImpl implements Res
         }
 
         // First, add all exported packages to our package space.
-        calculateExportedPackages(module, modulePkgMap);
+        calculateExportedPackages(module, modulePkgMap, candidateMap);
         Packages modulePkgs = modulePkgMap.get(module);
 
         // Second, add all imported packages to our candidate space.
@@ -607,7 +607,7 @@ public class ResolverImpl implements Res
         {
             Requirement req = reqs.get(i);
             Capability cap = caps.get(i);
-            calculateExportedPackages(cap.getModule(), modulePkgMap);
+            calculateExportedPackages(cap.getModule(), modulePkgMap, candidateMap);
             mergeCandidatePackages(module, req, cap, modulePkgMap, candidateMap);
             addCapabilityDependency(cap, req, capDepSet);
         }
@@ -674,7 +674,7 @@ public class ResolverImpl implements Res
         else if (candCap.getNamespace().equals(Capability.MODULE_NAMESPACE))
         {
 // TODO: FELIX3 - THIS NEXT LINE IS A HACK. IMPROVE HOW/WHEN WE CALCULATE EXPORTS.
-            calculateExportedPackages(candCap.getModule(), modulePkgMap);
+            calculateExportedPackages(candCap.getModule(), modulePkgMap, candidateMap);
 
             // Get the candidate's package space to determine which packages
             // will be visible to the current module.
@@ -1110,7 +1110,8 @@ public class ResolverImpl implements Res
     }
 
     private static void calculateExportedPackages(
-        Module module, Map<Module, Packages> modulePkgMap)
+        Module module, Map<Module, Packages> modulePkgMap,
+        Map<Requirement, Set<Capability>> candidateMap)
     {
         Packages packages = modulePkgMap.get(module);
         if (packages != null)
@@ -1123,6 +1124,7 @@ public class ResolverImpl implements Res
 
         if (caps.size() > 0)
         {
+            // Grab all exported packages that are not also imported.
             for (int i = 0; i < caps.size(); i++)
             {
 // TODO: FELIX3 - Assume if a module imports the same package it
@@ -1135,6 +1137,24 @@ public class ResolverImpl implements Res
                         new Blame(caps.get(i), null));
                 }
             }
+            // Grab all imported packages for which the module imports from itself.
+            for (Requirement req : module.getRequirements())
+            {
+                if (req.getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+                {
+                    Set<Capability> cands = candidateMap.get(req);
+                    if ((cands != null) && (cands.size() > 0))
+                    {
+                        Capability cand = cands.iterator().next();
+                        if (cand.getModule().equals(module))
+                        {
+                            packages.m_exportedPkgs.put(
+                                (String) cand.getAttribute(Capability.PACKAGE_ATTR).getValue(),
+                                new Blame(cand, null));
+                        }
+                    }
+                }
+            }
         }
 
         modulePkgMap.put(module, packages);
@@ -1434,22 +1454,16 @@ public class ResolverImpl implements Res
         {
         }
 
-        public Packages(Packages packages)
-        {
-            m_exportedPkgs.putAll(packages.m_exportedPkgs);
-            m_importedPkgs.putAll(packages.m_importedPkgs);
-            m_requiredPkgs.putAll(packages.m_requiredPkgs);
-            m_usedPkgs.putAll(packages.m_usedPkgs);
-        }
-
         public List<String> getExportedAndReexportedPackages()
         {
             List<String> pkgs = new ArrayList();
+            // Grab all exported packages.
             for (Entry<String, Blame> entry : m_exportedPkgs.entrySet())
             {
                 pkgs.add((String)
                     entry.getValue().m_cap.getAttribute(Capability.PACKAGE_ATTR).getValue());
             }
+            // Grab all required and reexported required packages.
             for (Entry<String, List<Blame>> entry : m_requiredPkgs.entrySet())
             {
                 for (Blame blame : entry.getValue())