Author: rickhall
Date: Mon Sep 15 14:09:27 2008
New Revision: 695629

URL: http://svn.apache.org/viewvc?rev=695629&view=rev
Log:
The class loader delegation in wires was not correctly working when a module
imported a packaged that was an aggregated (via require-bundle) export from
another bundle. The wire for the package should have been delegating to the
module and instead it was delegating directly to the module content, which
did not account for the wires of the aggregated split package. (FELIX-722)

Modified:
    
felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4Wire.java

Modified: 
felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4Wire.java
URL: 
http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4Wire.java?rev=695629&r1=695628&r2=695629&view=diff
==============================================================================
--- 
felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4Wire.java
 (original)
+++ 
felix/trunk/framework/src/main/java/org/apache/felix/framework/searchpolicy/R4Wire.java
 Mon Sep 15 14:09:27 2008
@@ -97,18 +97,24 @@
         if (m_capability.getNamespace().equals(ICapability.PACKAGE_NAMESPACE) 
&&
             
m_capability.getProperties().get(ICapability.PACKAGE_PROPERTY).equals(pkgName))
         {
-            // Before delegating to the exporting module to satisfy
-            // the class load, we must check the include/exclude filters
-            // from the target package to make sure that the class is
-            // actually visible. However, if the exporting module is the
-            // same as the requesting module, then filtering is not
-            // performed since a module has complete access to itself.
-            if ((m_exporter == m_importer) ||
-                
(m_capability.getNamespace().equals(ICapability.PACKAGE_NAMESPACE) &&
-                    ((Capability) m_capability).isIncluded(name)))
+            // If the importer and the exporter are the same, then
+            // just ask for the class from the exporting module's
+            // content directly.
+            if (m_exporter == m_importer)
             {
                 clazz = m_exporter.getContentLoader().getClass(name);
             }
+            // Otherwise, check the include/exclude filters from the target
+            // package to make sure that the class is actually visible. In
+            // this case since the importing and exporting modules are 
different,
+            // we delegate to the exporting module, rather than its content,
+            // so that it can follow any internal wires it may have (e.g.,
+            // if the package has multiple sources).
+            else if 
(m_capability.getNamespace().equals(ICapability.PACKAGE_NAMESPACE)
+                && ((Capability) m_capability).isIncluded(name))
+            {
+                clazz = m_exporter.getClass(name);
+            }
 
             // If no class was found, then we must throw an exception
             // since the exporter for this package did not contain the
@@ -137,7 +143,20 @@
         if (m_capability.getNamespace().equals(ICapability.PACKAGE_NAMESPACE) 
&&
             
m_capability.getProperties().get(ICapability.PACKAGE_PROPERTY).equals(pkgName))
         {
-            url = m_exporter.getContentLoader().getResource(name);
+            // If the importer and the exporter are the same, then
+            // just ask for the resource from the exporting module's
+            // content directly.
+            if (m_exporter == m_importer)
+            {
+                url = m_exporter.getContentLoader().getResource(name);
+            }
+            // Otherwise, delegate to the exporting module, rather than its
+            // content, so that it can follow any internal wires it may have
+            // (e.g., if the package has multiple sources).
+            else
+            {
+                url = m_exporter.getResource(name);
+            }
 
             // If no resource was found, then we must throw an exception
             // since the exporter for this package did not contain the


Reply via email to