felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r955035 - in /felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework: ./ ext/ resolver/ util/
Date Tue, 15 Jun 2010 20:16:26 GMT
Author: rickhall
Date: Tue Jun 15 20:16:26 2010
New Revision: 955035

URL: http://svn.apache.org/viewvc?rev=955035&view=rev
Log:
Merge branch 'vb'

Added:
    felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/WireBootImpl.java
Modified:
    felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/AbstractModuleImpl.java
    felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/BundleImpl.java
    felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/Felix.java
    felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/FelixResolverState.java
    felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/ModuleImpl.java
    felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/UnmanagedModuleImpl.java
    felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/ext/VirtualModule.java
    felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/resolver/Module.java
    felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/util/FelixConstants.java

Modified: felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/AbstractModuleImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/AbstractModuleImpl.java?rev=955035&r1=955034&r2=955035&view=diff
==============================================================================
--- felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/AbstractModuleImpl.java
(original)
+++ felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/AbstractModuleImpl.java
Tue Jun 15 20:16:26 2010
@@ -20,8 +20,10 @@ package org.apache.felix.framework;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.Constructor;
 import java.net.URL;
 import java.security.ProtectionDomain;
+import java.security.SecureClassLoader;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.List;
@@ -40,6 +42,7 @@ import org.apache.felix.framework.util.m
 import org.apache.felix.framework.util.manifestparser.R4Library;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
 
 abstract class AbstractModuleImpl implements Module
@@ -74,8 +77,39 @@ abstract class AbstractModuleImpl implem
     private ProtectionDomain m_protectionDomain = null;
     static SecureAction m_secureAction = new SecureAction();
 
+
+    // Default class loader for boot delegation.
+    final static ClassLoader m_bootClassLoader;
+
+    // Statically define the default class loader for boot delegation.
+    static
+    {
+        ClassLoader cl = null;
+        try
+        {
+            Constructor ctor = m_secureAction.getDeclaredConstructor(
+                SecureClassLoader.class, new Class[] { ClassLoader.class });
+            m_secureAction.setAccesssible(ctor);
+            cl = (ClassLoader) m_secureAction.invoke(ctor, new Object[] { null });
+        }
+        catch (Throwable ex)
+        {
+            // On Android we get an exception if we set the parent class loader
+            // to null, so we will work around that case by setting the parent
+            // class loader to the system class loader in getClassLoader() below.
+            cl = null;
+            System.err.println("Problem creating boot delegation class loader: " + ex);
+        }
+        m_bootClassLoader = cl;
+    }
+
+    // Boot delegation packages.
+    final String[] m_bootPkgs;
+    final boolean[] m_bootPkgWildcards;
+
     public AbstractModuleImpl(
-        Logger logger, Map config, Bundle bundle, String id, Map headerMap)
+        Logger logger, Map config, Bundle bundle, String id, Map headerMap,
+        String[] bootPkgs, boolean[] bootPkgWildcards)
         throws BundleException
     {
         m_logger = logger;
@@ -83,6 +117,8 @@ abstract class AbstractModuleImpl implem
         m_bundle = bundle;
         m_id = id;
         m_headerMap = headerMap;
+        m_bootPkgs = bootPkgs;
+        m_bootPkgWildcards = bootPkgWildcards;
 
         ManifestParser mp = new ManifestParser(m_logger, m_config, this, m_headerMap);
 
@@ -199,7 +235,7 @@ abstract class AbstractModuleImpl implem
         return m_wires;
     }
 
