svn commit: r1612909 - in /ofbiz/trunk: ./ framework/base/lib/commons/ framework/entity/lib/ framework/entity/src/org/ofbiz/entity/connection/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1612909 - in /ofbiz/trunk: ./ framework/base/lib/commons/ framework/entity/lib/ framework/entity/src/org/ofbiz/entity/connection/

jacopoc
Author: jacopoc
Date: Wed Jul 23 18:26:33 2014
New Revision: 1612909

URL: http://svn.apache.org/r1612909
Log:
Upgrade to Commons DBCP 2; this new version is designed for Java 7 (JDBC 4.1).
Commons DBCP 2 relies on Commons Pool 2 and this commits upgrades that jar too.

Added:
    ofbiz/trunk/framework/base/lib/commons/commons-pool2-2.2.jar   (with props)
    ofbiz/trunk/framework/entity/lib/commons-dbcp2-2.0.1.jar   (with props)
Removed:
    ofbiz/trunk/framework/base/lib/commons/commons-pool-1.5.7.jar
    ofbiz/trunk/framework/entity/lib/commons-dbcp-1.4.jar
Modified:
    ofbiz/trunk/.classpath
    ofbiz/trunk/LICENSE
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java

Modified: ofbiz/trunk/.classpath
URL: http://svn.apache.org/viewvc/ofbiz/trunk/.classpath?rev=1612909&r1=1612908&r2=1612909&view=diff
==============================================================================
--- ofbiz/trunk/.classpath (original)
+++ ofbiz/trunk/.classpath Wed Jul 23 18:26:33 2014
@@ -73,7 +73,7 @@
     <classpathentry kind="lib" path="framework/base/lib/commons/commons-logging-1.1.2.jar"/>
     <classpathentry kind="lib" path="framework/base/lib/commons/commons-modeler-2.0.1.jar"/>
     <classpathentry kind="lib" path="framework/base/lib/commons/commons-net-3.1.jar"/>
-    <classpathentry kind="lib" path="framework/base/lib/commons/commons-pool-1.5.7.jar"/>
+    <classpathentry kind="lib" path="framework/base/lib/commons/commons-pool2-2.2.jar"/>
     <classpathentry kind="lib" path="framework/base/lib/commons/commons-primitives-1.0.jar"/>
     <classpathentry kind="lib" path="framework/base/lib/commons/commons-validator-1.4.0.jar"/>
     <classpathentry kind="lib" path="framework/base/lib/commons/commons-csv-1.0.jar"/>
@@ -110,7 +110,7 @@
     <classpathentry kind="lib" path="framework/catalina/lib/tomcat-7.0.54-tomcat-util.jar"/>
     <classpathentry kind="lib" path="framework/catalina/lib/tomcat-extras-7.0.54-tomcat-juli.jar"/>
     <classpathentry kind="lib" path="framework/catalina/lib/tomcat-extras-7.0.54-tomcat-juli-adapters.jar"/>
-    <classpathentry kind="lib" path="framework/entity/lib/commons-dbcp-1.4.jar"/>
+    <classpathentry kind="lib" path="framework/entity/lib/commons-dbcp2-2.0.1.jar"/>
     <classpathentry kind="lib" path="framework/geronimo/lib/geronimo-connector-3.1.1.jar"/>
     <classpathentry kind="lib" path="framework/geronimo/lib/geronimo-transaction-3.1.1.jar"/>
     <classpathentry kind="lib" path="specialpurpose/jetty/lib/com.sun.el-2.2.0.v201108011116.jar"/>

Modified: ofbiz/trunk/LICENSE
URL: http://svn.apache.org/viewvc/ofbiz/trunk/LICENSE?rev=1612909&r1=1612908&r2=1612909&view=diff
==============================================================================
--- ofbiz/trunk/LICENSE (original)
+++ ofbiz/trunk/LICENSE Wed Jul 23 18:26:33 2014
@@ -54,7 +54,7 @@ framework/base/lib/commons/commons-lang-
 framework/base/lib/commons/commons-logging-1.1.2.jar
 framework/base/lib/commons/commons-modeler-2.0.1.jar
 framework/base/lib/commons/commons-net-3.1.jar
-framework/base/lib/commons/commons-pool-1.5.7.jar
+framework/base/lib/commons/commons-pool2-2.2.jar
 framework/base/lib/commons/commons-primitives-1.0.jar
 framework/base/lib/commons/commons-validator-1.4.0.jar
 framework/base/lib/j2eespecs/geronimo-activation_1.0.2_spec-1.0.jar
