openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From curti...@apache.org
Subject svn commit: r953830 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCBrokerFactory.java openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java
Date Fri, 11 Jun 2010 18:51:48 GMT
Author: curtisr7
Date: Fri Jun 11 18:51:47 2010
New Revision: 953830

URL: http://svn.apache.org/viewvc?rev=953830&view=rev
Log:
OPENJPA-1692: Update method signature for BrokerFactory.getInstance(...) to take a classloader.

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCBrokerFactory.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCBrokerFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCBrokerFactory.java?rev=953830&r1=953829&r2=953830&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCBrokerFactory.java
(original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCBrokerFactory.java
Fri Jun 11 18:51:47 2010
@@ -65,7 +65,7 @@ public class JDBCBrokerFactory
      * Factory method for obtaining a possibly-pooled factory from properties.
      * Invoked from {@link Bootstrap#getBrokerFactory}.
      */
-    public static JDBCBrokerFactory getInstance(ConfigurationProvider cp) {
+    public static JDBCBrokerFactory getInstance(ConfigurationProvider cp, ClassLoader loader)
{
         Map<String, Object> props = cp.getProperties();
         Object key = toPoolKey(props);
         JDBCBrokerFactory factory = (JDBCBrokerFactory) getPooledFactoryForKey(key);
@@ -73,7 +73,7 @@ public class JDBCBrokerFactory
             return factory;
         
         // The creation of all BrokerFactories should be driven through Bootstrap.
-        factory = (JDBCBrokerFactory) Bootstrap.newBrokerFactory(cp, null);
+        factory = (JDBCBrokerFactory) Bootstrap.newBrokerFactory(cp, loader);
         pool(key, factory);
         return factory;
     }

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java?rev=953830&r1=953829&r2=953830&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java Fri
Jun 11 18:51:47 2010
@@ -39,8 +39,11 @@ import org.apache.openjpa.util.UserExcep
  */
 public class Bootstrap {
 
-    private static final Class[] FACTORY_ARGS =
-        new Class[]{ ConfigurationProvider.class };
+    private static final Class<?>[] CONFIGURATION_ARG =
+        new Class<?>[]{ ConfigurationProvider.class };
+    
+    private static final Class<?>[] CONFIGURATION_CLASSLOADER_ARGS =
+        new Class<?>[] { ConfigurationProvider.class, ClassLoader.class };
 
     private static Localizer s_loc = Localizer.forPackage(Bootstrap.class);
 
@@ -59,7 +62,8 @@ public class Bootstrap {
     public static BrokerFactory newBrokerFactory(ConfigurationProvider conf,
         ClassLoader loader) {
         try {
-            BrokerFactory factory = invokeFactory(conf, loader, "newInstance");
+            BrokerFactory factory =
+                invokeFactory(conf, loader, "newInstance", CONFIGURATION_ARG, new Object[]
{ conf });
             factory.postCreationCallback();
             return factory;
         } catch (InvocationTargetException ite) {
@@ -89,7 +93,8 @@ public class Bootstrap {
     public static BrokerFactory getBrokerFactory(ConfigurationProvider conf,
         ClassLoader loader) {
         try {
-            return invokeFactory(conf, loader, "getInstance");
+            return invokeFactory(conf, loader, "getInstance", CONFIGURATION_CLASSLOADER_ARGS,
new Object[] { conf,
+                loader });
         } catch (InvocationTargetException ite) {
             Throwable cause = ite.getTargetException();
             if (cause instanceof OpenJPAException)
@@ -103,7 +108,7 @@ public class Bootstrap {
     }
 
     private static BrokerFactory invokeFactory(ConfigurationProvider conf,
-        ClassLoader loader, String methodName)
+        ClassLoader loader, String methodName, Class<?>[] argTypes, Object[] args)
         throws InvocationTargetException, NoSuchMethodException,
             IllegalAccessException {
         if (conf == null)
@@ -113,17 +118,17 @@ public class Bootstrap {
         Class cls = getFactoryClass(conf, loader);
         Method meth;
         try {
-            meth = cls.getMethod(methodName, FACTORY_ARGS); 
+            meth = cls.getMethod(methodName, argTypes); 
         } catch (NoSuchMethodException nsme) {
             // handle cases where there is a mismatch between loaders by falling
             // back to the configuration's class loader for broker resolution
             cls = getFactoryClass(conf,
                 AccessController.doPrivileged(
                     J2DoPrivHelper.getClassLoaderAction(conf.getClass()))); 
-            meth = cls.getMethod(methodName, FACTORY_ARGS); 
+            meth = cls.getMethod(methodName, argTypes); 
         }
 
-        return (BrokerFactory) meth.invoke(null, new Object[]{ conf });
+        return (BrokerFactory) meth.invoke(null, args);
     }
 
     private static String getFactoryClassName(ConfigurationProvider conf,



Mime
View raw message