-    public synchronized void resolve(List<VBWire> wires)
+    public synchronized void resolve(VBWire bootWire, List<VBWire> wires)
         throws BundleException
     {
         // Remove module from old wire modules' dependencies,
@@ -207,13 +243,17 @@ abstract class AbstractModuleImpl implem
         // from the old wires.
         for (int i = 0; (m_wires != null) && (i < m_wires.size()); i++)
         {
-            if (((Wire) m_wires.get(i)).getCapability().getNamespace().equals(Capability.MODULE_NAMESPACE))
+            if (((Wire) m_wires.get(i)).getCapability().getNamespace()
+                .equals(Capability.MODULE_NAMESPACE))
             {
-                ((AbstractModuleImpl) ((Wire) m_wires.get(i)).getExporter()).removeDependentRequirer(this);
+                ((AbstractModuleImpl) ((Wire) m_wires.get(i)).getExporter())
+                    .removeDependentRequirer(this);
             }
-            else if (((Wire) m_wires.get(i)).getCapability().getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+            else if (((Wire) m_wires.get(i)).getCapability().getNamespace()
+                .equals(Capability.PACKAGE_NAMESPACE))
             {
-                ((AbstractModuleImpl) ((Wire) m_wires.get(i)).getExporter()).removeDependentImporter(this);
+                ((AbstractModuleImpl) ((Wire) m_wires.get(i)).getExporter())
+                    .removeDependentImporter(this);
             }
         }
 
@@ -222,13 +262,17 @@ abstract class AbstractModuleImpl implem
         // Add ourself as a dependent to the new wires' modules.
         for (int i = 0; (m_wires != null) && (i < m_wires.size()); i++)
         {
-            if (((Wire) m_wires.get(i)).getCapability().getNamespace().equals(Capability.MODULE_NAMESPACE))
+            if (((Wire) m_wires.get(i)).getCapability().getNamespace()
+                .equals(Capability.MODULE_NAMESPACE))
             {
-                ((AbstractModuleImpl) ((Wire) m_wires.get(i)).getExporter()).addDependentRequirer(this);
+                ((AbstractModuleImpl) ((Wire) m_wires.get(i)).getExporter())
+                    .addDependentRequirer(this);
             }
-            else if (((Wire) m_wires.get(i)).getCapability().getNamespace().equals(Capability.PACKAGE_NAMESPACE))
+            else if (((Wire) m_wires.get(i)).getCapability().getNamespace()
+                .equals(Capability.PACKAGE_NAMESPACE))
             {
-                ((AbstractModuleImpl) ((Wire) m_wires.get(i)).getExporter()).addDependentImporter(this);
+                ((AbstractModuleImpl) ((Wire) m_wires.get(i)).getExporter())
+                    .addDependentImporter(this);
             }
         }
     }
@@ -370,6 +414,40 @@ abstract class AbstractModuleImpl implem
 
     public abstract InputStream getInputStream(int index, String urlPath) throws IOException;
 
+    ClassLoader determineParentClassLoader()
+    {
+        // Determine the class loader's parent based on the
+        // configuration property; use boot class loader by
+        // default.
+        String cfg = (String) getConfig().get(Constants.FRAMEWORK_BUNDLE_PARENT);
+        cfg = (cfg == null) ? Constants.FRAMEWORK_BUNDLE_PARENT_BOOT : cfg;
+        final ClassLoader parent;
+        if (cfg.equalsIgnoreCase(Constants.FRAMEWORK_BUNDLE_PARENT_APP))
+        {
+            parent = m_secureAction.getSystemClassLoader();
+        }
+        else if (cfg.equalsIgnoreCase(Constants.FRAMEWORK_BUNDLE_PARENT_EXT))
+        {
+            parent = m_secureAction.getSystemClassLoader().getParent();
+        }
+        else if (cfg.equalsIgnoreCase(Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK))
+        {
+            parent = ModuleImpl.class.getClassLoader();
+        }
+        // On Android we cannot set the parent class loader to be null, so
+        // we special case that situation here and set it to the system
+        // class loader by default instead, which is not really spec.
+        else if (m_bootClassLoader == null)
+        {
+            parent = m_secureAction.getSystemClassLoader();
+        }
+        else
+        {
+            parent = null;
+        }
+        return parent;
+    }
+
     static class FragmentRequirement implements Requirement
     {
         private final Module m_owner;

Modified: felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/BundleImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/BundleImpl.java?rev=955035&r1=955034&r2=955035&view=diff
==============================================================================
--- felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/BundleImpl.java
(original)
+++ felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/BundleImpl.java
Tue Jun 15 20:16:26 2010
@@ -1140,6 +1140,8 @@ class BundleImpl implements Bundle
                 this,
                 Long.toString(getBundleId()) + "." + Integer.toString(revision),
                 headers,
+                getFramework().getBootPackages(),
+                getFramework().getBootPackageWildcards(),
                 vm);
         }
         else

