Applied patch (FELIX-1991) to make boot delegation class loader configurable.


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@900959 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/Felix.java b/framework/src/main/java/org/apache/felix/framework/Felix.java
index 3290209..b1e3b92 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -3687,7 +3687,15 @@
         {
             sb.setCharAt(sb.toString().indexOf("-"), '.');
         }
-        return sb.toString();
+        String toRet = sb.toString();
+        if (toRet.contains("${pom"))
+        {
+            return "0.0.0";
+        }
+        else
+        {
+            return toRet;
+        }
     }
 
     //
diff --git a/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java b/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java
index 914bff1..24bc19e 100644
--- a/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java
@@ -99,9 +99,13 @@
     private boolean m_isActivationTriggered = false;
     private ProtectionDomain m_protectionDomain = null;
     private static SecureAction m_secureAction = new SecureAction();
-    // Class load to be used for boot delegation.
-    private final static ClassLoader m_bootClassLoader;
-    // Statically create the class loader for boot delegation.
+
+    // 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;
@@ -120,7 +124,7 @@
             cl = null;
             System.err.println("Problem creating boot delegation class loader: " + ex);
         }
-        m_bootClassLoader = cl;
+        m_defBootClassLoader = cl;
     }
 
     // Boot delegation packages.
@@ -175,6 +179,7 @@
         m_activationExcludes = null;
         m_activationIncludes = null;
         m_implicitBootDelegation = false;
+        m_bootClassLoader = m_defBootClassLoader;
     }
 
     public ModuleImpl(
@@ -201,6 +206,18 @@
                 (String) m_configMap.get(
                     FelixConstants.IMPLICIT_BOOT_DELEGATION_PROP)).booleanValue();
 
+        ClassLoader bootLoader = m_defBootClassLoader;
+        Object map = m_configMap.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;
+
         ManifestParser mp = new ManifestParser(m_logger, m_configMap, this, m_headerMap);
 
         // Record some of the parsed metadata. Note, if this is an extension
@@ -1539,6 +1556,13 @@
 
     private boolean shouldBootDelegate(String pkgName)
     {
+        // Always boot delegate if the bundle has a configured
+        // boot class loader.
+        if (m_classLoader != m_defBootClassLoader)
+        {
+            return true;
+        }
+
         boolean result = false;
 
         // Only consider delegation if we have a package name, since
diff --git a/framework/src/main/java/org/apache/felix/framework/util/FelixConstants.java b/framework/src/main/java/org/apache/felix/framework/util/FelixConstants.java
index 3c56a30..0c08a2f 100644
--- a/framework/src/main/java/org/apache/felix/framework/util/FelixConstants.java
+++ b/framework/src/main/java/org/apache/felix/framework/util/FelixConstants.java
@@ -52,6 +52,7 @@
         = "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;