felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r374413 - in /incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/searchpolicy: R4SearchPolicyCore.java R4Wire.java
Date Thu, 02 Feb 2006 15:47:30 GMT
Author: rickhall
Date: Thu Feb  2 07:47:22 2006
New Revision: 374413

URL: http://svn.apache.org/viewcvs?rev=374413&view=rev
Log:
Moved some checking code into the wire and out of the search policy core.

Modified:
    incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java
    incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/searchpolicy/R4Wire.java

Modified: incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java?rev=374413&r1=374412&r2=374413&view=diff
==============================================================================
--- incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java
(original)
+++ incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/searchpolicy/R4SearchPolicyCore.java
Thu Feb  2 07:47:22 2006
@@ -308,22 +308,11 @@
         R4Wire[] wires = getWires(module);
         for (int i = 0; (wires != null) && (i < wires.length); i++)
         {
-            // Only check when the package of the class is
-            // the same as the package for the wire.
-            if (wires[i].getExport().getName().equals(pkgName))
-            {
-                // If we find the class, then return it. Otherwise,
-                // throw an exception since the provider of the
-                // package did not have the class.
-                Class clazz = wires[i].getClass(name);
-                if (clazz != null)
-                {
-                    return clazz;
-                }
-                else
-                {
-                    throw new ClassNotFoundException(name);
-                }
+            // If we find the class, then return it.
+            Class clazz = wires[i].getClass(name);
+            if (clazz != null)
+            {
+                return clazz;
             }
         }
 
@@ -434,7 +423,7 @@
         }
 
         // Look in the module's imports.
-        URL url = findImportedResource(module, name, pkgName);
+        URL url = findImportedResource(module, name);
 
         // If not found, try the module's own content.
         if (url == null)
@@ -456,26 +445,18 @@
         return url;
     }
 
-    private URL findImportedResource(IModule module, String name, String pkgName)
+    private URL findImportedResource(IModule module, String name)
         throws ResourceNotFoundException
     {
         // We delegate to the module's wires to find the class.
         R4Wire[] wires = getWires(module);
         for (int i = 0; (wires != null) && (i < wires.length); i++)
         {
-            // Only check when the package of the class is
-            // the same as the package for the wire.
-            if (wires[i].getExport().getName().equals(pkgName))
-            {   
-                URL url = wires[i].getResource(name);
-                if (url != null)
-                {
-                    return url;
-                }
-                else
-                {
-                    throw new ResourceNotFoundException(name);
-                }
+            // If we find the resource, then return it.
+            URL url = wires[i].getResource(name);
+            if (url != null)
+            {
+                return url;
             }
         }
     

Modified: incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/searchpolicy/R4Wire.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/searchpolicy/R4Wire.java?rev=374413&r1=374412&r2=374413&view=diff
==============================================================================
--- incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/searchpolicy/R4Wire.java
(original)
+++ incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/searchpolicy/R4Wire.java
Thu Feb  2 07:47:22 2006
@@ -18,6 +18,7 @@
 
 import java.net.URL;
 
+import org.apache.felix.framework.util.Util;
 import org.apache.felix.moduleloader.*;
 
 public class R4Wire
@@ -48,29 +49,63 @@
         return m_export;
     }
 
-    public Class getClass(String name)
+    public Class getClass(String name) throws ClassNotFoundException
     {
-        // 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)
+        Class clazz = null;
+
+        // Get the package of the target class.
+        String pkgName = Util.getClassPackage(name);
+
+        // Only check when the package of the target class is
+        // the same as the package for the wire.
+        if (m_export.getName().equals(pkgName))
         {
-            if (!m_export.isIncluded(name))
+            // 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_export.isIncluded(name))
             {
-                return null;
+                clazz = m_exporter.getContentLoader().getClass(name);
+            }
+
+            // If no class was found, then we must throw an exception
+            // since the exporter for this package did not contain the
+            // requested class.
+            if (clazz == null)
+            {
+                throw new ClassNotFoundException(name);
             }
         }
 
-        // Since the class is included, delegate to the exporting module.
-        return m_exporter.getContentLoader().getClass(name);
+        return clazz;
     }
 
-    public URL getResource(String name)
+    public URL getResource(String name) throws ResourceNotFoundException
     {
-        return m_exporter.getContentLoader().getResource(name);
+        URL url = null;
+
+        // Get the package of the target class.
+        String pkgName = Util.getResourcePackage(name);
+
+        // Only check when the package of the target resource is
+        // the same as the package for the wire.
+        if (m_export.getName().equals(pkgName))
+        {
+            url = m_exporter.getContentLoader().getResource(name);
+
+            // If no resource was found, then we must throw an exception
+            // since the exporter for this package did not contain the
+            // requested class.
+            if (url == null)
+            {
+                throw new ResourceNotFoundException(name);
+            }
+        }
+
+        return url;
     }
 
     public String toString()



Mime
View raw message