Modified: felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/Felix.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/Felix.java?rev=955035&r1=955034&r2=955035&view=diff
==============================================================================
--- felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/Felix.java
(original)
+++ felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/Felix.java
Tue Jun 15 20:16:26 2010
@@ -4290,7 +4290,7 @@ ex.printStackTrace();
                                 wires = new ArrayList<VBWire>(wires.size() + 1);
                                 wires.addAll(module.getWires());
                                 wires.add(candidateWire);
-                                ((AbstractModuleImpl) module).resolve(wires);
+                                ((AbstractModuleImpl) module).resolve(null, wires);
 m_logger.log(Logger.LOG_DEBUG, "DYNAMIC WIRE: " + wires.get(wires.size() - 1));
                             }
                         }
@@ -4400,7 +4400,7 @@ m_logger.log(Logger.LOG_DEBUG, "DYNAMIC 
                     }
 // TODO: VB - How to properly handle this generic crap?
                     List<VBWire> vbWires = new ArrayList<VBWire>(wires);
-                    module.resolve(vbWires);
+                    module.resolve(null, vbWires);
 
                     // Resolve all attached fragments.
                     if (module instanceof ModuleImpl)

Modified: felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/FelixResolverState.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/FelixResolverState.java?rev=955035&r1=955034&r2=955035&view=diff
==============================================================================
--- felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/FelixResolverState.java
(original)
+++ felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/FelixResolverState.java
Tue Jun 15 20:16:26 2010
@@ -550,7 +550,7 @@ public class FelixResolverState implemen
         // of its dependent modules.
         try
         {
-            ((AbstractModuleImpl) host).resolve(null);
+            ((AbstractModuleImpl) host).resolve(null, null);
         }
         catch (BundleException ex)
         {

Modified: felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/ModuleImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/ModuleImpl.java?rev=955035&r1=955034&r2=955035&view=diff
==============================================================================
--- felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/ModuleImpl.java
(original)
+++ felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/ModuleImpl.java
Tue Jun 15 20:16:26 2010
@@ -87,37 +87,6 @@ public class ModuleImpl extends Abstract
     private List<Requirement> m_cachedRequirements = null;
     private List<Requirement> m_cachedDynamicRequirements = null;
 
-    // Bundle-specific class loader for boot delegation.
-    private final ClassLoader m_bootClassLoader;
-    // Default class loader for boot delegation.
-    private final static ClassLoader m_defBootClassLoader;
-
-    // Statically define the default class loader for boot delegation.
-    static
-    {
-        ClassLoader cl = null;
-        try
-        {
-            Constructor ctor = m_secureAction.getDeclaredConstructor(
-                SecureClassLoader.class, new Class[] { ClassLoader.class });
-            m_secureAction.setAccesssible(ctor);
-            cl = (ClassLoader) m_secureAction.invoke(ctor, new Object[] { null });
-        }
-        catch (Throwable ex)
-        {
-            // On Android we get an exception if we set the parent class loader
-            // to null, so we will work around that case by setting the parent
-            // class loader to the system class loader in getClassLoader() below.
-            cl = null;
-            System.err.println("Problem creating boot delegation class loader: " + ex);
-        }
-        m_defBootClassLoader = cl;
-    }
-
-    // Boot delegation packages.
-    private final String[] m_bootPkgs;
-    private final boolean[] m_bootPkgWildcards;
-
     // Boolean flag to enable/disable implicit boot delegation.
     private final boolean m_implicitBootDelegation;
 
@@ -145,13 +114,10 @@ public class ModuleImpl extends Abstract
         String[] bootPkgs, boolean[] bootPkgWildcards)
         throws BundleException
     {
-        super(logger, configMap, bundle, id, configMap);
+        super(logger, configMap, bundle, id, configMap, bootPkgs, bootPkgWildcards);
         m_resolver = null;
         m_content = null;
         m_streamHandler = null;
-        m_bootPkgs = bootPkgs;
-        m_bootPkgWildcards = bootPkgWildcards;
-        m_bootClassLoader = m_defBootClassLoader;
         m_implicitBootDelegation = false;
     }
 
