openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From curti...@apache.org
Subject svn commit: r1644414 - in /openjpa/trunk: openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
Date Wed, 10 Dec 2014 14:11:45 GMT
Author: curtisr7
Date: Wed Dec 10 14:11:45 2014
New Revision: 1644414

URL: http://svn.apache.org/r1644414
Log:
OPENJPA-2542: Use bundle classloader AND PersistenceUnitInfo classloader when creating a BrokerFactory.

Modified:
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java?rev=1644414&r1=1644413&r2=1644414&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java
Wed Dec 10 14:11:45 2014
@@ -68,6 +68,12 @@ public class MultiClassLoader extends Cl
         addClassLoaders(other);
     }
 
+    public MultiClassLoader(ClassLoader... loaders) {
+        for (ClassLoader loader : loaders) {
+            addClassLoader(loader);
+        }
+    }
+
     /**
      * Returns true if the list contains the given class loader or marker.
      */

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java?rev=1644414&r1=1644413&r2=1644414&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProviderImpl.java
Wed Dec 10 14:11:45 2014
@@ -44,6 +44,7 @@ import org.apache.openjpa.lib.conf.Confi
 import org.apache.openjpa.lib.conf.Configurations;
 import org.apache.openjpa.lib.log.Log;
 import org.apache.openjpa.lib.util.Localizer;
+import org.apache.openjpa.lib.util.MultiClassLoader;
 import org.apache.openjpa.meta.AbstractCFMetaDataFactory;
 import org.apache.openjpa.meta.MetaDataModes;
 import org.apache.openjpa.meta.MetaDataRepository;
@@ -180,14 +181,14 @@ public class PersistenceProviderImpl
                 cp.addProperty("openjpa." + BrokerValue.KEY, getDefaultBrokerAlias());
             }
 
-            // OPENJPA-1491 If running under OSGi, use the Bundle's ClassLoader instead of
the application one
-            BrokerFactory factory;
+
+            ClassLoader loader = pui.getClassLoader();
             if (BundleUtils.runningUnderOSGi()) {
-                factory = getBrokerFactory(cp, poolValue, BundleUtils.getBundleClassLoader());
-            } else {
-                factory = getBrokerFactory(cp, poolValue, pui.getClassLoader());
+                // OPENJPA-1491 : If running under OSGi, use the Bundle's ClassLoader instead
of the application one
+                // OPENJPA-2542 : Also try to load from app loader in the case of a user
implemented interface/config 
+                loader = new MultiClassLoader(BundleUtils.getBundleClassLoader(), loader);
             }
-
+            BrokerFactory factory = getBrokerFactory(cp, poolValue, loader);
             OpenJPAConfiguration conf = factory.getConfiguration();
             setPersistenceEnvironmentInfo(conf, pui);
             _log = conf.getLog(OpenJPAConfiguration.LOG_RUNTIME);



Mime
View raw message