Some class loading related functionality was done incorrectly during the
Module Loader refactoring. These methods were loading classes only from
the module content when they should be loading from the imports as well.


git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@377666 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/Felix.java b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/Felix.java
index 8ae2895..57b3f8d 100644
--- a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -1188,7 +1188,7 @@
     **/
     protected Class loadBundleClass(BundleImpl bundle, String name) throws ClassNotFoundException
     {
-        Class clazz = bundle.getInfo().getCurrentModule().getContentLoader().getClass(name);
+        Class clazz = bundle.getInfo().getCurrentModule().getClass(name);
         if (clazz == null)
         {
             // Throw exception.
@@ -3077,7 +3077,7 @@
             {
                 activator =
                     m_cache.getArchive(info.getBundleId())
-                        .getActivator(info.getCurrentModule().getContentLoader());
+                        .getActivator(info.getCurrentModule());
             }
             catch (Exception ex)
             {
diff --git a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/ServiceReferenceImpl.java b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/ServiceReferenceImpl.java
index 3b4eb7c..76814db 100644
--- a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/ServiceReferenceImpl.java
+++ b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/ServiceReferenceImpl.java
@@ -152,8 +152,7 @@
             {
                 // Load the class from the requesting bundle.
                 Class requestClass =
-                    ((BundleImpl) requester).getInfo().getCurrentModule().getContentLoader()
-                        .getClass(className);
+                    ((BundleImpl) requester).getInfo().getCurrentModule().getClass(className);
                 // Get the service registration and ask it to check
                 // if the service object is assignable to the requesting
                 // bundle's class.
diff --git a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/SystemBundleArchive.java b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/SystemBundleArchive.java
index 0547655..58104c6 100644
--- a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/SystemBundleArchive.java
+++ b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/SystemBundleArchive.java
@@ -22,7 +22,7 @@
 import org.apache.felix.framework.cache.BundleArchive;
 import org.apache.felix.framework.util.FelixConstants;
 import org.apache.felix.moduleloader.IContent;
-import org.apache.felix.moduleloader.IContentLoader;
+import org.apache.felix.moduleloader.IModule;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleActivator;
 
@@ -69,7 +69,7 @@
         return null;
     }
 
-    public BundleActivator getActivator(IContentLoader contentLoader)
+    public BundleActivator getActivator(IModule module)
         throws Exception
     {
         return null;
diff --git a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/BundleArchive.java b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/BundleArchive.java
index b0f6aec..cc032ce 100644
--- a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/BundleArchive.java
+++ b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/BundleArchive.java
@@ -20,7 +20,7 @@
 import java.util.Map;
 
 import org.apache.felix.moduleloader.IContent;
-import org.apache.felix.moduleloader.IContentLoader;
+import org.apache.felix.moduleloader.IModule;
 import org.osgi.framework.BundleActivator;
 
 /**
@@ -113,13 +113,13 @@
      * this archive; this is a non-standard OSGi method that is only called
      * when Felix is running in non-strict OSGi mode.
      * </p>
-     * @param loader the class loader to use when trying to instantiate
+     * @param module the module to use when trying to instantiate
      *        the bundle activator.
      * @return the persistent bundle activator of the bundle associated with
      *         this archive.
      * @throws java.lang.Exception if any error occurs.
     **/
-    public BundleActivator getActivator(IContentLoader contentLoader)
+    public BundleActivator getActivator(IModule module)
         throws Exception;
 
     /**
diff --git a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/DefaultBundleArchive.java b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/DefaultBundleArchive.java
index e2a162d..fade8a1 100644
--- a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/DefaultBundleArchive.java
+++ b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/cache/DefaultBundleArchive.java
@@ -522,7 +522,7 @@
         }
     }
 
-    public BundleActivator getActivator(IContentLoader contentLoader)
+    public BundleActivator getActivator(IModule module)
         throws Exception
     {
         if (System.getSecurityManager() != null)
@@ -531,7 +531,7 @@
             {
                 return (BundleActivator) AccessController.doPrivileged(
                     new PrivilegedAction(
-                        PrivilegedAction.GET_ACTIVATOR_ACTION, this, contentLoader));
+                        PrivilegedAction.GET_ACTIVATOR_ACTION, this, module));
             }
             catch (PrivilegedActionException ex)
             {
@@ -540,11 +540,11 @@
         }
         else
         {
-            return getActivatorUnchecked(contentLoader);
+            return getActivatorUnchecked(module);
         }
     }
 
-    private BundleActivator getActivatorUnchecked(IContentLoader contentLoader)
+    private BundleActivator getActivatorUnchecked(IModule module)
         throws Exception
     {
         // Get bundle activator file.
@@ -560,7 +560,7 @@
         try
         {
             is = new FileInputStream(activatorFile);
-            ois = new ObjectInputStreamX(is, contentLoader);
+            ois = new ObjectInputStreamX(is, module);
             Object o = ois.readObject();
             return (BundleActivator) o;
         }
@@ -1430,7 +1430,7 @@
         private InputStream m_isArg = null;
         private int m_intArg = 0;
         private File m_fileArg = null;
-        private IContentLoader m_contentLoaderArg = null;
+        private IModule m_moduleArg = null;
         private Object m_objArg = null;
 
         public PrivilegedAction(int action, DefaultBundleArchive archive)
@@ -1460,11 +1460,11 @@
             m_fileArg = fileArg;
         }
 
-        public PrivilegedAction(int action, DefaultBundleArchive archive, IContentLoader contentLoaderArg)
+        public PrivilegedAction(int action, DefaultBundleArchive archive, IModule moduleArg)
         {
             m_action = action;
             m_archive = archive;
-            m_contentLoaderArg = contentLoaderArg;
+            m_moduleArg = moduleArg;
         }
 
         public PrivilegedAction(int action, DefaultBundleArchive archive, Object objArg)
@@ -1514,7 +1514,7 @@
                 case GET_CONTENT_PATH_ACTION:
                     return m_archive.getContentPathUnchecked(m_intArg);
                 case GET_ACTIVATOR_ACTION:
-                    return m_archive.getActivatorUnchecked(m_contentLoaderArg);
+                    return m_archive.getActivatorUnchecked(m_moduleArg);
                 case SET_ACTIVATOR_ACTION:
                     m_archive.setActivatorUnchecked(m_objArg);
                     return null;
diff --git a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/ContentClassLoader.java b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/ContentClassLoader.java
index 5486312..d2c5c0c 100644
--- a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/ContentClassLoader.java
+++ b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/searchpolicy/ContentClassLoader.java
@@ -41,7 +41,7 @@
         return m_contentLoader;
     }
 
-    public Class loadClassFromModule(String name)
+    protected Class loadClassFromModule(String name)
         throws ClassNotFoundException
     {
         // Ask the search policy for the clas before consulting the module.
diff --git a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/ObjectInputStreamX.java b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/ObjectInputStreamX.java
index e30b47c..b5a6f44 100644
--- a/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/ObjectInputStreamX.java
+++ b/org.apache.felix.framework/src/main/java/org/apache/felix/framework/util/ObjectInputStreamX.java
@@ -18,7 +18,7 @@
 
 import java.io.*;
 
-import org.apache.felix.moduleloader.IContentLoader;
+import org.apache.felix.moduleloader.IModule;
 
 /**
  * The ObjectInputStreamX class is a simple extension to the ObjectInputStream
@@ -27,7 +27,7 @@
  */
 public class ObjectInputStreamX extends ObjectInputStream
 {
-    private IContentLoader m_contentLoader = null;
+    private IModule m_module = null;
 
     /**
      * Construct an ObjectInputStreamX for the specified InputStream and the specified
@@ -35,11 +35,11 @@
      * @param in the input stream to read.
      * @param loader the class loader used to resolve classes.
      */
-    public ObjectInputStreamX(InputStream in, IContentLoader contentLoader)
+    public ObjectInputStreamX(InputStream in, IModule module)
         throws IOException, StreamCorruptedException
     {
         super(in);
-        m_contentLoader = contentLoader;
+        m_module = module;
     }
 
     /**
@@ -49,6 +49,6 @@
     protected Class resolveClass(ObjectStreamClass v)
         throws IOException, ClassNotFoundException
     {
-        return m_contentLoader.getClass(v.getName());
+        return m_module.getClass(v.getName());
     }
 }
\ No newline at end of file