Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 39175 invoked from network); 9 Jan 2011 02:27:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 9 Jan 2011 02:27:22 -0000 Received: (qmail 71056 invoked by uid 500); 9 Jan 2011 02:27:21 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 71011 invoked by uid 500); 9 Jan 2011 02:27:21 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 71004 invoked by uid 99); 9 Jan 2011 02:27:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Jan 2011 02:27:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Jan 2011 02:27:18 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BDCE723889E2; Sun, 9 Jan 2011 02:26:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1056867 - in /commons/proper/dbcp: branches/DBCP_1_4_x_BRANCH/src/changes/ branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/ branches/DBCP_1_4_x_BRANCH/src/site/xdoc/ branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/ ... Date: Sun, 09 Jan 2011 02:26:56 -0000 To: commits@commons.apache.org From: psteitz@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110109022656.BDCE723889E2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: psteitz Date: Sun Jan 9 02:26:55 2011 New Revision: 1056867 URL: http://svn.apache.org/viewvc?rev=1056867&view=rev Log: Exposed pool LIFO property as config option for DBCP. JIRA: DBCP-346 Reported and patched by Ken Tatsushita Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/changes/changes.xml commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/BasicDataSource.java commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/BasicDataSourceFactory.java commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/site/xdoc/configuration.xml commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TestBasicDataSourceFactory.java commons/proper/dbcp/trunk/src/changes/changes.xml commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/BasicDataSource.java commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/BasicDataSourceFactory.java commons/proper/dbcp/trunk/src/site/xdoc/configuration.xml commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSourceFactory.java Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/changes/changes.xml?rev=1056867&r1=1056866&r2=1056867&view=diff ============================================================================== --- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/changes/changes.xml (original) +++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/changes/changes.xml Sun Jan 9 02:26:55 2011 @@ -39,12 +39,17 @@ The type attribute can be add,u - + + LIFO configuration option has been added to BasicDataSource. When set + to true (the default), the pool acts as a LIFO queue; setting to false + causes connections to enter and exit to pool in FIFO order. + + Test transitive dependencies brought in by geronimo-transaction created version conflicts (commons logging and junit). These have been explicitly excluded in the POM. - BasicDataSourceFactory incorrectly used "initConnectSqls" in versions 1.3 and 1.4 of DBCP as the property name for connectionInitSqls. Online docs for 1.3/1/4 have been updated to reflect this inconsistency. Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/BasicDataSource.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/BasicDataSource.java?rev=1056867&r1=1056866&r2=1056867&view=diff ============================================================================== --- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/BasicDataSource.java (original) +++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/BasicDataSource.java Sun Jan 9 02:26:55 2011 @@ -261,6 +261,39 @@ public class BasicDataSource implements } /** + * True means that borrowObject returns the most recently used ("last in") + * connection in the pool (if there are idle connections available). False + * means that the pool behaves as a FIFO queue - connections are taken from + * the idle instance pool in the order that they are returned to the pool. + */ + private boolean lifo = GenericObjectPool.DEFAULT_LIFO; + + /** + * Returns the LIFO property. + * + * @return true if connection pool behaves as a LIFO queue. + * + * @see #lifo + */ + public synchronized boolean getLifo() { + return this.lifo; + } + + /** + * Sets the LIFO property. True means the pool behaves as a LIFO queue; + * false means FIFO. + * + * @param lifo the new value for the LIFO property + * + */ + public synchronized void setLifo(boolean lifo) { + this.lifo = lifo; + if (connectionPool != null) { + connectionPool.setLifo(lifo); + } + } + + /** * The maximum number of active connections that can be allocated from * this pool at the same time, or negative for no limit. */ @@ -1510,6 +1543,7 @@ public class BasicDataSource implements gop.setNumTestsPerEvictionRun(numTestsPerEvictionRun); gop.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); gop.setTestWhileIdle(testWhileIdle); + gop.setLifo(lifo); connectionPool = gop; } Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/BasicDataSourceFactory.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/BasicDataSourceFactory.java?rev=1056867&r1=1056866&r2=1056867&view=diff ============================================================================== --- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/BasicDataSourceFactory.java (original) +++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/java/org/apache/commons/dbcp/BasicDataSourceFactory.java Sun Jan 9 02:26:55 2011 @@ -50,6 +50,7 @@ public class BasicDataSourceFactory impl private final static String PROP_DEFAULTTRANSACTIONISOLATION = "defaultTransactionIsolation"; private final static String PROP_DEFAULTCATALOG = "defaultCatalog"; private final static String PROP_DRIVERCLASSNAME = "driverClassName"; + private final static String PROP_LIFO = "lifo"; private final static String PROP_MAXACTIVE = "maxActive"; private final static String PROP_MAXIDLE = "maxIdle"; private final static String PROP_MINIDLE = "minIdle"; @@ -86,6 +87,7 @@ public class BasicDataSourceFactory impl PROP_DEFAULTTRANSACTIONISOLATION, PROP_DEFAULTCATALOG, PROP_DRIVERCLASSNAME, + PROP_LIFO, PROP_MAXACTIVE, PROP_MAXIDLE, PROP_MINIDLE, @@ -218,6 +220,11 @@ public class BasicDataSourceFactory impl dataSource.setDriverClassName(value); } + value = properties.getProperty(PROP_LIFO); + if (value != null) { + dataSource.setLifo(Boolean.valueOf(value).booleanValue()); + } + value = properties.getProperty(PROP_MAXACTIVE); if (value != null) { dataSource.setMaxActive(Integer.parseInt(value)); Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/site/xdoc/configuration.xml URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/site/xdoc/configuration.xml?rev=1056867&r1=1056866&r2=1056867&view=diff ============================================================================== --- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/site/xdoc/configuration.xml (original) +++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/site/xdoc/configuration.xml Sun Jan 9 02:26:55 2011 @@ -257,6 +257,16 @@ one row. only once - when the configured connection factory creates the connection. + + lifo + true + + True means that borrowObject returns the most recently used ("last in") + connection in the pool (if there are idle connections available). False + means that the pool behaves as a FIFO queue - connections are taken from + the idle instance pool in the order that they are returned to the pool. + + Modified: commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TestBasicDataSourceFactory.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TestBasicDataSourceFactory.java?rev=1056867&r1=1056866&r2=1056867&view=diff ============================================================================== --- commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TestBasicDataSourceFactory.java (original) +++ commons/proper/dbcp/branches/DBCP_1_4_x_BRANCH/src/test/org/apache/commons/dbcp/TestBasicDataSourceFactory.java Sun Jan 9 02:26:55 2011 @@ -79,6 +79,7 @@ public class TestBasicDataSourceFactory properties.setProperty("logAbandoned", "true"); properties.setProperty("poolPreparedStatements", "true"); properties.setProperty("maxOpenPreparedStatements", "10"); + properties.setProperty("lifo", "true"); BasicDataSource ds = (BasicDataSource) BasicDataSourceFactory.createDataSource(properties); @@ -113,5 +114,6 @@ public class TestBasicDataSourceFactory assertEquals(true, ds.getLogAbandoned()); assertEquals(true, ds.isPoolPreparedStatements()); assertEquals(10, ds.getMaxOpenPreparedStatements()); + assertEquals(true, ds.getLifo()); } } Modified: commons/proper/dbcp/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/changes/changes.xml?rev=1056867&r1=1056866&r2=1056867&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/changes/changes.xml (original) +++ commons/proper/dbcp/trunk/src/changes/changes.xml Sun Jan 9 02:26:55 2011 @@ -38,13 +38,20 @@ The type attribute can be add,u Commons DBCP Release Notes + + - + + LIFO configuration option has been added to BasicDataSource. When set + to true (the default), the pool acts as a LIFO queue; setting to false + causes connections to enter and exit to pool in FIFO order. + + Test transitive dependencies brought in by geronimo-transaction created version conflicts (commons logging and junit). These have been explicitly excluded in the POM. - BasicDataSourceFactory incorrectly used "initConnectSqls" in versions 1.3 and 1.4 of DBCP as the property name for connectionInitSqls. Online docs for 1.3/1/4 have been updated to reflect this inconsistency. Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/BasicDataSource.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/BasicDataSource.java?rev=1056867&r1=1056866&r2=1056867&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/BasicDataSource.java (original) +++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/BasicDataSource.java Sun Jan 9 02:26:55 2011 @@ -261,6 +261,39 @@ public class BasicDataSource implements } /** + * True means that borrowObject returns the most recently used ("last in") + * connection in the pool (if there are idle connections available). False + * means that the pool behaves as a FIFO queue - connections are taken from + * the idle instance pool in the order that they are returned to the pool. + */ + private boolean lifo = GenericObjectPool.DEFAULT_LIFO; + + /** + * Returns the LIFO property. + * + * @return true if connection pool behaves as a LIFO queue. + * + * @see #lifo + */ + public synchronized boolean getLifo() { + return this.lifo; + } + + /** + * Sets the LIFO property. True means the pool behaves as a LIFO queue; + * false means FIFO. + * + * @param lifo the new value for the LIFO property + * + */ + public synchronized void setLifo(boolean lifo) { + this.lifo = lifo; + if (connectionPool != null) { + connectionPool.setLifo(lifo); + } + } + + /** * The maximum number of active connections that can be allocated from * this pool at the same time, or negative for no limit. */ @@ -1510,6 +1543,7 @@ public class BasicDataSource implements gop.setNumTestsPerEvictionRun(numTestsPerEvictionRun); gop.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); gop.setTestWhileIdle(testWhileIdle); + gop.setLifo(lifo); connectionPool = gop; } Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/BasicDataSourceFactory.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/BasicDataSourceFactory.java?rev=1056867&r1=1056866&r2=1056867&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/BasicDataSourceFactory.java (original) +++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/BasicDataSourceFactory.java Sun Jan 9 02:26:55 2011 @@ -50,6 +50,7 @@ public class BasicDataSourceFactory impl private final static String PROP_DEFAULTTRANSACTIONISOLATION = "defaultTransactionIsolation"; private final static String PROP_DEFAULTCATALOG = "defaultCatalog"; private final static String PROP_DRIVERCLASSNAME = "driverClassName"; + private final static String PROP_LIFO = "lifo"; private final static String PROP_MAXACTIVE = "maxActive"; private final static String PROP_MAXIDLE = "maxIdle"; private final static String PROP_MINIDLE = "minIdle"; @@ -86,6 +87,7 @@ public class BasicDataSourceFactory impl PROP_DEFAULTTRANSACTIONISOLATION, PROP_DEFAULTCATALOG, PROP_DRIVERCLASSNAME, + PROP_LIFO, PROP_MAXACTIVE, PROP_MAXIDLE, PROP_MINIDLE, @@ -218,6 +220,11 @@ public class BasicDataSourceFactory impl dataSource.setDriverClassName(value); } + value = properties.getProperty(PROP_LIFO); + if (value != null) { + dataSource.setLifo(Boolean.valueOf(value).booleanValue()); + } + value = properties.getProperty(PROP_MAXACTIVE); if (value != null) { dataSource.setMaxActive(Integer.parseInt(value)); Modified: commons/proper/dbcp/trunk/src/site/xdoc/configuration.xml URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/site/xdoc/configuration.xml?rev=1056867&r1=1056866&r2=1056867&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/site/xdoc/configuration.xml (original) +++ commons/proper/dbcp/trunk/src/site/xdoc/configuration.xml Sun Jan 9 02:26:55 2011 @@ -250,6 +250,16 @@ one row. only once - when the configured connection factory creates the connection. + + + + +
lifotrue + True means that borrowObject returns the most recently used ("last in") + connection in the pool (if there are idle connections available). False + means that the pool behaves as a FIFO queue - connections are taken from + the idle instance pool in the order that they are returned to the pool. +
Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSourceFactory.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSourceFactory.java?rev=1056867&r1=1056866&r2=1056867&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSourceFactory.java (original) +++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestBasicDataSourceFactory.java Sun Jan 9 02:26:55 2011 @@ -79,6 +79,7 @@ public class TestBasicDataSourceFactory properties.setProperty("logAbandoned", "true"); properties.setProperty("poolPreparedStatements", "true"); properties.setProperty("maxOpenPreparedStatements", "10"); + properties.setProperty("lifo", "true"); BasicDataSource ds = (BasicDataSource) BasicDataSourceFactory.createDataSource(properties); @@ -113,5 +114,6 @@ public class TestBasicDataSourceFactory assertEquals(true, ds.getLogAbandoned()); assertEquals(true, ds.isPoolPreparedStatements()); assertEquals(10, ds.getMaxOpenPreparedStatements()); + assertEquals(true, ds.getLifo()); } }