@@ -162,30 +128,16 @@ public class ModuleImpl extends Abstract
         boolean[] bootPkgWildcards)
         throws BundleException
     {
-        super(logger, configMap, bundle, id, headerMap);
+        super(logger, configMap, bundle, id, headerMap, bootPkgs, bootPkgWildcards);
         m_resolver = resolver;
         m_content = content;
         m_streamHandler = streamHandler;
-        m_bootPkgs = bootPkgs;
-        m_bootPkgWildcards = bootPkgWildcards;
 
         m_implicitBootDelegation =
             (getConfig().get(FelixConstants.IMPLICIT_BOOT_DELEGATION_PROP) == null)
             || Boolean.valueOf(
                 (String) getConfig().get(
                     FelixConstants.IMPLICIT_BOOT_DELEGATION_PROP)).booleanValue();
-
-        ClassLoader bootLoader = m_defBootClassLoader;
-        Object map = getConfig().get(FelixConstants.BOOT_CLASSLOADERS_PROP);
-        if (map instanceof Map)
-        {
-            Object l = ((Map) map).get(bundle);
-            if (l instanceof ClassLoader)
-            {
-                bootLoader = (ClassLoader) l;
-            }
-        }
-        m_bootClassLoader = bootLoader;
     }
 
     synchronized boolean isActivationTriggered()
@@ -1076,40 +1028,6 @@ public class ModuleImpl extends Abstract
         return m_classLoader;
     }
 
-    private ClassLoader determineParentClassLoader()
-    {
-        // Determine the class loader's parent based on the
-        // configuration property; use boot class loader by
-        // default.
-        String cfg = (String) getConfig().get(Constants.FRAMEWORK_BUNDLE_PARENT);
-        cfg = (cfg == null) ? Constants.FRAMEWORK_BUNDLE_PARENT_BOOT : cfg;
-        final ClassLoader parent;
-        if (cfg.equalsIgnoreCase(Constants.FRAMEWORK_BUNDLE_PARENT_APP))
-        {
-            parent = m_secureAction.getSystemClassLoader();
-        }
-        else if (cfg.equalsIgnoreCase(Constants.FRAMEWORK_BUNDLE_PARENT_EXT))
-        {
-            parent = m_secureAction.getSystemClassLoader().getParent();
-        }
-        else if (cfg.equalsIgnoreCase(Constants.FRAMEWORK_BUNDLE_PARENT_FRAMEWORK))
-        {
-            parent = ModuleImpl.class.getClassLoader();
-        }
-        // On Android we cannot set the parent class loader to be null, so
-        // we special case that situation here and set it to the system
-        // class loader by default instead, which is not really spec.
-        else if (m_bootClassLoader == null)
-        {
-            parent = m_secureAction.getSystemClassLoader();
-        }
-        else
-        {
-            parent = null;
-        }
-        return parent;
-    }
-
     private Object searchImports(String name, boolean isClass)
         throws ClassNotFoundException, ResourceNotFoundException
     {
@@ -1329,13 +1247,6 @@ public class ModuleImpl extends Abstract
 
     boolean shouldBootDelegate(String pkgName)
     {
-        // Always boot delegate if the bundle has a configured
-        // boot class loader.
-        if (m_bootClassLoader != m_defBootClassLoader)
-        {
-            return true;
-        }
-
         boolean result = false;
 
         // Only consider delegation if we have a package name, since

Modified: felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/UnmanagedModuleImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/UnmanagedModuleImpl.java?rev=955035&r1=955034&r2=955035&view=diff
==============================================================================
--- felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/UnmanagedModuleImpl.java
(original)
+++ felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/UnmanagedModuleImpl.java
Tue Jun 15 20:16:26 2010
@@ -49,10 +49,11 @@ public class UnmanagedModuleImpl extends
 
     public UnmanagedModuleImpl(
         Logger logger, Map configMap,
-        Bundle bundle, String id, Map headerMap, VirtualModule vm)
+        Bundle bundle, String id, Map headerMap,
+        String[] bootPkgs, boolean[] bootPkgWildcards, VirtualModule vm)
         throws BundleException
     {
-        super(logger, configMap, bundle, id, headerMap);
+        super(logger, configMap, bundle, id, headerMap, bootPkgs, bootPkgWildcards);
         m_vm = vm;
     }
 
@@ -78,14 +79,15 @@ public class UnmanagedModuleImpl extends
     }
 
     @Override
