openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r813149 - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ openjpa-lib/src/main/java/org/apache/...
Date Wed, 09 Sep 2009 22:43:50 GMT
Author: ppoddar
Date: Wed Sep  9 22:43:49 2009
New Revision: 813149

URL: http://svn.apache.org/viewvc?rev=813149&view=rev
Log:
OPENJPA-1285: Dynamic JDBC 4 Wrappers use constructor to save reflection cost

Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ConfiguringConnectionDecorator.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DecoratingDataSource.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingConnection.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDatabaseMetaData.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingPreparedStatement.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingStatement.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/ConcreteClassGenerator.java
    openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedConnection.java
    openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCStoreManager.java
    openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedPreparedStatement.java
    openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedResultSet.java
    openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStatement.java
    openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedTemplate.java
    openjpa/trunk/openjpa-slice/src/test/resources/META-INF/persistence.xml

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/JDBCStoreManager.java Wed Sep  9 22:43:49 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.jdbc.kernel;
 
+import java.lang.reflect.Constructor;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -107,22 +108,21 @@
     // track the pending statements so we can cancel them
     private Set _stmnts = Collections.synchronizedSet(new HashSet());
 
-    private static final Class<ClientConnection> clientConnectionImpl;
-    private static final Class<RefCountConnection> refCountConnectionImpl;
-    private static final Class<CancelStatement> cancelStatementImpl;
-    private static final Class<CancelPreparedStatement>
-            cancelPreparedStatementImpl;
+    private static final Constructor<ClientConnection> clientConnectionImpl;
+    private static final Constructor<RefCountConnection> refCountConnectionImpl;
+    private static final Constructor<CancelStatement> cancelStatementImpl;
+    private static final Constructor<CancelPreparedStatement> cancelPreparedStatementImpl;
 
     static {
         try {
-            clientConnectionImpl = ConcreteClassGenerator.
-                makeConcrete(ClientConnection.class);
-            refCountConnectionImpl = ConcreteClassGenerator.
-                makeConcrete(RefCountConnection.class);
-            cancelStatementImpl = ConcreteClassGenerator.
-                makeConcrete(CancelStatement.class);
-            cancelPreparedStatementImpl = ConcreteClassGenerator.
-                makeConcrete(CancelPreparedStatement.class);
+            clientConnectionImpl = ConcreteClassGenerator.getConcreteConstructor(ClientConnection.class, 
+                Connection.class);
+            refCountConnectionImpl = ConcreteClassGenerator.getConcreteConstructor(RefCountConnection.class,
+                JDBCStoreManager.class, Connection.class);
+            cancelStatementImpl = ConcreteClassGenerator.getConcreteConstructor(CancelStatement.class,
+                JDBCStoreManager.class, Statement.class, Connection.class);
+            cancelPreparedStatementImpl = ConcreteClassGenerator.getConcreteConstructor(CancelPreparedStatement.class,
+                JDBCStoreManager.class, PreparedStatement.class, Connection.class);
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }
@@ -236,8 +236,7 @@
     }
 
     public Object getClientConnection() {
-        return ConcreteClassGenerator.newInstance
-            (clientConnectionImpl, Connection.class, getConnection());
+        return ConcreteClassGenerator.newInstance(clientConnectionImpl, getConnection());
     }
 
     public Connection getConnection() {
@@ -901,9 +900,7 @@
      * can be overridden.
      */
     protected RefCountConnection connectInternal() throws SQLException {
-        return ConcreteClassGenerator.newInstance
-            (refCountConnectionImpl, JDBCStoreManager.class, 
-                JDBCStoreManager.this, Connection.class, _ds.getConnection());
+        return ConcreteClassGenerator.newInstance(refCountConnectionImpl, JDBCStoreManager.this, _ds.getConnection());
     }
 
     /**
@@ -1521,11 +1518,8 @@
         }
 
         protected Statement createStatement(boolean wrap) throws SQLException {
-            return ConcreteClassGenerator.newInstance
-                (cancelStatementImpl,
-                    JDBCStoreManager.class, JDBCStoreManager.this,
-                    Statement.class, super.createStatement(false),
-                    Connection.class, RefCountConnection.this);
+            return ConcreteClassGenerator.newInstance(cancelStatementImpl, JDBCStoreManager.this,
+                    super.createStatement(false), RefCountConnection.this);
         }
 
         protected Statement createStatement(int rsType, int rsConcur,
@@ -1540,11 +1534,8 @@
 
         protected PreparedStatement prepareStatement(String sql, boolean wrap)
             throws SQLException {
-            return ConcreteClassGenerator.newInstance
-                (cancelPreparedStatementImpl,
-                    JDBCStoreManager.class, JDBCStoreManager.this,
-                    PreparedStatement.class, super.prepareStatement(sql, false),
-                    Connection.class, RefCountConnection.this);
+            return ConcreteClassGenerator.newInstance(cancelPreparedStatementImpl,
+                    JDBCStoreManager.this, super.prepareStatement(sql, false), RefCountConnection.this);
         }
 
         protected PreparedStatement prepareStatement(String sql, int rsType,

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java Wed Sep  9 22:43:49 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.jdbc.schema;
 
+import java.lang.reflect.Constructor;
 import java.security.AccessController;
 import java.sql.Connection;
 import java.sql.Driver;
@@ -295,12 +296,12 @@
     protected abstract static class DefaultsDataSource
         extends DelegatingDataSource {
 
-        private static final Class<DefaultsDataSource> implClass;
+        private static final Constructor<DefaultsDataSource> implClass;
 
         static {
             try {
-                implClass = ConcreteClassGenerator.
-                    makeConcrete(DefaultsDataSource.class);
+                implClass = ConcreteClassGenerator.getConcreteConstructor(DefaultsDataSource.class, 
+                        DataSource.class, String.class, String.class);
             } catch (Exception e) {
                 throw new ExceptionInInitializerError(e);
             }
@@ -315,13 +316,8 @@
             _pass = pass;
         }
 
-        public static DefaultsDataSource newInstance(DataSource ds,
-            String user, String pass) {
-            return ConcreteClassGenerator.
-                newInstance(implClass,
-                    DataSource.class, ds,
-                    String.class, user,
-                    String.class, pass);
+        public static DefaultsDataSource newInstance(DataSource ds, String user, String pass) {
+            return ConcreteClassGenerator.newInstance(implClass, ds, user, pass);
         }
 
         public Connection getConnection()

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java Wed Sep  9 22:43:49 2009
@@ -19,6 +19,7 @@
 package org.apache.openjpa.jdbc.schema;
 
 import java.io.PrintWriter;
+import java.lang.reflect.Constructor;
 import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import java.sql.Connection;
@@ -28,6 +29,8 @@
 import java.util.List;
 import java.util.Properties;
 
+import javax.sql.DataSource;
+
 import org.apache.openjpa.jdbc.sql.DBDictionary;
 import org.apache.openjpa.lib.jdbc.DelegatingDataSource;
 import org.apache.openjpa.lib.util.ConcreteClassGenerator;
@@ -50,17 +53,14 @@
     private Driver _driver;
     private ClassLoader _classLoader;
     
-    protected static Localizer _loc = 
-    	Localizer.forPackage(SimpleDriverDataSource.class);
-    protected static Localizer _eloc = 
-    	Localizer.forPackage(DelegatingDataSource.class);
+    protected static Localizer _loc = Localizer.forPackage(SimpleDriverDataSource.class);
+    protected static Localizer _eloc = Localizer.forPackage(DelegatingDataSource.class);
 
-    private static final Class<SimpleDriverDataSource> implClass;
+    private static final Class<? extends SimpleDriverDataSource> implClass;
 
     static {
         try {
-            implClass = ConcreteClassGenerator.
-                makeConcrete(SimpleDriverDataSource.class);
+            implClass = ConcreteClassGenerator.makeConcrete(SimpleDriverDataSource.class);
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/PostgresDictionary.java Wed Sep  9 22:43:49 2009
@@ -21,6 +21,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.sql.Connection;
@@ -63,16 +64,16 @@
     private static final Localizer _loc = Localizer.forPackage
         (PostgresDictionary.class);
 
-    private static Class<PostgresConnection> postgresConnectionImpl;
-    private static Class<PostgresPreparedStatement>
-            postgresPreparedStatementImpl;
+    private static Constructor<PostgresConnection> postgresConnectionImpl;
+    private static Constructor<PostgresPreparedStatement> postgresPreparedStatementImpl;
 
     static {
         try {
-            postgresConnectionImpl = ConcreteClassGenerator.
-                makeConcrete(PostgresConnection.class);
-            postgresPreparedStatementImpl = ConcreteClassGenerator.
-                makeConcrete(PostgresPreparedStatement.class);
+            postgresConnectionImpl = ConcreteClassGenerator.getConcreteConstructor(PostgresConnection.class,
+                    Connection.class, PostgresDictionary.class);
+            postgresPreparedStatementImpl = ConcreteClassGenerator.getConcreteConstructor(
+                    PostgresPreparedStatement.class,
+                    PreparedStatement.class, Connection.class, PostgresDictionary.class);
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }
@@ -372,9 +373,7 @@
 
     public Connection decorate(Connection conn)
         throws SQLException {
-        return ConcreteClassGenerator.
-            newInstance(postgresConnectionImpl, Connection.class, 
-                super.decorate(conn), PostgresDictionary.class, this);
+        return ConcreteClassGenerator.newInstance(postgresConnectionImpl, super.decorate(conn), this);
     }
 
     public InputStream getLOBStream(JDBCStore store, ResultSet rs,
@@ -688,11 +687,8 @@
 
         protected PreparedStatement prepareStatement(String sql, boolean wrap)
             throws SQLException {
-           return ConcreteClassGenerator.
-                newInstance(postgresPreparedStatementImpl,
-                    PreparedStatement.class, super.prepareStatement(sql, false),
-                    Connection.class, PostgresConnection.this,
-                    PostgresDictionary.class, _dict);
+           return ConcreteClassGenerator.newInstance(postgresPreparedStatementImpl, 
+                   super.prepareStatement(sql, false), PostgresConnection.this, _dict);
         }
 
         protected PreparedStatement prepareStatement(String sql, int rsType,

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SybaseDictionary.java Wed Sep  9 22:43:49 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.jdbc.sql;
 
+import java.lang.reflect.Constructor;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.sql.Connection;
@@ -61,12 +62,12 @@
     private static Localizer _loc = Localizer.forPackage
         (SybaseDictionary.class);
 
-    private static Class<SybaseConnection> sybaseConnectionImpl;
+    private static Constructor<SybaseConnection> sybaseConnectionImpl;
 
     static {
         try {
-            sybaseConnectionImpl = ConcreteClassGenerator.
-                makeConcrete(SybaseConnection.class);
+            sybaseConnectionImpl = ConcreteClassGenerator.getConcreteConstructor(SybaseConnection.class, 
+                    Connection.class);
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }
@@ -308,8 +309,7 @@
             stmnt.close();            
         }        
         
-        return ConcreteClassGenerator.newInstance(sybaseConnectionImpl, 
-            Connection.class, conn);
+        return ConcreteClassGenerator.newInstance(sybaseConnectionImpl, conn);
     }
 
     /**

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ConfiguringConnectionDecorator.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ConfiguringConnectionDecorator.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ConfiguringConnectionDecorator.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/ConfiguringConnectionDecorator.java Wed Sep  9 22:43:49 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.lib.jdbc;
 
+import java.lang.reflect.Constructor;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
@@ -39,12 +40,12 @@
  */
 public class ConfiguringConnectionDecorator implements ConnectionDecorator {
 
-   static final Class<ConfiguringConnection> configuringConnectionImpl;
+   static final Constructor<ConfiguringConnection> configuringConnectionImpl;
 
     static {
         try {
-            configuringConnectionImpl = ConcreteClassGenerator.
-                makeConcrete(ConfiguringConnection.class);
+            configuringConnectionImpl = ConcreteClassGenerator.getConcreteConstructor(ConfiguringConnection.class, 
+                    ConfiguringConnectionDecorator.class, Connection.class);
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }
@@ -104,9 +105,7 @@
         if (_isolation == Connection.TRANSACTION_NONE || _queryTimeout != -1
             || _autoCommit != null)
             conn = ConcreteClassGenerator.
-                newInstance(configuringConnectionImpl,
-                    ConfiguringConnectionDecorator.class, this,
-                    Connection.class, conn);
+                newInstance(configuringConnectionImpl, this, conn);
         if (_isolation != -1 && _isolation != Connection.TRANSACTION_NONE)
             conn.setTransactionIsolation(_isolation);
         return conn;

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DecoratingDataSource.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DecoratingDataSource.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DecoratingDataSource.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DecoratingDataSource.java Wed Sep  9 22:43:49 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.lib.jdbc;
 
+import java.lang.reflect.Constructor;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.Collection;
@@ -37,12 +38,11 @@
  */
 public abstract class DecoratingDataSource extends DelegatingDataSource {
     
-    private static final Class<DecoratingDataSource> implClass;
+    private static final Constructor<DecoratingDataSource> implClass;
 
     static {
         try {
-            implClass = ConcreteClassGenerator.
-                makeConcrete(DecoratingDataSource.class);
+            implClass = ConcreteClassGenerator.getConcreteConstructor(DecoratingDataSource.class, DataSource.class);
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }
@@ -60,8 +60,7 @@
     }
     
     public static DecoratingDataSource newDecoratingDataSource(DataSource ds) {
-        return ConcreteClassGenerator.newInstance(implClass, 
-            DataSource.class, ds);
+        return ConcreteClassGenerator.newInstance(implClass, ds);
     }
 
 

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingCallableStatement.java Wed Sep  9 22:43:49 2009
@@ -20,6 +20,7 @@
 
 import java.io.InputStream;
 import java.io.Reader;
+import java.lang.reflect.Constructor;
 import java.math.BigDecimal;
 import java.net.URL;
 import java.sql.Array;
@@ -50,12 +51,12 @@
 public abstract class DelegatingCallableStatement
     implements CallableStatement, Closeable {
 
-    static final Class<DelegatingCallableStatement> concreteImpl;
+    static final Constructor<DelegatingCallableStatement> concreteImpl;
 
     static {
         try {
-            concreteImpl = ConcreteClassGenerator.
-                makeConcrete(DelegatingCallableStatement.class);
+            concreteImpl = ConcreteClassGenerator.getConcreteConstructor(DelegatingCallableStatement.class, 
+                CallableStatement.class, Connection.class);
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }
@@ -78,10 +79,8 @@
     /** 
      *  Constructor for the concrete implementation of this abstract class.
      */
-    public static DelegatingCallableStatement newInstance
-        (CallableStatement stmnt, Connection conn) {
-        return ConcreteClassGenerator.newInstance(concreteImpl,
-                CallableStatement.class, stmnt, Connection.class, conn);
+    public static DelegatingCallableStatement newInstance(CallableStatement stmnt, Connection conn) {
+        return ConcreteClassGenerator.newInstance(concreteImpl, stmnt, conn);
     }
 
     protected ResultSet wrapResult(boolean wrap, ResultSet rs) {

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingConnection.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingConnection.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingConnection.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingConnection.java Wed Sep  9 22:43:49 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.lib.jdbc;
 
+import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.sql.CallableStatement;
 import java.sql.Connection;
@@ -35,6 +36,7 @@
 import org.apache.openjpa.lib.util.Closeable;
 import org.apache.openjpa.lib.util.ConcreteClassGenerator;
 import org.apache.openjpa.lib.util.Localizer;
+
 import serp.util.Numbers;
 
 /**
@@ -47,11 +49,10 @@
  */
 public abstract class DelegatingConnection implements Connection, Closeable {
 
-    static final Class<DelegatingConnection> concreteImpl;
+    static final Constructor<DelegatingConnection> concreteImpl;
     static {
         try {
-            concreteImpl = ConcreteClassGenerator.
-                makeConcrete(DelegatingConnection.class);
+            concreteImpl = ConcreteClassGenerator.getConcreteConstructor(DelegatingConnection.class, Connection.class);
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }
@@ -80,8 +81,7 @@
         boolean jdbc3 = false;
         Method m = null;
         try {
-            m = Connection.class.getMethod("setSavepoint",
-                new Class[]{ String.class });
+            m = Connection.class.getMethod("setSavepoint", new Class[]{ String.class });
             jdbc3 = true;
         } catch (Throwable t) {
         }
@@ -108,8 +108,7 @@
      *  Constructor for the concrete implementation of this abstract class.
      */
     public static DelegatingConnection newInstance(Connection conn) {
-        return ConcreteClassGenerator.newInstance(concreteImpl, 
-            Connection.class, conn);
+        return ConcreteClassGenerator.newInstance(concreteImpl, conn);
     }
 
     /** 

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDataSource.java Wed Sep  9 22:43:49 2009
@@ -19,6 +19,7 @@
 package org.apache.openjpa.lib.jdbc;
 
 import java.io.PrintWriter;
+import java.lang.reflect.Constructor;
 import java.sql.Connection;
 import java.sql.SQLException;
 import javax.sql.DataSource;
@@ -35,12 +36,11 @@
  */
 public abstract class DelegatingDataSource implements DataSource, Closeable {
 
-    static final Class<DelegatingDataSource> concreteImpl;
+    static final Constructor<DelegatingDataSource> concreteImpl;
 
     static {
         try {
-            concreteImpl = ConcreteClassGenerator.
-                makeConcrete(DelegatingDataSource.class);
+            concreteImpl = ConcreteClassGenerator.getConcreteConstructor(DelegatingDataSource.class, DataSource.class);
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }
@@ -65,8 +65,7 @@
      *  Constructor for the concrete implementation of this abstract class.
      */
     public static DelegatingDataSource newInstance(DataSource ds) {
-        return ConcreteClassGenerator.newInstance(concreteImpl, 
-            DataSource.class, ds);
+        return ConcreteClassGenerator.newInstance(concreteImpl, ds);
     }
 
     /** 

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDatabaseMetaData.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDatabaseMetaData.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDatabaseMetaData.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingDatabaseMetaData.java Wed Sep  9 22:43:49 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.lib.jdbc;
 
+import java.lang.reflect.Constructor;
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
 import java.sql.ResultSet;
@@ -32,12 +33,12 @@
  */
 public abstract class DelegatingDatabaseMetaData implements DatabaseMetaData {
 
-    static final Class<DelegatingDatabaseMetaData> concreteImpl;
+    static final Constructor<DelegatingDatabaseMetaData> concreteImpl;
 
     static {
         try {
-            concreteImpl = ConcreteClassGenerator.
-                makeConcrete(DelegatingDatabaseMetaData.class);
+            concreteImpl = ConcreteClassGenerator.getConcreteConstructor(DelegatingDatabaseMetaData.class, 
+                    DatabaseMetaData.class, Connection.class);
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }
@@ -52,10 +53,8 @@
         _metaData = metaData;
     }
 
-    public static DelegatingDatabaseMetaData newInstance
-        (DatabaseMetaData metaData, Connection conn) {
-        return ConcreteClassGenerator.newInstance(concreteImpl,
-                DatabaseMetaData.class, metaData, Connection.class, conn);
+    public static DelegatingDatabaseMetaData newInstance(DatabaseMetaData metaData, Connection conn) {
+        return ConcreteClassGenerator.newInstance(concreteImpl, metaData, conn);
     }
 
     /** 

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingPreparedStatement.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingPreparedStatement.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingPreparedStatement.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingPreparedStatement.java Wed Sep  9 22:43:49 2009
@@ -20,6 +20,7 @@
 
 import java.io.InputStream;
 import java.io.Reader;
+import java.lang.reflect.Constructor;
 import java.math.BigDecimal;
 import java.net.URL;
 import java.sql.Array;
@@ -52,11 +53,11 @@
 public abstract class DelegatingPreparedStatement
     implements PreparedStatement, Closeable {
     
-    static final Class<DelegatingPreparedStatement> concreteImpl;
+    static final Constructor<DelegatingPreparedStatement> concreteImpl;
     static {
         try {
-            concreteImpl = ConcreteClassGenerator.
-                makeConcrete(DelegatingPreparedStatement.class);
+            concreteImpl = ConcreteClassGenerator.getConcreteConstructor(DelegatingPreparedStatement.class,
+                    PreparedStatement.class, Connection.class);
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }
@@ -76,10 +77,8 @@
             _del = null;
     }
     
-    public static DelegatingPreparedStatement newInstance
-        (PreparedStatement stmnt, Connection conn) {
-        return ConcreteClassGenerator.newInstance(concreteImpl,
-                PreparedStatement.class, stmnt, Connection.class, conn);
+    public static DelegatingPreparedStatement newInstance(PreparedStatement stmnt, Connection conn) {
+        return ConcreteClassGenerator.newInstance(concreteImpl, stmnt, conn);
     }
 
     protected ResultSet wrapResult(ResultSet rs, boolean wrap) {

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingResultSet.java Wed Sep  9 22:43:49 2009
@@ -20,6 +20,7 @@
 
 import java.io.InputStream;
 import java.io.Reader;
+import java.lang.reflect.Constructor;
 import java.math.BigDecimal;
 import java.net.URL;
 import java.sql.Array;
@@ -50,12 +51,12 @@
  */
 public abstract class DelegatingResultSet implements ResultSet, Closeable {
 
-    static final Class<DelegatingResultSet> concreteImpl;
+    static final Constructor<DelegatingResultSet> concreteImpl;
 
     static {
         try {
-            concreteImpl = ConcreteClassGenerator.
-                makeConcrete(DelegatingResultSet.class);
+            concreteImpl = ConcreteClassGenerator.getConcreteConstructor(DelegatingResultSet.class, 
+                ResultSet.class, Statement.class);
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }
@@ -77,10 +78,8 @@
             _del = null;
     }
 
-    public static DelegatingResultSet newInstance
-        (ResultSet rs, Statement stmnt)  {
-        return ConcreteClassGenerator.newInstance(concreteImpl,
-                ResultSet.class, rs, Statement.class, stmnt);
+    public static DelegatingResultSet newInstance(ResultSet rs, Statement stmnt)  {
+        return ConcreteClassGenerator.newInstance(concreteImpl, rs, stmnt);
     }
 
     /** 

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingStatement.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingStatement.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingStatement.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/DelegatingStatement.java Wed Sep  9 22:43:49 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.lib.jdbc;
 
+import java.lang.reflect.Constructor;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -37,12 +38,12 @@
  */
 public abstract class DelegatingStatement implements Statement, Closeable {
 
-    static final Class<DelegatingStatement> concreteImpl;
+    static final Constructor<DelegatingStatement> concreteImpl;
 
     static {
         try {
-            concreteImpl = ConcreteClassGenerator.
-                makeConcrete(DelegatingStatement.class);
+            concreteImpl = ConcreteClassGenerator.getConcreteConstructor(DelegatingStatement.class, 
+                Statement.class, Connection.class);
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }
@@ -61,10 +62,8 @@
             _del = null;
     }
 
-    public static DelegatingStatement newInstance
-        (Statement stmnt, Connection conn)  {
-        return ConcreteClassGenerator.newInstance(concreteImpl,
-                Statement.class, stmnt, Connection.class, conn);
+    public static DelegatingStatement newInstance(Statement stmnt, Connection conn)  {
+        return ConcreteClassGenerator.newInstance(concreteImpl, stmnt, conn);
     }
 
     /** 

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/JDBCEventConnectionDecorator.java Wed Sep  9 22:43:49 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.lib.jdbc;
 
+import java.lang.reflect.Constructor;
 import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -37,19 +38,20 @@
 public class JDBCEventConnectionDecorator extends AbstractConcurrentEventManager
     implements ConnectionDecorator {
 
-    private static final Class<EventConnection> eventConnectionImpl;
-    private static final Class<EventStatement> eventStatementImpl;
-    private static final Class<EventPreparedStatement>
+    private static final Constructor<EventConnection> eventConnectionImpl;
+    private static final Constructor<EventStatement> eventStatementImpl;
+    private static final Constructor<EventPreparedStatement>
             eventPreparedStatementImpl;
 
     static {
         try {
-            eventConnectionImpl = ConcreteClassGenerator.
-                makeConcrete(EventConnection.class);
-            eventStatementImpl = ConcreteClassGenerator.
-                makeConcrete(EventStatement.class);
-            eventPreparedStatementImpl = ConcreteClassGenerator.
-                makeConcrete(EventPreparedStatement.class);
+            eventConnectionImpl = ConcreteClassGenerator.getConcreteConstructor(EventConnection.class,
+                JDBCEventConnectionDecorator.class, Connection.class);
+            eventStatementImpl = ConcreteClassGenerator.getConcreteConstructor(EventStatement.class,
+                JDBCEventConnectionDecorator.class, Statement.class, EventConnection.class);
+            eventPreparedStatementImpl = ConcreteClassGenerator.getConcreteConstructor(EventPreparedStatement.class,
+                JDBCEventConnectionDecorator.class, PreparedStatement.class, EventConnection.class, String.class);
+
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }
@@ -60,11 +62,7 @@
         if (!hasListeners())
             return conn;
 
-        return ConcreteClassGenerator.
-            newInstance(eventConnectionImpl,
-                JDBCEventConnectionDecorator.class,
-                    JDBCEventConnectionDecorator.this,
-                Connection.class, conn);
+        return ConcreteClassGenerator.newInstance(eventConnectionImpl, JDBCEventConnectionDecorator.this, conn);
     }
 
     /**
@@ -166,10 +164,7 @@
             Statement stmnt = null;
             try {
                 stmnt = ConcreteClassGenerator.newInstance(eventStatementImpl,
-                        JDBCEventConnectionDecorator.class,
-                            JDBCEventConnectionDecorator.this,
-                        Statement.class, super.createStatement(false),
-                        EventConnection.class, EventConnection.this);
+                            JDBCEventConnectionDecorator.this, super.createStatement(false), EventConnection.this);
             } finally {
                 fireEvent(getDelegate(), JDBCEvent.AFTER_CREATE_STATEMENT,
                     before, stmnt, null);
@@ -202,14 +197,8 @@
                 JDBCEvent.BEFORE_PREPARE_STATEMENT, null, null, sql);
             PreparedStatement stmnt = null;
             try {
-                stmnt = ConcreteClassGenerator.newInstance(
-                    eventPreparedStatementImpl,
-                    JDBCEventConnectionDecorator.class, 
-                    JDBCEventConnectionDecorator.this,
-                    PreparedStatement.class,
-                    super.prepareStatement(sql, false),
-                    EventConnection.class, EventConnection.this,
-                    String.class, sql);
+                stmnt = ConcreteClassGenerator.newInstance(eventPreparedStatementImpl, 
+                    JDBCEventConnectionDecorator.this, super.prepareStatement(sql, false), EventConnection.this, sql);
             } finally {
                 fireEvent(getDelegate(), JDBCEvent.AFTER_PREPARE_STATEMENT,
                     before, stmnt, sql);

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java Wed Sep  9 22:43:49 2009
@@ -20,6 +20,7 @@
 
 import java.io.InputStream;
 import java.io.Reader;
+import java.lang.reflect.Constructor;
 import java.math.BigDecimal;
 import java.sql.Array;
 import java.sql.BatchUpdateException;
@@ -69,12 +70,12 @@
 public class LoggingConnectionDecorator implements ConnectionDecorator {
 
     private static final String SEP = J2DoPrivHelper.getLineSeparator();
-    static final Class<LoggingConnection> loggingConnectionImpl;
-    static final Class<LoggingResultSet> loggingResultSetImpl;
-    static final Class<LoggingStatement> loggingStatementImpl;
-    static final Class<LoggingPreparedStatement> loggingPreparedStatementImpl;
-    static final Class<LoggingCallableStatement> loggingCallableStatementImpl;
-    static final Class<LoggingDatabaseMetaData> loggingDatabaseMetaDataImpl;
+    static final Constructor<LoggingConnection> loggingConnectionImpl;
+    static final Constructor<LoggingResultSet> loggingResultSetImpl;
+    static final Constructor<LoggingStatement> loggingStatementImpl;
+    static final Constructor<LoggingPreparedStatement> loggingPreparedStatementImpl;
+    static final Constructor<LoggingCallableStatement> loggingCallableStatementImpl;
+    static final Constructor<LoggingDatabaseMetaData> loggingDatabaseMetaDataImpl;
 
     private static final int WARN_IGNORE = 0;
     private static final int WARN_LOG_TRACE = 1;
@@ -95,18 +96,23 @@
         WARNING_ACTIONS[WARN_HANDLE] = "handle";
 
         try {
-            loggingConnectionImpl = ConcreteClassGenerator.
-                makeConcrete(LoggingConnection.class);
-            loggingResultSetImpl = ConcreteClassGenerator.
-                makeConcrete(LoggingConnection.LoggingResultSet.class);
-            loggingStatementImpl = ConcreteClassGenerator.
-                makeConcrete(LoggingConnection.LoggingStatement.class);
-            loggingPreparedStatementImpl = ConcreteClassGenerator.
-                makeConcrete(LoggingConnection.LoggingPreparedStatement.class);
-            loggingCallableStatementImpl = ConcreteClassGenerator.
-                makeConcrete(LoggingConnection.LoggingCallableStatement.class);
-            loggingDatabaseMetaDataImpl = ConcreteClassGenerator.
-                makeConcrete(LoggingConnection.LoggingDatabaseMetaData.class);
+            loggingConnectionImpl = ConcreteClassGenerator.getConcreteConstructor(LoggingConnection.class,
+                LoggingConnectionDecorator.class, Connection.class);
+            loggingResultSetImpl = ConcreteClassGenerator.getConcreteConstructor(
+                LoggingConnection.LoggingResultSet.class, 
+                LoggingConnection.class, ResultSet.class, Statement.class);
+            loggingStatementImpl = ConcreteClassGenerator.getConcreteConstructor(
+                LoggingConnection.LoggingStatement.class,
+                LoggingConnection.class, Statement.class);
+            loggingPreparedStatementImpl = ConcreteClassGenerator.getConcreteConstructor(
+                LoggingConnection.LoggingPreparedStatement.class, 
+                LoggingConnection.class, PreparedStatement.class, String.class);
+            loggingCallableStatementImpl = ConcreteClassGenerator.getConcreteConstructor(
+                LoggingConnection.LoggingCallableStatement.class,
+                LoggingConnection.class, CallableStatement.class, String.class);
+            loggingDatabaseMetaDataImpl = ConcreteClassGenerator.getConcreteConstructor(
+                LoggingConnection.LoggingDatabaseMetaData.class,
+                LoggingConnection.class, DatabaseMetaData.class);
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }
@@ -220,10 +226,7 @@
          
     private LoggingConnection newLoggingConnection(Connection conn)
         throws SQLException {
-        return ConcreteClassGenerator.
-            newInstance(loggingConnectionImpl,
-            LoggingConnectionDecorator.class, LoggingConnectionDecorator.this,
-            Connection.class, conn);
+        return ConcreteClassGenerator.newInstance(loggingConnectionImpl, LoggingConnectionDecorator.this, conn);
     }
 
 
@@ -342,36 +345,21 @@
 
         private LoggingPreparedStatement newLoggingPreparedStatement
             (PreparedStatement stmnt, String sql) throws SQLException {
-            return ConcreteClassGenerator.
-                newInstance(loggingPreparedStatementImpl,
-                LoggingConnection.class, LoggingConnection.this,
-                PreparedStatement.class, stmnt,
-                String.class, sql);
+            return ConcreteClassGenerator.newInstance(loggingPreparedStatementImpl, LoggingConnection.this, stmnt, sql);
         }
         
-        private CallableStatement newLoggingCallableStatement
-            (CallableStatement stmnt, String sql) throws SQLException {
-            return ConcreteClassGenerator.
-               newInstance(loggingCallableStatementImpl,
-               LoggingConnection.class, LoggingConnection.this,
-               CallableStatement.class, stmnt,
-               String.class, sql);
-    }
+        private CallableStatement newLoggingCallableStatement(CallableStatement stmnt, String sql) throws SQLException {
+            return ConcreteClassGenerator.newInstance(loggingCallableStatementImpl, LoggingConnection.this, stmnt, sql);
+        }
         
         private LoggingStatement newLoggingStatement(Statement stmnt)
             throws SQLException {
-            return ConcreteClassGenerator.
-                newInstance(loggingStatementImpl,
-                LoggingConnection.class, LoggingConnection.this,
-                Statement.class, stmnt);
+            return ConcreteClassGenerator.newInstance(loggingStatementImpl, LoggingConnection.this, stmnt);
         }
         
         private LoggingDatabaseMetaData newLoggingDatabaseMetaData
             (DatabaseMetaData meta) throws SQLException {
-            return ConcreteClassGenerator.
-                newInstance(loggingDatabaseMetaDataImpl,
-                LoggingConnection.class, LoggingConnection.this,
-                DatabaseMetaData.class, meta);
+            return ConcreteClassGenerator.newInstance(loggingDatabaseMetaDataImpl, LoggingConnection.this, meta);
         }
 
 
@@ -900,13 +888,8 @@
                 super(stmnt, LoggingConnection.this);
             }
 
-            private LoggingResultSet newLoggingResultSet(ResultSet rs,
-                Statement stmnt) {
-                return ConcreteClassGenerator.
-                    newInstance(loggingResultSetImpl,
-                    LoggingConnection.class, LoggingConnection.this,
-                    ResultSet.class, rs,
-                    Statement.class, stmnt);
+            private LoggingResultSet newLoggingResultSet(ResultSet rs, Statement stmnt) {
+                return ConcreteClassGenerator.newInstance(loggingResultSetImpl, LoggingConnection.this, rs, stmnt);
             }
 
             public void appendInfo(StringBuffer buf) {

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/ConcreteClassGenerator.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/ConcreteClassGenerator.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/ConcreteClassGenerator.java (original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/ConcreteClassGenerator.java Wed Sep  9 22:43:49 2009
@@ -18,6 +18,7 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Modifier;
 import java.security.AccessController;
+import java.util.Arrays;
 
 import serp.bytecode.BCClass;
 import serp.bytecode.BCClassLoader;
@@ -29,11 +30,40 @@
  * Dynamically generates concrete implementations of abstract classes.
  *
  * @author Marc Prud'hommeaux
+ * @author Pinaki Poddar
+ * 
  * @nojavadoc
- * @since 0.9.8
+ * @since 1.3.0
  */
 public class ConcreteClassGenerator {
-
+    /**
+     * Get the constructor of the concrete, dynamic wrapper class of the given abstract class 
+     * with matching argument types.
+     * @param the argTypes of the constructor to look for. null signify default constructor.
+     */
+    public static <T> Constructor<T> getConcreteConstructor(Class<T> abstractClass, Class<?>... argTypes)
+    throws ClassNotFoundException {
+        Class<? extends T> cls = makeConcrete(abstractClass);
+        Constructor<?>[] constructors = cls.getConstructors();
+        int args = argTypes == null ? 0 : argTypes.length;
+        for (Constructor<?> cons : constructors) {
+            Class<?>[] params = cons.getParameterTypes();
+            if (params.length != args)
+                continue;
+            boolean match = false;
+            for (int i = 0; i < params.length; i++) {
+                match = params[i].isAssignableFrom(argTypes[i]);
+                if (!match)
+                    break;
+            }
+            if (match) {
+                return (Constructor<T>)cons;
+            }
+        }
+        throw new RuntimeException(abstractClass + " has no constructor with " + 
+                (args == 0 ? "void" : Arrays.toString(argTypes)));
+    }
+    
     /** 
      *  Takes an abstract class and returns a concrete implementation. Note
      *  that it doesn't actually implement any abstract methods, it
@@ -43,7 +73,7 @@
      *  @param  abstractClass  the abstract class
      *  @return a concrete class
      */
-    public static <T> Class<T> makeConcrete(Class<T> abstractClass)
+    public static <T> Class<? extends T> makeConcrete(Class<T> abstractClass)
         throws ClassNotFoundException {
         if (abstractClass == null)
             return null;
@@ -61,13 +91,13 @@
         
         bc.setSuperclass(abstractClass);
 
-        Constructor[] constructors = abstractClass.getConstructors();
+        Constructor<?>[] constructors = abstractClass.getConstructors();
         if (constructors == null || constructors.length == 0) {
             bc.addDefaultConstructor().makePublic();
         } else {
             for (int i = 0; i < constructors.length; i++) {
-                Constructor con = constructors[i];
-                Class[] args = con.getParameterTypes();
+                Constructor<?> con = constructors[i];
+                Class<?>[] args = con.getParameterTypes();
 
                 BCMethod bccon = bc.declareMethod("<init>", void.class, args);
                 Code code = bccon.getCode(true);
@@ -79,8 +109,7 @@
                     code.checkcast().setType(args[j]);
                 }
 
-                code.invokespecial().setMethod(abstractClass,
-                    "<init>", void.class, args);
+                code.invokespecial().setMethod(abstractClass, "<init>", void.class, args);
                 code.vreturn();
 
                 code.calculateMaxStack();
@@ -88,10 +117,23 @@
             }
         }
 
-        Class cls = Class.forName(bc.getName(), false, loader);
-        return cls;
+        Class<?> cls = Class.forName(bc.getName(), false, loader);
+        return (Class<? extends T>)cls;
     }
 
+    /**
+     * Construct a new instance by the given constructor and its arguments.
+     * Hopefully faster than looking for constructor in overloaded implementations. 
+     */
+    public static <T> T newInstance(Constructor<T> cons, Object... params) {
+        try {
+            return cons.newInstance(params);
+        } catch (Exception e) {
+            throw new ExceptionInInitializerError(e);
+        }
+        
+    }
+    
     /** 
      *  Utility method for safely invoking a constructor that we do
      *  not expect to throw exceptions. 

Modified: openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedConnection.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedConnection.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedConnection.java (original)
+++ openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedConnection.java Wed Sep  9 22:43:49 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.slice.jdbc;
 
+import java.lang.reflect.Constructor;
 import java.sql.CallableStatement;
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
@@ -38,11 +39,10 @@
  * 
  */
 public abstract class DistributedConnection implements Connection {
-    static final Class<DistributedConnection> concreteImpl;
+    static final Constructor<DistributedConnection> concreteImpl;
     static {
         try {
-            concreteImpl = ConcreteClassGenerator.
-                makeConcrete(DistributedConnection.class);
+            concreteImpl = ConcreteClassGenerator.getConcreteConstructor(DistributedConnection.class, List.class);
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }
@@ -61,8 +61,7 @@
      *  Constructor for the concrete implementation of this abstract class.
      */
     public static DistributedConnection newInstance(List<Connection> conns) {
-        return ConcreteClassGenerator.newInstance(concreteImpl, 
-            List.class, conns);
+        return ConcreteClassGenerator.newInstance(concreteImpl, conns);
     }
 
     /** 

Modified: openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCStoreManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCStoreManager.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCStoreManager.java (original)
+++ openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedJDBCStoreManager.java Wed Sep  9 22:43:49 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.slice.jdbc;
 
+import java.lang.reflect.Constructor;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.ArrayList;
@@ -82,14 +83,14 @@
     private static final Localizer _loc =
             Localizer.forPackage(DistributedJDBCStoreManager.class);
 
-    private static final Class<ClientConnection> clientConnectionImpl;
-    private static final Class<RefCountConnection> refCountConnectionImpl;
+    private static final Constructor<ClientConnection> clientConnectionImpl;
+    private static final Constructor<RefCountConnection> refCountConnectionImpl;
     static {
         try {
             clientConnectionImpl = ConcreteClassGenerator.
-                makeConcrete(ClientConnection.class);
+                getConcreteConstructor(ClientConnection.class, Connection.class);
             refCountConnectionImpl = ConcreteClassGenerator.
-                makeConcrete(RefCountConnection.class);
+                getConcreteConstructor(RefCountConnection.class, JDBCStoreManager.class, Connection.class);
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }
@@ -364,8 +365,7 @@
     }
 
     public Object getClientConnection() {
-        return ConcreteClassGenerator.newInstance
-            (clientConnectionImpl, Connection.class, getConnection());
+        return ConcreteClassGenerator.newInstance(clientConnectionImpl, getConnection());
     }
 
     public Seq getDataStoreIdSequence(ClassMetaData forClass) {
@@ -480,9 +480,7 @@
         for (SliceStoreManager slice : _slices)
             list.add(slice.getConnection());
         DistributedConnection con = DistributedConnection.newInstance(list);
-        return ConcreteClassGenerator.newInstance(refCountConnectionImpl, 
-            JDBCStoreManager.class, DistributedJDBCStoreManager.this, 
-            Connection.class, con);
+        return ConcreteClassGenerator.newInstance(refCountConnectionImpl, DistributedJDBCStoreManager.this, con);
     }
     
     /**

Modified: openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedPreparedStatement.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedPreparedStatement.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedPreparedStatement.java (original)
+++ openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedPreparedStatement.java Wed Sep  9 22:43:49 2009
@@ -20,6 +20,7 @@
 
 import java.io.InputStream;
 import java.io.Reader;
+import java.lang.reflect.Constructor;
 import java.math.BigDecimal;
 import java.net.URL;
 import java.sql.Array;
@@ -49,11 +50,11 @@
     extends DistributedTemplate<PreparedStatement> 
     implements PreparedStatement {
 
-    static final Class<DistributedPreparedStatement> concreteImpl;
+    static final Constructor<DistributedPreparedStatement> concreteImpl;
     static {
         try {
-            concreteImpl = ConcreteClassGenerator.
-                makeConcrete(DistributedPreparedStatement.class);
+            concreteImpl = ConcreteClassGenerator.getConcreteConstructor(DistributedPreparedStatement.class, 
+                    DistributedConnection.class);
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }
@@ -63,11 +64,9 @@
 		super(c);
 	}
 	
-    public static DistributedPreparedStatement newInstance(
-        DistributedConnection conn) {
-    return ConcreteClassGenerator.newInstance(concreteImpl, 
-        DistributedConnection.class, conn);
-}
+    public static DistributedPreparedStatement newInstance(DistributedConnection conn) {
+        return ConcreteClassGenerator.newInstance(concreteImpl, conn);
+    }
 
 	public void clearParameters() throws SQLException {
 		for (PreparedStatement s : this)

Modified: openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedResultSet.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedResultSet.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedResultSet.java (original)
+++ openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedResultSet.java Wed Sep  9 22:43:49 2009
@@ -20,6 +20,7 @@
 
 import java.io.InputStream;
 import java.io.Reader;
+import java.lang.reflect.Constructor;
 import java.math.BigDecimal;
 import java.net.URL;
 import java.sql.Array;
@@ -49,12 +50,11 @@
  *
  */
 public abstract class DistributedResultSet implements ResultSet {
-    static final Class<DistributedResultSet> concreteImpl;
+    static final Constructor<DistributedResultSet> concreteImpl;
 
     static {
         try {
-            concreteImpl = ConcreteClassGenerator.
-                makeConcrete(DistributedResultSet.class);
+            concreteImpl = ConcreteClassGenerator.getConcreteConstructor(DistributedResultSet.class);
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }

Modified: openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStatement.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStatement.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStatement.java (original)
+++ openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedStatement.java Wed Sep  9 22:43:49 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.slice.jdbc;
 
+import java.lang.reflect.Constructor;
 import java.sql.Statement;
 
 import org.apache.openjpa.lib.util.ConcreteClassGenerator;
@@ -30,12 +31,12 @@
  */
 public abstract class DistributedStatement extends
     DistributedTemplate<Statement> {
-    static final Class<DistributedStatement> concreteImpl;
+    static final Constructor<DistributedStatement> concreteImpl;
 
     static {
         try {
-            concreteImpl = ConcreteClassGenerator.makeConcrete(
-                DistributedStatement.class);
+            concreteImpl = ConcreteClassGenerator.getConcreteConstructor(DistributedStatement.class, 
+                DistributedConnection.class);
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }
@@ -46,7 +47,6 @@
     }
 
     public static DistributedStatement newInstance(DistributedConnection conn) {
-        return ConcreteClassGenerator.newInstance(concreteImpl, 
-            DistributedConnection.class, conn);
+        return ConcreteClassGenerator.newInstance(concreteImpl, conn);
     }
 }

Modified: openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedTemplate.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedTemplate.java?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedTemplate.java (original)
+++ openjpa/trunk/openjpa-slice/src/main/java/org/apache/openjpa/slice/jdbc/DistributedTemplate.java Wed Sep  9 22:43:49 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.slice.jdbc;
 
+import java.lang.reflect.Constructor;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -37,12 +38,12 @@
  */
 public abstract class DistributedTemplate<T extends Statement> 
 	implements Statement, Iterable<T> {
-    static final Class<DistributedTemplate> concreteImpl;
+    static final Constructor<DistributedTemplate> concreteImpl;
 
     static {
         try {
-            concreteImpl = ConcreteClassGenerator.
-                makeConcrete(DistributedTemplate.class);
+            concreteImpl = ConcreteClassGenerator.getConcreteConstructor(DistributedTemplate.class, 
+                DistributedConnection.class);
         } catch (Exception e) {
             throw new ExceptionInInitializerError(e);
         }
@@ -56,6 +57,10 @@
 		con = c;
 	}
 	
+    public static DistributedTemplate newInstance(DistributedConnection conn) {
+        return ConcreteClassGenerator.newInstance(concreteImpl, conn);
+    }
+    
 	public Iterator<T> iterator() {
 		return stmts.iterator();
 	}

Modified: openjpa/trunk/openjpa-slice/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-slice/src/test/resources/META-INF/persistence.xml?rev=813149&r1=813148&r2=813149&view=diff
==============================================================================
--- openjpa/trunk/openjpa-slice/src/test/resources/META-INF/persistence.xml (original)
+++ openjpa/trunk/openjpa-slice/src/test/resources/META-INF/persistence.xml Wed Sep  9 22:43:49 2009
@@ -46,6 +46,8 @@
          <property name="openjpa.slice.Two.ConnectionURL"   value="jdbc:derby:target/database/openjpa-slice2;create=true"/>
          <property name="openjpa.slice.Three.ConnectionURL" value="jdbc:some-bad-url"/>
          
+         <property name="openjpa.DynamicEnhancementAgent"   value="false"/>
+         
       </properties>
    </persistence-unit>
 
@@ -68,7 +70,9 @@
          <property name="openjpa.Multithreaded" value="false"/>
          <property name="openjpa.jdbc.SynchronizeMappings" value="refresh"/>
          <property name="openjpa.jdbc.MappingDefaults" value="DefaultMissingInfo=true"/>
-         <property name="openjpa.RuntimeUnenhancedClasses" value="supported"/>
+         
+         <property name="openjpa.RuntimeUnenhancedClasses" value="unsupported"/>
+         <property name="openjpa.DynamicEnhancementAgent"   value="false"/>
       </properties>
    </persistence-unit>
    
@@ -96,7 +100,9 @@
 	        <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
             <property name="openjpa.QueryCompilationCache" value="false"/>
             <property name="openjpa.jdbc.MappingDefaults" value="DefaultMissingInfo=true"/>
-            <property name="openjpa.RuntimeUnenhancedClasses" value="supported"/>
+            
+            <property name="openjpa.RuntimeUnenhancedClasses" value="unsupported"/>
+            <property name="openjpa.DynamicEnhancementAgent"   value="false"/>
       	</properties>
    </persistence-unit>
    
@@ -120,6 +126,8 @@
             <property name="openjpa.Connection2URL" value="jdbc:derby:target/database/openjpa-slice1;create=true"/>
             <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
             <property name="openjpa.jdbc.MappingDefaults" value="DefaultMissingInfo=true"/>
+            <property name="openjpa.RuntimeUnenhancedClasses" value="unsupported"/>
+            <property name="openjpa.DynamicEnhancementAgent"   value="false"/>
         </properties>
    </persistence-unit>
    
@@ -141,7 +149,8 @@
          <property name="openjpa.Multithreaded" value="false"/>
          <property name="openjpa.jdbc.SynchronizeMappings" value="refresh"/>
          <property name="openjpa.jdbc.MappingDefaults" value="DefaultMissingInfo=true"/>
-         <property name="openjpa.RuntimeUnenhancedClasses" value="supported"/>
+            <property name="openjpa.RuntimeUnenhancedClasses" value="unsupported"/>
+            <property name="openjpa.DynamicEnhancementAgent"   value="false"/>
       </properties>
    </persistence-unit>
    
@@ -166,7 +175,8 @@
          <property name="openjpa.Log" value="DefaultLevel=INFO, Enhance=TRACE, SQL=TRACE"/>
          <property name="openjpa.jdbc.SynchronizeMappings" value="refresh"/>
          <property name="openjpa.jdbc.MappingDefaults" value="DefaultMissingInfo=true"/>
-         <property name="openjpa.RuntimeUnenhancedClasses" value="supported"/>
+            <property name="openjpa.RuntimeUnenhancedClasses" value="unsupported"/>
+            <property name="openjpa.DynamicEnhancementAgent"   value="false"/>
       </properties>
    </persistence-unit>
    



Mime
View raw message