@@ -84,7 +84,7 @@ framework/catalina/lib/tomcat-7.0.54-tom
 framework/catalina/lib/tomcat-7.0.54-tomcat-util.jar
 framework/catalina/lib/tomcat-extras-7.0.54-tomcat-juli.jar
 framework/catalina/lib/tomcat-extras-7.0.54-tomcat-juli-adapters.jar
-framework/entity/lib/commons-dbcp-1.4.jar
+framework/entity/lib/commons-dbcp2-2.0.1.jar
 framework/entity/lib/jdbc/derby-10.10.1.1.jar
 framework/entity/lib/jdbc/derbytools-10.8.2.2.jar
 framework/service/lib/axiom-api-1.2.9.jar

Added: ofbiz/trunk/framework/base/lib/commons/commons-pool2-2.2.jar
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/lib/commons/commons-pool2-2.2.jar?rev=1612909&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ofbiz/trunk/framework/base/lib/commons/commons-pool2-2.2.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: ofbiz/trunk/framework/entity/lib/commons-dbcp2-2.0.1.jar
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/lib/commons-dbcp2-2.0.1.jar?rev=1612909&view=auto
==============================================================================
Binary file - no diff available.

Propchange: ofbiz/trunk/framework/entity/lib/commons-dbcp2-2.0.1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java?rev=1612909&r1=1612908&r2=1612909&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DBCPConnectionFactory.java Wed Jul 23 18:26:33 2014
@@ -28,14 +28,15 @@ import java.util.concurrent.ConcurrentHa
 
 import javax.transaction.TransactionManager;
 
-import org.apache.commons.dbcp.ConnectionFactory;
-import org.apache.commons.dbcp.DriverConnectionFactory;
-import org.apache.commons.dbcp.PoolableConnectionFactory;
-import org.apache.commons.dbcp.managed.LocalXAConnectionFactory;
-import org.apache.commons.dbcp.managed.ManagedDataSource;
-import org.apache.commons.dbcp.managed.PoolableManagedConnectionFactory;
-import org.apache.commons.dbcp.managed.XAConnectionFactory;
-import org.apache.commons.pool.impl.GenericObjectPool;
+import org.apache.commons.dbcp2.ConnectionFactory;
+import org.apache.commons.dbcp2.DriverConnectionFactory;
+import org.apache.commons.dbcp2.PoolableConnectionFactory;
+import org.apache.commons.dbcp2.managed.LocalXAConnectionFactory;
+import org.apache.commons.dbcp2.managed.ManagedDataSource;
+import org.apache.commons.dbcp2.managed.PoolableManagedConnectionFactory;
+import org.apache.commons.dbcp2.managed.XAConnectionFactory;
+import org.apache.commons.pool2.impl.GenericObjectPool;
+import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.entity.GenericEntityConfException;
 import org.ofbiz.entity.GenericEntityException;
@@ -103,20 +104,10 @@ public class DBCPConnectionFactory imple
         // wrap it with a LocalXAConnectionFactory
         XAConnectionFactory xacf = new LocalXAConnectionFactory(txMgr, cf);
 
-        // configure the pool settings
-        GenericObjectPool pool = new GenericObjectPool();
-
-        pool.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
-        pool.setMaxActive(maxSize);
-        pool.setMaxIdle(maxIdle);
-        pool.setMinIdle(minSize);
-        pool.setMaxWait(120000);
-
         // create the pool object factory
-        PoolableConnectionFactory factory = new PoolableManagedConnectionFactory(xacf, pool, null, null, true, true);
+        PoolableConnectionFactory factory = new PoolableManagedConnectionFactory(xacf, null);
         factory.setValidationQuery("select 1 from entity_key_store where key_name = ''");
         factory.setDefaultReadOnly(false);
-
         String transIso = jdbcElement.getIsolationLevel();
         if (!transIso.isEmpty()) {
             if ("Serializable".equals(transIso)) {
@@ -131,7 +122,15 @@ public class DBCPConnectionFactory imple
                 factory.setDefaultTransactionIsolation(Connection.TRANSACTION_NONE);
             }
         }
-        pool.setFactory(factory);
+
+        // configure the pool settings
+        GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
+        poolConfig.setMaxWaitMillis(120000);
+        poolConfig.setMaxTotal(maxSize);
+        poolConfig.setMaxIdle(maxIdle);
+        poolConfig.setMinIdle(minSize);
+        poolConfig.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
+        GenericObjectPool pool = new GenericObjectPool(factory, poolConfig);
 
         // mds = new ManagedDataSource(pool, xacf.getTransactionRegistry());
         mds = new DebugManagedDataSource(pool, xacf.getTransactionRegistry()); // Useful to debug the usage of connections in the pool

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java?rev=1612909&r1=1612908&r2=1612909&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/connection/DebugManagedDataSource.java Wed Jul 23 18:26:33 2014
@@ -19,11 +19,11 @@
 
 package org.ofbiz.entity.connection;
 