-    public synchronized void resolve(List<VBWire> wires)
+    public synchronized void resolve(VBWire bootWire, List<VBWire> wires)
         throws BundleException
     {
         if (m_vm != null)
         {
-            m_vm.resolve(wires);
+            m_vm.resolve(
+                new WireBootImpl(m_bootClassLoader, m_bootPkgs, m_bootPkgWildcards), wires);
         }
-        super.resolve(wires);
+        super.resolve(bootWire, wires);
     }
 
     public Class loadClass(String name) throws ClassNotFoundException

Added: felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/WireBootImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/WireBootImpl.java?rev=955035&view=auto
==============================================================================
--- felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/WireBootImpl.java
(added)
+++ felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/WireBootImpl.java
Tue Jun 15 20:16:26 2010
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.framework;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.apache.felix.framework.ext.ResourceNotFoundException;
+import org.apache.felix.framework.ext.VBWire;
+import org.apache.felix.framework.util.Util;
+
+// TODO: VB - This duplicates logic in ModuleImpl, so perhaps the two
+//       could be merged.
+class WireBootImpl implements VBWire
+{
+    private final ClassLoader m_bootLoader;
+    private final String[] m_bootPkgs;
+    private final boolean[] m_bootPkgWildcards;
+
+    public WireBootImpl(ClassLoader boot, String[] bootPkgs, boolean[] bootPkgWildcards)
+    {
+        m_bootLoader = boot;
+        m_bootPkgs = bootPkgs;
+        m_bootPkgWildcards = bootPkgWildcards;
+    }
+
+    public Class loadClass(String name) throws ClassNotFoundException
+    {
+        Class result = null;
+
+        String pkgName = Util.getClassPackage(name);
+
+        // Delegate any packages listed in the boot delegation
+        // property to the parent class loader.
+        if (shouldBootDelegate(pkgName))
+        {
+            try
+            {
+                result = m_bootLoader.loadClass(name);
+                // If this is a java.* package, then always terminate the
+                // search; otherwise, continue to look locally if not found.
+                if (pkgName.startsWith("java.") && (result == null))
+                {
+                    throw new ClassNotFoundException(name);
+                }
+            }
+            catch (ClassNotFoundException ex)
+            {
+                // If this is a java.* package, then always terminate the
+                // search; otherwise, continue to look locally if not found.
+                if (pkgName.startsWith("java."))
+                {
+                    throw ex;
+                }
+            }
+        }
+
+        return result;
+    }
+
+    public URL getResource(String name) throws ResourceNotFoundException
+    {
+        URL result = null;
+
+        String pkgName = Util.getClassPackage(name);
+
+        // Delegate any packages listed in the boot delegation
+        // property to the parent class loader.
+        if (shouldBootDelegate(pkgName))
+        {
+            result = m_bootLoader.getResource(name);
+            // If this is a java.* package, then always terminate the
+            // search; otherwise, continue to look locally if not found.
+            if (pkgName.startsWith("java.") && (result == null))
+            {
+                throw new ResourceNotFoundException(name);
+            }
+        }
+
+        return result;
+    }
+
+    public Enumeration getResources(String name) throws ResourceNotFoundException
+    {
+        Enumeration result = null;
+
+        String pkgName = Util.getClassPackage(name);
+
+        // Delegate any packages listed in the boot delegation
+        // property to the parent class loader.
+        if (shouldBootDelegate(pkgName))
+        {
+            try
+            {
+                result = m_bootLoader.getResources(name);
+            }
+            catch (IOException ex)
+            {
+                // Not much we can do.
+            }
+            // If this is a java.* package, then always terminate the
+            // search; otherwise, continue to look locally if not found.
+            if (pkgName.startsWith("java.") && (result == null))
+            {
+                throw new ResourceNotFoundException(name);
+            }
+        }
+
+        return result;
+    }
+
+    private boolean shouldBootDelegate(String pkgName)
+    {
+        boolean result = false;
+
+        // Only consider delegation if we have a package name, since
+        // we don't want to promote the default package. The spec does
+        // not take a stand on this issue.
+        if (pkgName.length() > 0)
+        {
+            for (int i = 0; !result && (i < m_bootPkgs.length); i++)
+            {
+                // Check if the boot package is wildcarded.
+                // A wildcarded boot package will be in the form "foo.",
+                // so a matching subpackage will start with "foo.", e.g.,
+                // "foo.bar".
+                if (m_bootPkgWildcards[i] && pkgName.startsWith(m_bootPkgs[i]))
+                {
+                    return true;
+                }
+                // If not wildcarded, then check for an exact match.
+                else if (m_bootPkgs[i].equals(pkgName))
+                {
+                    return true;
+                }
+            }
+        }
+
+        return result;
+    }
+}
\ No newline at end of file

