felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r372840 - in /incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework: BundleInfo.java ExportedPackageImpl.java Felix.java ServiceReferenceImpl.java util/ObjectInputStreamX.java
Date Fri, 27 Jan 2006 13:27:05 GMT
Author: rickhall
Date: Fri Jan 27 05:26:52 2006
New Revision: 372840

URL: http://svn.apache.org/viewcvs?rev=372840&view=rev
Log:
These classes were modified to use the new module abstractions provided
by the Module Layer refactoring.

Modified:
    incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/BundleInfo.java
    incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
    incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/Felix.java
    incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/ServiceReferenceImpl.java
    incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/util/ObjectInputStreamX.java

Modified: incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/BundleInfo.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/BundleInfo.java?rev=372840&r1=372839&r2=372840&view=diff
==============================================================================
--- incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/BundleInfo.java
(original)
+++ incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/BundleInfo.java
Fri Jan 27 05:26:52 2006
@@ -1,5 +1,5 @@
 /*
- *   Copyright 2005 The Apache Software Foundation
+ *   Copyright 2006 The Apache Software Foundation
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
  *   you may not use this file except in compliance with the License.
@@ -19,14 +19,14 @@
 import java.util.Map;
 
 import org.apache.felix.framework.cache.BundleArchive;
-import org.apache.felix.moduleloader.Module;
+import org.apache.felix.moduleloader.IModule;
 import org.osgi.framework.*;
 
 class BundleInfo
 {
     private LogWrapper m_logger = null;
     private BundleArchive m_archive = null;
-    private Module[] m_modules = null;
+    private IModule[] m_modules = null;
     private int m_state = 0;
     private long m_modified = 0;
     private BundleActivator m_activator = null;
@@ -39,12 +39,12 @@
     private int m_lockCount = 0;
     private Thread m_lockThread = null;
 
-    protected BundleInfo(LogWrapper logger, BundleArchive archive, Module module)
+    protected BundleInfo(LogWrapper logger, BundleArchive archive, IModule module)
         throws Exception
     {
         m_logger = logger;
         m_archive = archive;
-        m_modules = (module == null) ? new Module[0] : new Module[] { module };
+        m_modules = (module == null) ? new IModule[0] : new IModule[] { module };
 
         m_state = Bundle.INSTALLED;
         m_removalPending = false;
@@ -73,7 +73,7 @@
      * no limit on the potential number of bundle JAR file revisions.
      * @return array of modules corresponding to the bundle JAR file revisions.
     **/
-    public Module[] getModules()
+    public IModule[] getModules()
     {
         return m_modules;
     }
@@ -84,7 +84,7 @@
      * @return <tt>true</tt> if the specified module is in the array of modules
      *         associated with this bundle, <tt>false</tt> otherwise.
     **/
-    public boolean hasModule(Module module)
+    public boolean hasModule(IModule module)
     {
         for (int i = 0; i < m_modules.length; i++)
         {
@@ -101,7 +101,7 @@
      * in the module array.
      * @return the newest module.
     **/
-    public Module getCurrentModule()
+    public IModule getCurrentModule()
     {
         return m_modules[m_modules.length - 1];
     }
@@ -111,9 +111,9 @@
      * the bundle associated with this <tt>BundleInfo</tt> object.
      * @param module the module to add.
     **/
-    public void addModule(Module module)
+    public void addModule(IModule module)
     {
-        Module[] dest = new Module[m_modules.length + 1];
+        IModule[] dest = new IModule[m_modules.length + 1];
         System.arraycopy(m_modules, 0, dest, 0, m_modules.length);
         dest[m_modules.length] = module;
         m_modules = dest;

Modified: incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java?rev=372840&r1=372839&r2=372840&view=diff
==============================================================================
--- incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
(original)
+++ incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/ExportedPackageImpl.java
Fri Jan 27 05:26:52 2006
@@ -1,5 +1,5 @@
 /*
- *   Copyright 2005 The Apache Software Foundation
+ *   Copyright 2006 The Apache Software Foundation
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
  *   you may not use this file except in compliance with the License.
@@ -16,8 +16,8 @@
  */
 package org.apache.felix.framework;
 
-import org.apache.felix.framework.searchpolicy.R4Version;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
 import org.osgi.service.packageadmin.ExportedPackage;
 
 class ExportedPackageImpl implements ExportedPackage
@@ -25,12 +25,12 @@
     private Felix m_felix = null;
     private BundleImpl m_exporter = null;
     private String m_name = null;
-    private R4Version m_version = null;
+    private Version m_version = null;
     private String m_toString = null;
     private String m_versionString = null;
 
     public ExportedPackageImpl(
-        Felix felix, BundleImpl exporter, String name, R4Version version)
+        Felix felix, BundleImpl exporter, String name, Version version)
     {
         m_felix = felix;
         m_exporter = exporter;

Modified: incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/Felix.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/Felix.java?rev=372840&r1=372839&r2=372840&view=diff
==============================================================================
--- incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/Felix.java
(original)
+++ incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/Felix.java
Fri Jan 27 05:26:52 2006
@@ -1,5 +1,5 @@
 /*
- *   Copyright 2005 The Apache Software Foundation
+ *   Copyright 2006 The Apache Software Foundation
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
  *   you may not use this file except in compliance with the License.
@@ -27,8 +27,6 @@
 import org.apache.felix.framework.util.*;
 import org.apache.felix.framework.util.Util;
 import org.apache.felix.moduleloader.*;
-import org.apache.felix.moduleloader.search.ResolveException;
-import org.apache.felix.moduleloader.search.ResolveListener;
 import org.osgi.framework.*;
 import org.osgi.service.packageadmin.ExportedPackage;
 
@@ -41,8 +39,8 @@
     // Configuration properties passed into constructor.
     private MutablePropertyResolver m_configMutable = null;
 
-    // MODULE MANAGER.
-    private ModuleManager m_mgr = null;
+    // MODULE FACTORY.
+    private IModuleFactory m_factory = null;
 
     // Object used as a lock when calculating which bundles
     // when performing an operation on one or more bundles.
@@ -215,7 +213,7 @@
         m_frameworkStatus = STARTING_STATUS;
 
         // Initialize member variables.
-        m_mgr = null;
+        m_factory = null;
         m_configMutable = (configMutable == null)
             ? new MutablePropertyResolverImpl(new StringMap(false)) : configMutable;
         m_activeStartLevel = FelixConstants.FRAMEWORK_INACTIVE_STARTLEVEL;
@@ -272,7 +270,7 @@
         }
 
         // Create search policy for module loader.
-        R4SearchPolicy searchPolicy = new R4SearchPolicy(m_logger);
+        SearchPolicyImpl searchPolicy = new SearchPolicyImpl(m_logger);
 
         // Add a resolver listener to the search policy
         // so that we will be notified when modules are resolved
@@ -331,7 +329,9 @@
             }
         });
 
-        m_mgr = new ModuleManager(searchPolicy, new OSGiURLPolicy(this));
+        m_factory = new ModuleFactoryImpl(
+            searchPolicy,
+            new URLPolicyImpl(new URLHandlersBundleStreamHandler(this)));
 
         // Initialize dispatch queue.
         m_dispatchQueue = new FelixDispatchQueue(m_logger);
@@ -350,12 +350,9 @@
                 m_logger, new SystemBundleArchive(), null);
             systembundle = new SystemBundle(this, info, activatorList);
             systembundle.getInfo().addModule(
-                m_mgr.addModule(
-                    "0", systembundle.getAttributes(),
-                    systembundle.getResourceSources(),
-                    systembundle.getLibrarySources(),
-                    true)); // HACK ALERT! This flag indicates that we will
-                            // use the parent class loader as a resource source.
+                m_factory.createModule(
+                    "0", systembundle.getContentLoader(),
+                    systembundle.getAttributes()));
             m_installedBundleMap.put(
                 systembundle.getInfo().getLocation(), systembundle);
 
@@ -380,7 +377,7 @@
         }
         catch (Exception ex)
         {
-            m_mgr = null;
+            m_factory = null;
             DispatchQueue.shutdown();
             m_logger.log(LogWrapper.LOG_ERROR, "Unable to start system bundle.", ex);
             throw new RuntimeException("Unable to start system bundle.");
@@ -899,9 +896,18 @@
     **/
     protected boolean isBundleClass(Class clazz)
     {
-        if (clazz.getClassLoader() instanceof ModuleClassLoader)
+        if (clazz.getClassLoader() instanceof ContentClassLoader)
         {
-            return ((ModuleClassLoader) clazz.getClassLoader()).isModuleManagerEqual(m_mgr);
+            IContentLoader contentLoader =
+                ((ContentClassLoader) clazz.getClassLoader()).getContentLoader();
+            IModule[] modules = m_factory.getModules();
+            for (int i = 0; i < modules.length; i++)
+            {
+                if (modules[i].getContentLoader() == contentLoader)
+                {
+                    return true;
+                }
+            }
         }
         return false;
     }
@@ -916,13 +922,16 @@
      * @return an input stream to the bundle resource.
      * @throws IOException if the input stream could not be created.
     **/
+/*
+ This might note be needed due to changes in URLHandlersBundleURLConnection
+
     protected InputStream getBundleResourceInputStream(URL url)
         throws IOException
     {
         // The URL is constructed like this:
         // bundle://<module-id>/<source-idx>/<resource-path>
     
-        Module module = m_mgr.getModule(url.getHost());
+        IModule module = m_factory.getModule(url.getHost());
         if (module == null)
         {
             throw new IOException("Unable to find bundle's module.");
@@ -933,38 +942,22 @@
         {
             throw new IOException("Unable to find resource: " + url.toString());
         }
+
+        // Remove any leading slash.
         if (resource.startsWith("/"))
         {
             resource = resource.substring(1);
         }
-        int rsIdx = -1;
-        try
-        {
-            rsIdx = Integer.parseInt(resource.substring(0, resource.indexOf("/")));
-        }
-        catch (NumberFormatException ex)
-        {
-            new IOException("Error parsing resource index.");
-        }
-        resource = resource.substring(resource.indexOf("/") + 1);
 
         // Get the resource bytes from the resource source.
-        byte[] bytes = null;
-        ResourceSource[] resSources = module.getResourceSources();
-        if ((resSources != null) && (rsIdx < resSources.length))
-        {
-            if (resSources[rsIdx].hasResource(resource))
-            {
-                bytes = resSources[rsIdx].getBytes(resource);
-            }
-        }
+        byte[] bytes = module.getContentLoader().getResourceBytes(resource);
         if (bytes == null)
         {
             throw new IOException("Unable to find resource: " + url.toString());
         }
         return new ByteArrayInputStream(bytes);
     }
-
+*/
     //
     // Implementation of Bundle interface methods.
     //
@@ -1006,7 +999,7 @@
         {
             AccessController.checkPermission(m_adminPerm);
         }
-        return bundle.getInfo().getCurrentModule().getClassLoader().getResource(name);
+        return bundle.getInfo().getCurrentModule().getContentLoader().getResource(name);
     }
 
     protected ServiceReference[] getBundleRegisteredServices(BundleImpl bundle)
@@ -1144,18 +1137,20 @@
     **/
     protected Class loadBundleClass(BundleImpl bundle, String name) throws ClassNotFoundException
     {
-        try
-        {
-            return bundle.getInfo().getCurrentModule().getClassLoader().loadClass(name);
-        }
-        catch (ClassNotFoundException ex)
+        Class clazz = bundle.getInfo().getCurrentModule().getContentLoader().getClass(name);
+        if (clazz == null)
         {
+            // Throw exception.
+            ClassNotFoundException ex = new ClassNotFoundException(name);
+
             // The spec says we must fire a framework error.
             fireFrameworkEvent(
                 FrameworkEvent.ERROR, bundle,
                 new BundleException(ex.getMessage()));
+
             throw ex;
         }
+        return clazz;
     }
 
     /**
@@ -1346,9 +1341,9 @@
         }
 
         // Get the import search policy.
-        R4SearchPolicy search = (R4SearchPolicy) m_mgr.getSearchPolicy();
+        SearchPolicyImpl search = (SearchPolicyImpl) m_factory.getSearchPolicy();
 
-        Module module = bundle.getInfo().getCurrentModule();
+        IModule module = bundle.getInfo().getCurrentModule();
         try
         {
             search.resolve(module);
@@ -1457,7 +1452,7 @@
                 // Create a module for the new revision; the revision is
                 // base zero, so subtract one from the revision count to
                 // get the revision of the new update.
-                Module module = createModule(
+                IModule module = createModule(
                     info.getBundleId(),
                     archive.getRevisionCount() - 1,
                     info.getCurrentHeader());
@@ -1875,6 +1870,7 @@
                             "Could not remove from cache.", ex1);
                     }
                 }
+ex.printStackTrace();
                 throw new BundleException("Could not create bundle object.", ex);
             }
 
@@ -2496,8 +2492,8 @@
     {
         // First, find the bundle exporting the package.
         BundleImpl bundle = null;
-        R4SearchPolicy search = (R4SearchPolicy) m_mgr.getSearchPolicy();
-        Module[] exporters = search.getInUseExporters(new R4Package(pkgName, null, null));
+        SearchPolicyImpl search = (SearchPolicyImpl) m_factory.getSearchPolicy();
+        IModule[] exporters = search.getInUseExporters(new ImportImpl(pkgName, null, null));
         if (exporters != null)
         {
             // Since OSGi R4 there may be more than one exporting, so just
@@ -2520,13 +2516,13 @@
             // that the first module found to be exporting the package is the
             // provider of the package, which makes sense since it must have
             // been resolved first.
-            Module[] modules = bundle.getInfo().getModules();
+            IModule[] modules = bundle.getInfo().getModules();
             for (int modIdx = 0; modIdx < modules.length; modIdx++)
             {
-                R4Package pkg = R4SearchPolicy.getExportPackage(modules[modIdx], pkgName);
-                if (pkg != null)
+                IExport export = SearchPolicyImpl.getExportPackage(modules[modIdx], pkgName);
+                if (export != null)
                 {
-                    return new ExportedPackageImpl(this, bundle, pkgName, pkg.getVersionLow());
+                    return new ExportedPackageImpl(this, bundle, pkgName, export.getVersion());
                 }
             }
         }
@@ -2598,26 +2594,36 @@
     **/
     private void getExportedPackages(BundleImpl bundle, List list)
     {
-        R4SearchPolicy policy = (R4SearchPolicy) m_mgr.getSearchPolicy();
+        SearchPolicyImpl policy = (SearchPolicyImpl) m_factory.getSearchPolicy();
 
         // Since a bundle may have many modules associated with it,
         // one for each revision in the cache, search each module
         // for each revision to get all exports.
-        Module[] modules = bundle.getInfo().getModules();
+        IModule[] modules = bundle.getInfo().getModules();
         for (int modIdx = 0; modIdx < modules.length; modIdx++)
         {
-            R4Package[] exports = R4SearchPolicy.getExportsAttr(modules[modIdx]);
+            IExport[] exports = (IExport[])
+                modules[modIdx].getAttribute(
+                        SearchPolicyImpl.EXPORTS_ATTR, new IExport[0]);
             if (exports.length > 0)
             {
                 for (int expIdx = 0; expIdx < exports.length; expIdx++)
                 {
                     // See if the target bundle's module is one of the
                     // "in use" exporters of the package.
-                    Module[] inUseModules = policy.getInUseExporters(exports[expIdx]);
-                    if (R4SearchPolicy.isModuleInArray(inUseModules, modules[modIdx]))
+                    IModule[] inUseModules =
+                        policy.getInUseExporters(
+                            new ImportImpl(exports[expIdx].getName(), null, null));
+                    // Search through the current providers to find the target
+                    // module.
+                    for (int i = 0; (inUseModules != null) && (i < inUseModules.length);
i++)
                     {
-                        list.add(new ExportedPackageImpl(
-                            this, bundle, exports[expIdx].getId(), exports[expIdx].getVersionLow()));
+                        if (inUseModules[i] == modules[modIdx])
+                        {
+                            list.add(new ExportedPackageImpl(
+                                this, bundle, exports[expIdx].getName(),
+                                exports[expIdx].getVersion()));
+                        }
                     }
                 }
             }
@@ -2646,15 +2652,15 @@
             if (exporter != importer)
             {
                 // Check the import wires of all modules for all bundles.
-                Module[] modules = importer.getInfo().getModules();
+                IModule[] modules = importer.getInfo().getModules();
                 for (int modIdx = 0; modIdx < modules.length; modIdx++)
                 {
-                    R4Wire wire = R4SearchPolicy.getWire(modules[modIdx], ep.getName());
+                    IWire wire = SearchPolicyImpl.getWire(modules[modIdx], ep.getName());
     
                     // If the resolving module is associated with the
                     // exporting bundle, then add current bundle to
                     // import list.
-                    if ((wire != null) && exporterInfo.hasModule(wire.m_module))
+                    if ((wire != null) && exporterInfo.hasModule(wire.getExportingModule()))
                     {
                         // Add the bundle to the list of importers.
                         list.add(bundles[bundleIdx]);
@@ -2787,7 +2793,7 @@
         // Create the module for the bundle; although there should only
         // ever be one revision at this point, create the module for
         // the current revision to be safe.
-        Module module = createModule(
+        IModule module = createModule(
             archive.getId(), archive.getRevisionCount() - 1, headerMap);
 
         // Finally, create an return the bundle info.
@@ -2803,7 +2809,7 @@
      * @param headers The headers map associated with the bundle.
      * @return The initialized and/or newly created module.
     **/
-    private Module createModule(long id, int revision, Map headerMap)
+    private IModule createModule(long id, int revision, Map headerMap)
         throws Exception
     {
         // Get the manifest version.
@@ -2814,31 +2820,14 @@
             throw new BundleException("Unknown 'Bundle-ManifestVersion' value: " + version);
         }
 
-        // Create the resource sources for the bundle. The resource sources
-        // are comprised of the bundle's class path values (as JarResourceSources).
-        ResourceSource[] resSources = null;
-        try
-        {
-            // Get bundle class path for the specified revision from cache.
-            String[] classPath = m_cache.getArchive(id).getClassPath(revision);
-
-            // Create resource sources for everything.
-            resSources = new ResourceSource[classPath.length];
-            for (int i = 0; i < classPath.length; i++)
-            {
-                resSources[i] = new JarResourceSource(classPath[i]);
-            }
-        }
-        catch (Exception ex)
-        {
-            ex.printStackTrace();
-            throw new BundleException("Error in class path: " + ex);
-        }
-
         // Get import packages from bundle manifest.
-        R4Package[] imports = R4Package.parseImportOrExportHeader(
+        IPackage[] pkgs = PackageImpl.parseImportOrExportHeader(
             (String) headerMap.get(Constants.IMPORT_PACKAGE));
-
+        IImport[] imports = new IImport[pkgs.length];
+        for (int i = 0; i < pkgs.length; i++)
+        {
+            imports[i] = new ImportImpl(pkgs[i]);
+        }
 
         // Check to make sure that R3 bundles have only specified
         // the 'specification-version' attribute and no directives.
@@ -2866,8 +2855,13 @@
         }
 
         // Get export packages from bundle manifest.
-        R4Package[] exports = R4Package.parseImportOrExportHeader(
+        pkgs = PackageImpl.parseImportOrExportHeader(
             (String) headerMap.get(Constants.EXPORT_PACKAGE));
+        IExport[] exports = new IExport[pkgs.length];
+        for (int i = 0; i < pkgs.length; i++)
+        {
+            exports[i] = new ExportImpl(pkgs[i]);
+        }
 
         // Check to make sure that R3 bundles have only specified
         // the 'specification-version' attribute and no directives.
@@ -2894,9 +2888,12 @@
                 }
             }
             
-            R4Package[] newImports = new R4Package[imports.length + exports.length];
+            IImport[] newImports = new IImport[imports.length + exports.length];
             System.arraycopy(imports, 0, newImports, 0, imports.length);
-            System.arraycopy(exports, 0, newImports, imports.length, exports.length);
+            for (int i = 0; i < exports.length; i++)
+            {
+                newImports[i + imports.length] = new ImportImpl(exports[i]);
+            }
             imports = newImports;
         }
 
@@ -2912,24 +2909,28 @@
             {
                 usesValue = usesValue
                     + ((usesValue.length() > 0) ? "," : "")
-                    + imports[i].getId();
+                    + imports[i].getName();
             }
             R4Directive uses = new R4Directive(
                 FelixConstants.USES_DIRECTIVE, usesValue);
             for (int i = 0; (exports != null) && (i < exports.length); i++)
             {
-                exports[i] = new R4Package(
-                    exports[i].getId(),
+                exports[i] = new ExportImpl(
+                    exports[i].getName(),
                     new R4Directive[] { uses },
                     exports[i].getAttributes());
             }
         }
 
 // TODO: CHECK FOR DUPLICATE IMPORTS/EXPORTS HERE.
-
         // Get dynamic import packages from bundle manifest.
-        R4Package[] dynamics = R4Package.parseImportOrExportHeader(
+        pkgs = PackageImpl.parseImportOrExportHeader(
             (String) headerMap.get(Constants.DYNAMICIMPORT_PACKAGE));
+        IImport[] dynamics = new IImport[pkgs.length];
+        for (int i = 0; i < pkgs.length; i++)
+        {
+            dynamics[i] = new ImportImpl(pkgs[i]);
+        }
 
         // Check to make sure that R3 bundles have no attributes or
         // directives.
@@ -2949,12 +2950,14 @@
         }
 
         Object[][] attributes = {
-            new Object[] { R4SearchPolicy.EXPORTS_ATTR, exports },
-            new Object[] { R4SearchPolicy.IMPORTS_ATTR, imports },
-            new Object[] { R4SearchPolicy.DYNAMICIMPORTS_ATTR, dynamics }
+            new Object[] { SearchPolicyImpl.EXPORTS_ATTR, exports },
+            new Object[] { SearchPolicyImpl.IMPORTS_ATTR, imports },
+            new Object[] { SearchPolicyImpl.DYNAMICIMPORTS_ATTR, dynamics }
         };
 
         // Get native library entry names for module library sources.
+// TODO: FIX NATIVE LIBRARIES.
+/*
         LibraryInfo[] libraries =
             Util.parseLibraryStrings(
                 Util.parseDelimitedString(
@@ -2966,13 +2969,15 @@
                 getProperty(Constants.FRAMEWORK_PROCESSOR),
                 libraries)
         };
-
-        Module module =
-            m_mgr.addModule(
-                Long.toString(id) + "." + Integer.toString(revision),
-                attributes, resSources, libSources);
-
-        return module;
+*/
+        // Get the content loader associated with the module archive.
+        IContentLoader contentLoader =
+            m_cache.getArchive(id).getContentLoader(revision);
+
+        // Finally, create the module and return it.
+        return m_factory.createModule(
+            Long.toString(id) + "." + Integer.toString(revision),
+            contentLoader, attributes);
     }
 
     private BundleActivator createBundleActivator(BundleInfo info)
@@ -2992,7 +2997,7 @@
             {
                 activator =
                     m_cache.getArchive(info.getBundleId())
-                        .getActivator(info.getCurrentModule().getClassLoader());
+                        .getActivator(info.getCurrentModule().getContentLoader());
             }
             catch (Exception ex)
             {
@@ -3016,7 +3021,7 @@
             if (className != null)
             {
                 className = className.trim();
-                Class clazz = info.getCurrentModule().getClassLoader().loadClass(className);
+                Class clazz = info.getCurrentModule().getContentLoader().getClass(className);
                 if (clazz == null)
                 {
                     throw new BundleException("Not found: "
@@ -3049,10 +3054,20 @@
             // way to do this is to remove the bundle, but that
             // would be incorrect, because this is a refresh operation
             // and should not trigger bundle REMOVE events.
-            Module[] modules = info.getModules();
+            IModule[] modules = info.getModules();
             for (int i = 0; i < modules.length; i++)
             {
-                m_mgr.removeModule(modules[i]);
+                m_factory.removeModule(modules[i]);
+// TODO: FIX - DETERMINE IF CLOSING SHOULD BE PART OF MODULE FACTORY.
+                // Close module content for disposal.
+                modules[i].getContentLoader().getContent().close();
+                // Close module class path content for disposal.
+                IContent[] classPath =
+                    ((ContentLoaderImpl) modules[i].getContentLoader()).getClassPath();
+                for (int pathIdx = 0; pathIdx < classPath.length; pathIdx++)
+                {
+                    classPath[pathIdx].close();
+                }
             }
 
             // Purge all bundle revisions, but the current one.
@@ -3073,10 +3088,20 @@
 
         // Remove the bundle's associated modules from
         // the module manager.
-        Module[] modules = bundle.getInfo().getModules();
+        IModule[] modules = bundle.getInfo().getModules();
         for (int i = 0; i < modules.length; i++)
         {
-            m_mgr.removeModule(modules[i]);
+            m_factory.removeModule(modules[i]);
+// TODO: FIX - DETERMINE IF CLOSING SHOULD BE PART OF MODULE FACTORY.
+            // Close module content for disposal.
+            modules[i].getContentLoader().getContent().close();
+            // Close module class path content for disposal.
+            IContent[] classPath =
+                ((ContentLoaderImpl) modules[i].getContentLoader()).getClassPath();
+            for (int pathIdx = 0; pathIdx < classPath.length; pathIdx++)
+            {
+                classPath[pathIdx].close();
+            }
         }
 
         // Remove the bundle from the cache.
@@ -3783,4 +3808,4 @@
             m_bundleLock.notifyAll();
         }
     }
-}
\ No newline at end of file
+}

Modified: incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/ServiceReferenceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/ServiceReferenceImpl.java?rev=372840&r1=372839&r2=372840&view=diff
==============================================================================
--- incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/ServiceReferenceImpl.java
(original)
+++ incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/ServiceReferenceImpl.java
Fri Jan 27 05:26:52 2006
@@ -1,5 +1,5 @@
 /*
- *   Copyright 2005 The Apache Software Foundation
+ *   Copyright 2006 The Apache Software Foundation
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
  *   you may not use this file except in compliance with the License.
@@ -16,8 +16,8 @@
  */
 package org.apache.felix.framework;
 
-import org.apache.felix.framework.searchpolicy.R4SearchPolicy;
-import org.apache.felix.framework.searchpolicy.R4Wire;
+import org.apache.felix.framework.searchpolicy.SearchPolicyImpl;
+import org.apache.felix.moduleloader.IWire;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceReference;
 
@@ -119,9 +119,9 @@
         String pkgName =
             org.apache.felix.moduleloader.Util.getClassPackage(className);
         // Get package wiring from service provider and requester.
-        R4Wire requesterWire = R4SearchPolicy.getWire(
+        IWire requesterWire = SearchPolicyImpl.getWire(
             ((BundleImpl) requester).getInfo().getCurrentModule(), pkgName);
-        R4Wire providerWire = R4SearchPolicy.getWire(
+        IWire providerWire = SearchPolicyImpl.getWire(
             ((BundleImpl) m_bundle).getInfo().getCurrentModule(), pkgName);
 
         // There are three situations that may occur here:
@@ -151,8 +151,8 @@
             {
                 // Load the class from the requesting bundle.
                 Class requestClass =
-                    ((BundleImpl) requester).getInfo().getCurrentModule().getClassLoader()
-                        .loadClass(className);
+                    ((BundleImpl) requester).getInfo().getCurrentModule().getContentLoader()
+                        .getClass(className);
                 // Get the service registration and ask it to check
                 // if the service object is assignable to the requesting
                 // bundle's class.
@@ -168,7 +168,7 @@
         // same source module.
         else
         {
-            allow = providerWire.m_module.equals(requesterWire.m_module);
+            allow = providerWire.getExportingModule().equals(requesterWire.getExportingModule());
         }
 
         return allow;

Modified: incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/util/ObjectInputStreamX.java
URL: http://svn.apache.org/viewcvs/incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/util/ObjectInputStreamX.java?rev=372840&r1=372839&r2=372840&view=diff
==============================================================================
--- incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/util/ObjectInputStreamX.java
(original)
+++ incubator/felix/sandbox/rickhall/framework-branch/src/main/java/org/apache/felix/framework/util/ObjectInputStreamX.java
Fri Jan 27 05:26:52 2006
@@ -1,5 +1,5 @@
 /*
- *   Copyright 2005 The Apache Software Foundation
+ *   Copyright 2006 The Apache Software Foundation
  *
  *   Licensed under the Apache License, Version 2.0 (the "License");
  *   you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@
 
 import java.io.*;
 
+import org.apache.felix.moduleloader.IContentLoader;
+
 /**
  * The ObjectInputStreamX class is a simple extension to the ObjectInputStream
  * class.  The purpose of ObjectInputStreamX is to allow objects to be deserialized
@@ -25,7 +27,7 @@
  */
 public class ObjectInputStreamX extends ObjectInputStream
 {
-    private ClassLoader m_loader = null;
+    private IContentLoader m_contentLoader = null;
 
     /**
      * Construct an ObjectInputStreamX for the specified InputStream and the specified
@@ -33,11 +35,11 @@
      * @param in the input stream to read.
      * @param loader the class loader used to resolve classes.
      */
-    public ObjectInputStreamX(InputStream in, ClassLoader loader)
+    public ObjectInputStreamX(InputStream in, IContentLoader contentLoader)
         throws IOException, StreamCorruptedException
     {
         super(in);
-        this.m_loader = loader;
+        m_contentLoader = contentLoader;
     }
 
     /**
@@ -47,7 +49,6 @@
     protected Class resolveClass(ObjectStreamClass v)
         throws IOException, ClassNotFoundException
     {
-        Class clazz = m_loader.loadClass(v.getName());
-        return clazz;
+        return m_contentLoader.getClass(v.getName());
     }
 }



Mime
View raw message