killbill-aplcache
Merge remote-tracking branch 'origin/master' into new-paymentpluginapi Signed-off-by: …
Changes
account/pom.xml 2(+1 -1)
analytics/pom.xml 5(+2 -3)
api/pom.xml 2(+1 -1)
beatrix/pom.xml 2(+1 -1)
catalog/pom.xml 5(+2 -3)
entitlement/pom.xml 2(+1 -1)
invoice/pom.xml 2(+1 -1)
jaxrs/pom.xml 2(+1 -1)
junction/pom.xml 2(+1 -1)
osgi/pom.xml 2(+1 -1)
osgi-bundles/defaultbundles/pom.xml 2(+1 -1)
osgi-bundles/hello/pom.xml 2(+1 -1)
osgi-bundles/jruby/pom.xml 2(+1 -1)
osgi-bundles/meter/pom.xml 2(+1 -1)
osgi-bundles/pom.xml 2(+1 -1)
osgi-bundles/test/pom.xml 2(+1 -1)
overdue/pom.xml 2(+1 -1)
payment/pom.xml 2(+1 -1)
pom.xml 7(+6 -1)
server/pom.xml 2(+1 -1)
tenant/pom.xml 2(+1 -1)
usage/pom.xml 2(+1 -1)
util/pom.xml 6(+5 -1)
Details
account/pom.xml 2(+1 -1)
diff --git a/account/pom.xml b/account/pom.xml
index a90d94f..968caea 100644
--- a/account/pom.xml
+++ b/account/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-account</artifactId>
analytics/pom.xml 5(+2 -3)
diff --git a/analytics/pom.xml b/analytics/pom.xml
index d67c2f3..1fb5c62 100644
--- a/analytics/pom.xml
+++ b/analytics/pom.xml
@@ -15,13 +15,12 @@
~ under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-analytics</artifactId>
api/pom.xml 2(+1 -1)
diff --git a/api/pom.xml b/api/pom.xml
index 6ac9131..56701c0 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-api</artifactId>
beatrix/pom.xml 2(+1 -1)
diff --git a/beatrix/pom.xml b/beatrix/pom.xml
index ca722bc..b714b6d 100644
--- a/beatrix/pom.xml
+++ b/beatrix/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-beatrix</artifactId>
catalog/pom.xml 5(+2 -3)
diff --git a/catalog/pom.xml b/catalog/pom.xml
index c57578d..84f0822 100644
--- a/catalog/pom.xml
+++ b/catalog/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-catalog</artifactId>
@@ -102,8 +102,7 @@
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>load-tool</shadedClassifierName>
<transformers>
- <transformer
- implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+ <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.ning.billing.catalog.LoadCatalog</Main-Class>
</manifestEntries>
entitlement/pom.xml 2(+1 -1)
diff --git a/entitlement/pom.xml b/entitlement/pom.xml
index 1a87cac..2555107 100644
--- a/entitlement/pom.xml
+++ b/entitlement/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-entitlement</artifactId>
invoice/pom.xml 2(+1 -1)
diff --git a/invoice/pom.xml b/invoice/pom.xml
index 9e5fbdc..98089fc 100644
--- a/invoice/pom.xml
+++ b/invoice/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-invoice</artifactId>
jaxrs/pom.xml 2(+1 -1)
diff --git a/jaxrs/pom.xml b/jaxrs/pom.xml
index f3bfabb..dc57362 100644
--- a/jaxrs/pom.xml
+++ b/jaxrs/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-jaxrs</artifactId>
junction/pom.xml 2(+1 -1)
diff --git a/junction/pom.xml b/junction/pom.xml
index 963b18f..ac3df69 100644
--- a/junction/pom.xml
+++ b/junction/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-junction</artifactId>
osgi/pom.xml 2(+1 -1)
diff --git a/osgi/pom.xml b/osgi/pom.xml
index 67db67c..01e9d7f 100644
--- a/osgi/pom.xml
+++ b/osgi/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-osgi</artifactId>
osgi-bundles/defaultbundles/pom.xml 2(+1 -1)
diff --git a/osgi-bundles/defaultbundles/pom.xml b/osgi-bundles/defaultbundles/pom.xml
index 358925e..e739a2e 100644
--- a/osgi-bundles/defaultbundles/pom.xml
+++ b/osgi-bundles/defaultbundles/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill-osgi-bundles</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-osgi-bundles-defaultbundles</artifactId>
osgi-bundles/hello/pom.xml 2(+1 -1)
diff --git a/osgi-bundles/hello/pom.xml b/osgi-bundles/hello/pom.xml
index b5fd84d..209e422 100644
--- a/osgi-bundles/hello/pom.xml
+++ b/osgi-bundles/hello/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill-osgi-bundles</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-osgi-bundles-hello</artifactId>
osgi-bundles/jruby/pom.xml 2(+1 -1)
diff --git a/osgi-bundles/jruby/pom.xml b/osgi-bundles/jruby/pom.xml
index a5a02e5..62c0b04 100644
--- a/osgi-bundles/jruby/pom.xml
+++ b/osgi-bundles/jruby/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill-osgi-bundles</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-osgi-bundles-jruby</artifactId>
osgi-bundles/meter/pom.xml 2(+1 -1)
diff --git a/osgi-bundles/meter/pom.xml b/osgi-bundles/meter/pom.xml
index 74f2480..d2d32cc 100644
--- a/osgi-bundles/meter/pom.xml
+++ b/osgi-bundles/meter/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill-osgi-bundles</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-osgi-bundles-meter</artifactId>
osgi-bundles/pom.xml 2(+1 -1)
diff --git a/osgi-bundles/pom.xml b/osgi-bundles/pom.xml
index 30addd9..1e06d27 100644
--- a/osgi-bundles/pom.xml
+++ b/osgi-bundles/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-osgi-bundles</artifactId>
osgi-bundles/test/pom.xml 2(+1 -1)
diff --git a/osgi-bundles/test/pom.xml b/osgi-bundles/test/pom.xml
index 5bddb19..d511a9b 100644
--- a/osgi-bundles/test/pom.xml
+++ b/osgi-bundles/test/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill-osgi-bundles</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-osgi-bundles-test</artifactId>
diff --git a/osgi-bundles/webconsolebranding/pom.xml b/osgi-bundles/webconsolebranding/pom.xml
index 68d47c9..0103154 100644
--- a/osgi-bundles/webconsolebranding/pom.xml
+++ b/osgi-bundles/webconsolebranding/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill-osgi-bundles</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-osgi-bundles-webconsolebranding</artifactId>
overdue/pom.xml 2(+1 -1)
diff --git a/overdue/pom.xml b/overdue/pom.xml
index 5798c8c..7732e73 100644
--- a/overdue/pom.xml
+++ b/overdue/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-overdue</artifactId>
payment/pom.xml 2(+1 -1)
diff --git a/payment/pom.xml b/payment/pom.xml
index 52a86dc..899442c 100644
--- a/payment/pom.xml
+++ b/payment/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-payment</artifactId>
pom.xml 7(+6 -1)
diff --git a/pom.xml b/pom.xml
index 0a0436a..bc2cbaa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,7 +25,7 @@
<groupId>com.ning.billing</groupId>
<artifactId>killbill</artifactId>
<packaging>pom</packaging>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<name>killbill</name>
<description>Library for managing recurring subscriptions and the associated billing</description>
<url>http://github.com/killbill/killbill</url>
@@ -306,6 +306,11 @@
</exclusions>
</dependency>
<dependency>
+ <groupId>com.mchange</groupId>
+ <artifactId>c3p0</artifactId>
+ <version>0.9.2</version>
+ </dependency>
+ <dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.1.0</version>
server/pom.xml 2(+1 -1)
diff --git a/server/pom.xml b/server/pom.xml
index f6aaeca..1722775 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-server</artifactId>
diff --git a/server/src/main/java/com/ning/billing/server/modules/DBIProvider.java b/server/src/main/java/com/ning/billing/server/modules/DBIProvider.java
index e67b929..5d86c2b 100644
--- a/server/src/main/java/com/ning/billing/server/modules/DBIProvider.java
+++ b/server/src/main/java/com/ning/billing/server/modules/DBIProvider.java
@@ -18,6 +18,8 @@ package com.ning.billing.server.modules;
import java.util.concurrent.TimeUnit;
+import javax.sql.DataSource;
+
import org.skife.jdbi.v2.DBI;
import org.skife.jdbi.v2.TimingCollector;
import org.skife.jdbi.v2.tweak.SQLLog;
@@ -37,6 +39,7 @@ import com.google.inject.Inject;
import com.google.inject.Provider;
import com.jolbox.bonecp.BoneCPConfig;
import com.jolbox.bonecp.BoneCPDataSource;
+import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.yammer.metrics.core.MetricsRegistry;
import com.yammer.metrics.jdbi.InstrumentedTimingCollector;
import com.yammer.metrics.jdbi.strategies.BasicSqlNameStrategy;
@@ -62,21 +65,8 @@ public class DBIProvider implements Provider<DBI> {
@Override
public DBI get() {
- final BoneCPConfig dbConfig = new BoneCPConfig();
- dbConfig.setJdbcUrl(config.getJdbcUrl());
- dbConfig.setUsername(config.getUsername());
- dbConfig.setPassword(config.getPassword());
- dbConfig.setMinConnectionsPerPartition(config.getMinIdle());
- dbConfig.setMaxConnectionsPerPartition(config.getMaxActive());
- dbConfig.setConnectionTimeout(config.getConnectionTimeout().getPeriod(), config.getConnectionTimeout().getUnit());
- dbConfig.setIdleMaxAge(config.getIdleMaxAge().getPeriod(), config.getIdleMaxAge().getUnit());
- dbConfig.setMaxConnectionAge(config.getMaxConnectionAge().getPeriod(), config.getMaxConnectionAge().getUnit());
- dbConfig.setIdleConnectionTestPeriod(config.getIdleConnectionTestPeriod().getPeriod(), config.getIdleConnectionTestPeriod().getUnit());
- dbConfig.setPartitionCount(1);
- dbConfig.setDefaultTransactionIsolation("READ_COMMITTED");
- dbConfig.setDisableJMX(false);
- final BoneCPDataSource ds = new BoneCPDataSource(dbConfig);
+ final DataSource ds = getC3P0DataSource();
final DBI dbi = new DBI(ds);
dbi.registerArgumentFactory(new UUIDArgumentFactory());
dbi.registerArgumentFactory(new DateTimeZoneArgumentFactory());
@@ -104,4 +94,33 @@ public class DBIProvider implements Provider<DBI> {
return dbi;
}
+
+
+ private DataSource getBoneCPDatSource() {
+ final BoneCPConfig dbConfig = new BoneCPConfig();
+ dbConfig.setJdbcUrl(config.getJdbcUrl());
+ dbConfig.setUsername(config.getUsername());
+ dbConfig.setPassword(config.getPassword());
+ dbConfig.setMinConnectionsPerPartition(config.getMinIdle());
+ dbConfig.setMaxConnectionsPerPartition(config.getMaxActive());
+ dbConfig.setConnectionTimeout(config.getConnectionTimeout().getPeriod(), config.getConnectionTimeout().getUnit());
+ dbConfig.setIdleMaxAge(config.getIdleMaxAge().getPeriod(), config.getIdleMaxAge().getUnit());
+ dbConfig.setMaxConnectionAge(config.getMaxConnectionAge().getPeriod(), config.getMaxConnectionAge().getUnit());
+ dbConfig.setIdleConnectionTestPeriod(config.getIdleConnectionTestPeriod().getPeriod(), config.getIdleConnectionTestPeriod().getUnit());
+ dbConfig.setPartitionCount(1);
+ dbConfig.setDisableJMX(false);
+
+ final BoneCPDataSource ds = new BoneCPDataSource(dbConfig);
+ return ds;
+ }
+
+ private DataSource getC3P0DataSource() {
+ ComboPooledDataSource cpds = new ComboPooledDataSource();
+ cpds.setJdbcUrl(config.getJdbcUrl());
+ cpds.setUser(config.getUsername());
+ cpds.setPassword(config.getPassword());
+ cpds.setMinPoolSize(1);
+ cpds.setMaxPoolSize(10);
+ return cpds;
+ }
}
tenant/pom.xml 2(+1 -1)
diff --git a/tenant/pom.xml b/tenant/pom.xml
index ea20fe1..1b195f4 100644
--- a/tenant/pom.xml
+++ b/tenant/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-tenant</artifactId>
usage/pom.xml 2(+1 -1)
diff --git a/usage/pom.xml b/usage/pom.xml
index 5b96c67..58d8321 100644
--- a/usage/pom.xml
+++ b/usage/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-usage</artifactId>
util/pom.xml 6(+5 -1)
diff --git a/util/pom.xml b/util/pom.xml
index 4905af0..4ceddb7 100644
--- a/util/pom.xml
+++ b/util/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>com.ning.billing</groupId>
<artifactId>killbill</artifactId>
- <version>0.1.54-SNAPSHOT</version>
+ <version>0.1.55-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>killbill-util</artifactId>
@@ -34,6 +34,10 @@
<artifactId>bonecp</artifactId>
</dependency>
<dependency>
+ <groupId>com.mchange</groupId>
+ <artifactId>c3p0</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.jdbi</groupId>
<artifactId>jdbi</artifactId>
</dependency>
diff --git a/util/src/main/java/com/ning/billing/util/bus/PersistentInternalBus.java b/util/src/main/java/com/ning/billing/util/bus/PersistentInternalBus.java
index f2fa6ab..cc8d4b0 100644
--- a/util/src/main/java/com/ning/billing/util/bus/PersistentInternalBus.java
+++ b/util/src/main/java/com/ning/billing/util/bus/PersistentInternalBus.java
@@ -24,6 +24,7 @@ import java.util.concurrent.ThreadFactory;
import org.skife.jdbi.v2.IDBI;
import org.skife.jdbi.v2.Transaction;
+import org.skife.jdbi.v2.TransactionIsolationLevel;
import org.skife.jdbi.v2.TransactionStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -171,7 +172,7 @@ public class PersistentInternalBus extends PersistentQueueBase implements Intern
@Override
public void post(final BusInternalEvent event, final InternalCallContext context) throws EventBusException {
- dao.inTransaction(new Transaction<Void, PersistentBusSqlDao>() {
+ dao.inTransaction(TransactionIsolationLevel.READ_COMMITTED, new Transaction<Void, PersistentBusSqlDao>() {
@Override
public Void inTransaction(final PersistentBusSqlDao transactional,
final TransactionStatus status) throws Exception {
diff --git a/util/src/main/java/com/ning/billing/util/entity/dao/EntitySqlDaoTransactionalJdbiWrapper.java b/util/src/main/java/com/ning/billing/util/entity/dao/EntitySqlDaoTransactionalJdbiWrapper.java
index 35098ca..9b6933b 100644
--- a/util/src/main/java/com/ning/billing/util/entity/dao/EntitySqlDaoTransactionalJdbiWrapper.java
+++ b/util/src/main/java/com/ning/billing/util/entity/dao/EntitySqlDaoTransactionalJdbiWrapper.java
@@ -18,6 +18,7 @@ package com.ning.billing.util.entity.dao;
import org.skife.jdbi.v2.IDBI;
import org.skife.jdbi.v2.Transaction;
+import org.skife.jdbi.v2.TransactionIsolationLevel;
import org.skife.jdbi.v2.TransactionStatus;
import com.ning.billing.util.cache.CacheControllerDispatcher;
@@ -67,6 +68,6 @@ public class EntitySqlDaoTransactionalJdbiWrapper {
*/
public <ReturnType> ReturnType execute(final EntitySqlDaoTransactionWrapper<ReturnType> entitySqlDaoTransactionWrapper) {
final EntitySqlDao<EntityModelDao<Entity>, Entity> entitySqlDao = dbi.onDemand(InitialEntitySqlDao.class);
- return entitySqlDao.inTransaction(new JdbiTransaction<ReturnType, EntityModelDao<Entity>, Entity>(entitySqlDaoTransactionWrapper));
+ return entitySqlDao.inTransaction(TransactionIsolationLevel.READ_COMMITTED, new JdbiTransaction<ReturnType, EntityModelDao<Entity>, Entity>(entitySqlDaoTransactionWrapper));
}
}
diff --git a/util/src/test/java/com/ning/billing/dbi/DBIProvider.java b/util/src/test/java/com/ning/billing/dbi/DBIProvider.java
index b66f87d..a54ee30 100644
--- a/util/src/test/java/com/ning/billing/dbi/DBIProvider.java
+++ b/util/src/test/java/com/ning/billing/dbi/DBIProvider.java
@@ -18,6 +18,8 @@ package com.ning.billing.dbi;
import java.util.concurrent.TimeUnit;
+import javax.sql.DataSource;
+
import org.skife.jdbi.v2.DBI;
import org.skife.jdbi.v2.IDBI;
import org.skife.jdbi.v2.tweak.transactions.SerializableTransactionRunner;
@@ -33,38 +35,28 @@ import com.google.inject.Inject;
import com.google.inject.Provider;
import com.jolbox.bonecp.BoneCPConfig;
import com.jolbox.bonecp.BoneCPDataSource;
+import com.mchange.v2.c3p0.ComboPooledDataSource;
public class DBIProvider implements Provider<IDBI> {
- private final BoneCPConfig dbConfig;
+ private final String jdbcUri;
+ private final String userName;
+ private final String userPwd;
@Inject
public DBIProvider(final DbiConfig config) {
this(config.getJdbcUrl(), config.getUsername(), config.getPassword());
}
- public DBIProvider(final String dbiString, final String userName, final String pwd) {
- this.dbConfig = createConfig(dbiString, userName, pwd);
- }
-
- BoneCPConfig createConfig(final String dbiString, final String userName, final String pwd) {
- final BoneCPConfig dbConfig = new BoneCPConfig();
- dbConfig.setJdbcUrl(dbiString);
- dbConfig.setUsername(userName);
- dbConfig.setPassword(pwd);
- dbConfig.setMinConnectionsPerPartition(1);
- dbConfig.setMaxConnectionsPerPartition(30);
- dbConfig.setConnectionTimeout(10, TimeUnit.SECONDS);
- dbConfig.setPartitionCount(1);
- dbConfig.setDefaultTransactionIsolation("REPEATABLE_READ");
- dbConfig.setDisableJMX(false);
- dbConfig.setLazyInit(true);
- return dbConfig;
+ public DBIProvider(final String jdbcUri, final String userName, final String userPwd) {
+ this.jdbcUri = jdbcUri;
+ this.userName = userName;
+ this.userPwd = userPwd;
}
@Override
public IDBI get() {
- final BoneCPDataSource ds = new BoneCPDataSource(dbConfig);
+ final DataSource ds = getC3P0DataSource();
final DBI dbi = new DBI(ds);
dbi.registerArgumentFactory(new UUIDArgumentFactory());
dbi.registerArgumentFactory(new DateTimeZoneArgumentFactory());
@@ -80,4 +72,29 @@ public class DBIProvider implements Provider<IDBI> {
return dbi;
}
+
+
+
+ private DataSource getBoneCPDatSource() {
+ final BoneCPConfig dbConfig = new BoneCPConfig();
+ dbConfig.setJdbcUrl(jdbcUri);
+ dbConfig.setUsername(userName);
+ dbConfig.setPassword(userPwd);
+ dbConfig.setPartitionCount(1);
+ //dbConfig.setDefaultTransactionIsolation("READ_COMMITTED");
+ dbConfig.setDisableJMX(false);
+
+ final BoneCPDataSource ds = new BoneCPDataSource(dbConfig);
+ return ds;
+ }
+
+ private DataSource getC3P0DataSource() {
+ ComboPooledDataSource cpds = new ComboPooledDataSource();
+ cpds.setJdbcUrl(jdbcUri);
+ cpds.setUser(userName);
+ cpds.setPassword(userPwd);
+ cpds.setMinPoolSize(1);
+ cpds.setMaxPoolSize(10);
+ return cpds;
+ }
}