Modified: felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/ext/VirtualModule.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/ext/VirtualModule.java?rev=955035&r1=955034&r2=955035&view=diff
==============================================================================
--- felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/ext/VirtualModule.java
(original)
+++ felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/ext/VirtualModule.java
Tue Jun 15 20:16:26 2010
@@ -27,8 +27,7 @@ import org.osgi.framework.BundleExceptio
 
 public interface VirtualModule
 {
-    // TODO: VB - How to signal a refresh?
-    void resolve(List<VBWire> wires) throws BundleException;
+    void resolve(VBWire bootWire, List<VBWire> wires) throws BundleException;
 
     Class loadClass(String name) throws ClassNotFoundException;
     URL getResource(String name);

Modified: felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/resolver/Module.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/resolver/Module.java?rev=955035&r1=955034&r2=955035&view=diff
==============================================================================
--- felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/resolver/Module.java
(original)
+++ felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/resolver/Module.java
Tue Jun 15 20:16:26 2010
@@ -33,6 +33,9 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Version;
 
+// TODO: VB - Extending VirtualModule add resolve(VBWire, List<VBWire>) which
+//       doesn't really make sense on Module; perhaps we need to handle boot
+//       delegation differently for virtual modules or normal modules or both.
 public interface Module extends VirtualModule
 {
     final static int EAGER_ACTIVATION = 0;
@@ -53,16 +56,12 @@ public interface Module extends VirtualM
     Bundle getBundle();
     String getId();
     List<VBWire> getWires();
-    void resolve(List<VBWire> wires) throws BundleException;
     boolean isResolved();
     boolean isResolvable();
     Object getSecurityContext();
 
     // Content access methods.
     Content getContent();
-    Class loadClass(String name) throws ClassNotFoundException;
-    URL getResource(String name);
-    Enumeration<URL> getResources(String name);
     URL getEntry(String name);
     Enumeration<String> getEntryPaths(String path);
     Enumeration<URL> findEntries(String path, String filePattern, boolean recurse);

Modified: felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/util/FelixConstants.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/util/FelixConstants.java?rev=955035&r1=955034&r2=955035&view=diff
==============================================================================
--- felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/util/FelixConstants.java
(original)
+++ felix/sandbox/rickhall/vb/framework-vb/src/main/java/org/apache/felix/framework/util/FelixConstants.java
Tue Jun 15 20:16:26 2010
@@ -52,7 +52,6 @@ public interface FelixConstants extends 
         = "felix.startlevel.bundle";
     public static final String SERVICE_URLHANDLERS_PROP = "felix.service.urlhandlers";
     public static final String IMPLICIT_BOOT_DELEGATION_PROP = "felix.bootdelegation.implicit";
-    public static final String BOOT_CLASSLOADERS_PROP = "felix.bootdelegation.classloaders";
 
     // Start level-related constants.
     public static final int FRAMEWORK_INACTIVE_STARTLEVEL = 0;



Mime
View raw message