-import org.apache.commons.dbcp.managed.ManagedDataSource;
-import org.apache.commons.dbcp.managed.TransactionRegistry;
-import org.apache.commons.pool.ObjectPool;
+import org.apache.commons.dbcp2.managed.ManagedDataSource;
+import org.apache.commons.dbcp2.managed.TransactionRegistry;
+import org.apache.commons.pool2.ObjectPool;
 
-import org.apache.commons.pool.impl.GenericObjectPool;
+import org.apache.commons.pool2.impl.GenericObjectPool;
 import org.ofbiz.base.util.Debug;
 
 import java.sql.Connection;
@@ -35,9 +35,6 @@ public class DebugManagedDataSource exte
 
     public static final String module = DebugManagedDataSource.class.getName();
 
-    public DebugManagedDataSource() {
-        super();
-    }
     public DebugManagedDataSource(ObjectPool pool, TransactionRegistry transactionRegistry) {
         super(pool, transactionRegistry);
     }
@@ -45,11 +42,11 @@ public class DebugManagedDataSource exte
     @Override
     public Connection getConnection() throws SQLException {
         if (Debug.verboseOn()) {
-            if (super._pool instanceof GenericObjectPool) {
-                GenericObjectPool objectPool = (GenericObjectPool)super._pool;
-                Debug.logVerbose("Borrowing a connection from the pool; used/total: " + objectPool.getNumActive() + "/" + objectPool.getNumActive() + objectPool.getNumIdle() + "; min idle/max idle/max total: " + objectPool.getMinIdle() + "/" + objectPool.getMaxIdle() + "/" + objectPool.getMaxActive(), module);
+            if (super.getPool() instanceof GenericObjectPool) {
+                GenericObjectPool objectPool = (GenericObjectPool)super.getPool();
+                Debug.logVerbose("Borrowing a connection from the pool; used/total: " + objectPool.getNumActive() + "/" + objectPool.getNumActive() + objectPool.getNumIdle() + "; min idle/max idle/max total: " + objectPool.getMinIdle() + "/" + objectPool.getMaxIdle() + "/" + objectPool.getMaxTotal(), module);
             } else {
-                Debug.logVerbose("Borrowing a connection from the pool; used/total: " + super._pool.getNumActive() + "/" + (super._pool.getNumActive() + super._pool.getNumIdle()), module);
+                Debug.logVerbose("Borrowing a connection from the pool; used/total: " + super.getPool().getNumActive() + "/" + (super.getPool().getNumActive() + super.getPool().getNumIdle()), module);
             }
         }
         return super.getConnection();
@@ -57,14 +54,14 @@ public class DebugManagedDataSource exte
 
     public Map<String, Object> getInfo() {
         Map<String, Object> dataSourceInfo = new HashMap<String, Object>();
-        dataSourceInfo.put("poolNumActive", super._pool.getNumActive());
-        dataSourceInfo.put("poolNumIdle", super._pool.getNumIdle());
-        dataSourceInfo.put("poolNumTotal", (super._pool.getNumIdle() + super._pool.getNumActive()));
-        if (super._pool instanceof GenericObjectPool) {
-            GenericObjectPool objectPool = (GenericObjectPool)super._pool;
-            dataSourceInfo.put("poolMaxActive", objectPool.getMaxActive());
+        dataSourceInfo.put("poolNumActive", super.getPool().getNumActive());
+        dataSourceInfo.put("poolNumIdle", super.getPool().getNumIdle());
+        dataSourceInfo.put("poolNumTotal", (super.getPool().getNumIdle() + super.getPool().getNumActive()));
+        if (super.getPool() instanceof GenericObjectPool) {
+            GenericObjectPool objectPool = (GenericObjectPool)super.getPool();
+            dataSourceInfo.put("poolMaxActive", objectPool.getMaxTotal());
             dataSourceInfo.put("poolMaxIdle", objectPool.getMaxIdle());
-            dataSourceInfo.put("poolMaxWait", objectPool.getMaxWait());
+            dataSourceInfo.put("poolMaxWait", objectPool.getMaxWaitMillis());
             dataSourceInfo.put("poolMinEvictableIdleTimeMillis", objectPool.getMinEvictableIdleTimeMillis());
             dataSourceInfo.put("poolMinIdle", objectPool.getMinIdle());
         }