[prev in list] [next in list] [prev in thread] [next in thread]
List: turbine-torque-dev
Subject: svn commit: r1754167 - in /db/torque/torque4/trunk/torque-runtime: ./ src/main/java/org/apache/torqu
From: tv () apache ! org
Date: 2016-07-26 18:43:48
Message-ID: 20160726184349.6E7C23A02CB () svn01-us-west ! apache ! org
[Download RAW message or body]
Author: tv
Date: Tue Jul 26 18:43:48 2016
New Revision: 1754167
URL: http://svn.apache.org/viewvc?rev=1754167&view=rev
Log:
TORQUE-344 Attempt to support DBCP2
Added:
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/PerUserPool2DataSourceFactory.java \
(with props) db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/SharedPool2DataSourceFactory.java \
(with props) Modified:
db/torque/torque4/trunk/torque-runtime/pom.xml
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/AbstractDataSourceFactory.java
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/PerUserPoolDataSourceFactory.java
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/SharedPoolDataSourceFactory.java
Modified: db/torque/torque4/trunk/torque-runtime/pom.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/pom.xml?rev=1754167&r1=1754166&r2=1754167&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/pom.xml (original)
+++ db/torque/torque4/trunk/torque-runtime/pom.xml Tue Jul 26 18:43:48 2016
@@ -39,12 +39,6 @@
<dependencies>
<dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <version>3.2.2</version>
- </dependency>
-
- <dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.10</version>
@@ -60,6 +54,14 @@
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
+ <optional>true</optional>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-dbcp2</artifactId>
+ <version>2.1.1</version>
+ <optional>true</optional>
</dependency>
<dependency>
Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/AbstractDataSourceFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java \
/org/apache/torque/dsfactory/AbstractDataSourceFactory.java?rev=1754167&r1=1754166&r2=1754167&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/AbstractDataSourceFactory.java \
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/AbstractDataSourceFactory.java \
Tue Jul 26 18:43:48 2016 @@ -28,8 +28,6 @@ import org.apache.commons.beanutils.Conv
import org.apache.commons.beanutils.MappedPropertyDescriptor;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.configuration.Configuration;
-import org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS;
-import org.apache.commons.dbcp.datasources.InstanceKeyDataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.torque.Torque;
@@ -209,14 +207,13 @@ public abstract class AbstractDataSource
* Initializes the ConnectionPoolDataSource.
*
* @param configuration where to read the settings from
+ * @param cpds data source to configure
* @throws TorqueException if a property set fails
- * @return a configured <code>ConnectionPoolDataSource</code>
*/
- protected ConnectionPoolDataSource initCPDS(final Configuration configuration)
+ protected void initCPDS(final Configuration configuration, final \
ConnectionPoolDataSource cpds) throws TorqueException
{
log.debug("Starting initCPDS");
- ConnectionPoolDataSource cpds = new DriverAdapterCPDS();
Configuration c = Torque.getConfiguration();
if (c == null || c.isEmpty())
@@ -232,8 +229,6 @@ public abstract class AbstractDataSource
Configuration conf = configuration.subset(CONNECTION_KEY);
applyConfiguration(conf, cpds);
-
- return cpds;
}
/**
@@ -245,7 +240,7 @@ public abstract class AbstractDataSource
* @throws TorqueException if a property set fails.
*/
protected void initJdbc2Pool(
- final InstanceKeyDataSource dataSource,
+ final DataSource dataSource,
final Configuration configuration)
throws TorqueException
{
@@ -272,6 +267,7 @@ public abstract class AbstractDataSource
* @return the <code>DataSource</code> configured by the factory.
* @throws TorqueException if the source can't be returned
*/
+ @Override
public abstract DataSource getDataSource()
throws TorqueException;
@@ -282,6 +278,7 @@ public abstract class AbstractDataSource
* @throws TorqueException Any exceptions caught during processing will be
* rethrown wrapped into a TorqueException.
*/
+ @Override
public abstract void initialize(Configuration configuration)
throws TorqueException;
}
Added: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/PerUserPool2DataSourceFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java \
/org/apache/torque/dsfactory/PerUserPool2DataSourceFactory.java?rev=1754167&view=auto \
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/PerUserPool2DataSourceFactory.java \
(added)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/PerUserPool2DataSourceFactory.java \
Tue Jul 26 18:43:48 2016 @@ -0,0 +1,91 @@
+package org.apache.torque.dsfactory;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import javax.sql.ConnectionPoolDataSource;
+import javax.sql.DataSource;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.dbcp2.cpdsadapter.DriverAdapterCPDS;
+import org.apache.commons.dbcp2.datasources.PerUserPoolDataSource;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.torque.TorqueException;
+
+/**
+ * A factory that looks up the DataSource using the DBCP2 pool methods.
+ *
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ * @version $Id: PerUserPoolDataSourceFactory.java 1485956 2013-05-24 07:55:47Z \
tfischer $ + */
+public class PerUserPool2DataSourceFactory
+ extends AbstractDataSourceFactory
+{
+
+ /** The log. */
+ private static Log log
+ = LogFactory.getLog(PerUserPool2DataSourceFactory.class);
+
+ /** The wrapped <code>DataSource</code>. */
+ private PerUserPoolDataSource ds = null;
+
+ /**
+ * @see org.apache.torque.dsfactory.DataSourceFactory#getDataSource
+ */
+ @Override
+ public DataSource getDataSource()
+ {
+ return ds;
+ }
+
+ /**
+ * @see org.apache.torque.dsfactory.DataSourceFactory#initialize
+ */
+ @Override
+ public void initialize(final Configuration configuration) throws TorqueException
+ {
+ ConnectionPoolDataSource cpds = new DriverAdapterCPDS();
+ initCPDS(configuration, cpds);
+ PerUserPoolDataSource dataSource = new PerUserPoolDataSource();
+ initJdbc2Pool(dataSource, configuration);
+ dataSource.setConnectionPoolDataSource(cpds);
+ this.ds = dataSource;
+ }
+
+ /**
+ * Closes the pool associated with this factory and releases it.
+ * @throws TorqueException if the pool cannot be closed properly
+ */
+ @Override
+ public void close() throws TorqueException
+ {
+ try
+ {
+ ds.close();
+ }
+ catch (Exception e)
+ {
+ log.error("Exception caught during close()", e);
+ throw new TorqueException(e);
+ }
+ ds = null;
+ }
+
+}
Propchange: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/PerUserPool2DataSourceFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/PerUserPoolDataSourceFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java \
/org/apache/torque/dsfactory/PerUserPoolDataSourceFactory.java?rev=1754167&r1=1754166&r2=1754167&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/PerUserPoolDataSourceFactory.java \
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/PerUserPoolDataSourceFactory.java \
Tue Jul 26 18:43:48 2016 @@ -23,6 +23,7 @@ import javax.sql.ConnectionPoolDataSourc
import javax.sql.DataSource;
import org.apache.commons.configuration.Configuration;
+import org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS;
import org.apache.commons.dbcp.datasources.PerUserPoolDataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -61,7 +62,8 @@ public class PerUserPoolDataSourceFactor
@Override
public void initialize(final Configuration configuration) throws TorqueException
{
- ConnectionPoolDataSource cpds = initCPDS(configuration);
+ ConnectionPoolDataSource cpds = new DriverAdapterCPDS();
+ initCPDS(configuration, cpds);
PerUserPoolDataSource dataSource = new PerUserPoolDataSource();
initJdbc2Pool(dataSource, configuration);
dataSource.setConnectionPoolDataSource(cpds);
@@ -72,6 +74,7 @@ public class PerUserPoolDataSourceFactor
* Closes the pool associated with this factory and releases it.
* @throws TorqueException if the pool cannot be closed properly
*/
+ @Override
public void close() throws TorqueException
{
try
Added: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/SharedPool2DataSourceFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java \
/org/apache/torque/dsfactory/SharedPool2DataSourceFactory.java?rev=1754167&view=auto \
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/SharedPool2DataSourceFactory.java \
(added)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/SharedPool2DataSourceFactory.java \
Tue Jul 26 18:43:48 2016 @@ -0,0 +1,90 @@
+package org.apache.torque.dsfactory;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import javax.sql.ConnectionPoolDataSource;
+import javax.sql.DataSource;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.dbcp2.cpdsadapter.DriverAdapterCPDS;
+import org.apache.commons.dbcp2.datasources.SharedPoolDataSource;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.torque.TorqueException;
+
+/**
+ * A factory that looks up the DataSource using the DBCP2 pool methods.
+ *
+ * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
+ * @version $Id: SharedPoolDataSourceFactory.java 1485956 2013-05-24 07:55:47Z \
tfischer $ + */
+public class SharedPool2DataSourceFactory
+ extends AbstractDataSourceFactory
+{
+
+ /** The log. */
+ private static Log log
+ = LogFactory.getLog(SharedPool2DataSourceFactory.class);
+
+ /** The wrapped <code>DataSource</code>. */
+ private SharedPoolDataSource ds = null;
+
+ /**
+ * @see org.apache.torque.dsfactory.DataSourceFactory#getDataSource
+ */
+ @Override
+ public DataSource getDataSource()
+ {
+ return ds;
+ }
+
+ /**
+ * @see org.apache.torque.dsfactory.DataSourceFactory#initialize
+ */
+ @Override
+ public void initialize(final Configuration configuration) throws TorqueException
+ {
+ ConnectionPoolDataSource cpds = new DriverAdapterCPDS();
+ initCPDS(configuration, cpds);
+ SharedPoolDataSource dataSource = new SharedPoolDataSource();
+ initJdbc2Pool(dataSource, configuration);
+ dataSource.setConnectionPoolDataSource(cpds);
+ this.ds = dataSource;
+ }
+
+ /**
+ * Closes the pool associated with this factory and releases it.
+ * @throws TorqueException if the pool cannot be closed properly
+ */
+ @Override
+ public void close() throws TorqueException
+ {
+ try
+ {
+ ds.close();
+ }
+ catch (Exception e)
+ {
+ log.error("Exception caught during close()", e);
+ throw new TorqueException(e);
+ }
+ ds = null;
+ }
+}
Propchange: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/SharedPool2DataSourceFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/SharedPoolDataSourceFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java \
/org/apache/torque/dsfactory/SharedPoolDataSourceFactory.java?rev=1754167&r1=1754166&r2=1754167&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/SharedPoolDataSourceFactory.java \
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/dsfactory/SharedPoolDataSourceFactory.java \
Tue Jul 26 18:43:48 2016 @@ -23,6 +23,7 @@ import javax.sql.ConnectionPoolDataSourc
import javax.sql.DataSource;
import org.apache.commons.configuration.Configuration;
+import org.apache.commons.dbcp.cpdsadapter.DriverAdapterCPDS;
import org.apache.commons.dbcp.datasources.SharedPoolDataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -61,7 +62,8 @@ public class SharedPoolDataSourceFactory
@Override
public void initialize(final Configuration configuration) throws TorqueException
{
- ConnectionPoolDataSource cpds = initCPDS(configuration);
+ ConnectionPoolDataSource cpds = new DriverAdapterCPDS();
+ initCPDS(configuration, cpds);
SharedPoolDataSource dataSource = new SharedPoolDataSource();
initJdbc2Pool(dataSource, configuration);
dataSource.setConnectionPoolDataSource(cpds);
@@ -72,6 +74,7 @@ public class SharedPoolDataSourceFactory
* Closes the pool associated with this factory and releases it.
* @throws TorqueException if the pool cannot be closed properly
*/
+ @Override
public void close() throws TorqueException
{
try
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic