Remove support for Apache Commons DBCP to align with Spring Boot 2.0.
This commit is contained in:
@@ -17,7 +17,6 @@ ext {
|
||||
mariadbDriverVersion = "1.5.9"
|
||||
postgresDriverVersion = "9.1-901-1.jdbc4"
|
||||
|
||||
commonDbcpVersion = "1.4"
|
||||
commonDbcp2Version = "2.1.1"
|
||||
hikariCpVersion = "2.5.1"
|
||||
|
||||
@@ -45,7 +44,6 @@ dependencies {
|
||||
optional("org.apache.commons:commons-dbcp2:$commonDbcp2Version") {
|
||||
exclude(group: 'commons-logging', module: 'commons-logging')
|
||||
}
|
||||
optional("commons-dbcp:commons-dbcp:$commonDbcpVersion")
|
||||
optional("com.zaxxer:HikariCP:${hikariCpVersion}")
|
||||
|
||||
optional("org.springframework.amqp:spring-rabbit:$springAmqpVersion")
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.springframework.cloud.service.relational;
|
||||
|
||||
import static org.springframework.cloud.service.Util.hasClass;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.cloud.service.ServiceConnectorConfig;
|
||||
@@ -10,28 +8,19 @@ import org.springframework.cloud.service.common.RelationalServiceInfo;
|
||||
/**
|
||||
*
|
||||
* @author Ramnivas Laddad
|
||||
* @author Scott Frederick
|
||||
*
|
||||
* @param <SI> the {@link RelationalServiceInfo} type for the underlying database service
|
||||
*/
|
||||
public class BasicDbcpPooledDataSourceCreator<SI extends RelationalServiceInfo> extends DbcpLikePooledDataSourceCreator<SI> {
|
||||
public static final String DBCP2_BASIC_DATASOURCE = "org.apache.commons.dbcp2.BasicDataSource";
|
||||
public static final String DBCP_BASIC_DATASOURCE = "org.apache.commons.dbcp.BasicDataSource";
|
||||
static final String DBCP2_BASIC_DATASOURCE = "org.apache.commons.dbcp2.BasicDataSource";
|
||||
|
||||
@Override
|
||||
public DataSource create(RelationalServiceInfo serviceInfo, ServiceConnectorConfig serviceConnectorConfig,
|
||||
String driverClassName, String validationQuery) {
|
||||
if (hasClass(DBCP2_BASIC_DATASOURCE)) {
|
||||
logger.info("Found DBCP2 on the classpath. Using it for DataSource connection pooling.");
|
||||
org.apache.commons.dbcp2.BasicDataSource ds = new org.apache.commons.dbcp2.BasicDataSource();
|
||||
setBasicDataSourceProperties(ds, serviceInfo, serviceConnectorConfig, driverClassName, validationQuery);
|
||||
return ds;
|
||||
} else if (hasClass(DBCP_BASIC_DATASOURCE)) {
|
||||
logger.info("Found DBCP on the classpath. Using it for DataSource connection pooling.");
|
||||
org.apache.commons.dbcp.BasicDataSource ds = new org.apache.commons.dbcp.BasicDataSource();
|
||||
setBasicDataSourceProperties(ds, serviceInfo, serviceConnectorConfig, driverClassName, validationQuery);
|
||||
return ds;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
logger.info("Found DBCP2 on the classpath. Using it for DataSource connection pooling.");
|
||||
org.apache.commons.dbcp2.BasicDataSource ds = new org.apache.commons.dbcp2.BasicDataSource();
|
||||
setBasicDataSourceProperties(ds, serviceInfo, serviceConnectorConfig, driverClassName, validationQuery);
|
||||
return ds;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.cloud.service.Util.hasClass;
|
||||
import static org.springframework.cloud.service.relational.BasicDbcpPooledDataSourceCreator.DBCP2_BASIC_DATASOURCE;
|
||||
import static org.springframework.cloud.service.relational.BasicDbcpPooledDataSourceCreator.DBCP_BASIC_DATASOURCE;
|
||||
import static org.springframework.cloud.service.relational.HikariCpPooledDataSourceCreator.HIKARI_DATASOURCE;
|
||||
import static org.springframework.cloud.service.relational.TomcatDbcpPooledDataSourceCreator.TOMCAT_7_DBCP;
|
||||
import static org.springframework.cloud.service.relational.TomcatDbcpPooledDataSourceCreator.TOMCAT_8_DBCP;
|
||||
@@ -116,24 +115,12 @@ public class PooledDataSourceCreatorsTest {
|
||||
}
|
||||
|
||||
private void assertBasicDbcpDataSource(DataSource ds) throws ClassNotFoundException {
|
||||
assertTrue(hasClass(DBCP2_BASIC_DATASOURCE) || hasClass(DBCP_BASIC_DATASOURCE));
|
||||
assertThat(ds, instanceOf(Class.forName(DBCP2_BASIC_DATASOURCE)));
|
||||
|
||||
if (hasClass(DBCP2_BASIC_DATASOURCE)) {
|
||||
assertThat(ds, instanceOf(Class.forName(DBCP2_BASIC_DATASOURCE)));
|
||||
|
||||
assertEquals(MIN_POOL_SIZE, getIntValue(ds, "minIdle"));
|
||||
assertEquals(MAX_POOL_SIZE, getIntValue(ds, "maxTotal"));
|
||||
assertEquals(MAX_WAIT_TIME, getIntValue(ds, "maxWaitMillis"));
|
||||
assertEquals(CONNECTION_PROPERTIES, getPropertiesValue(ds, "connectionProperties"));
|
||||
}
|
||||
if (hasClass(DBCP_BASIC_DATASOURCE) && !hasClass(DBCP2_BASIC_DATASOURCE)) {
|
||||
assertThat(ds, instanceOf(Class.forName(DBCP_BASIC_DATASOURCE)));
|
||||
|
||||
assertEquals(MIN_POOL_SIZE, getIntValue(ds, "minIdle"));
|
||||
assertEquals(MAX_POOL_SIZE, getIntValue(ds, "maxActive"));
|
||||
assertEquals(MAX_WAIT_TIME, getIntValue(ds, "maxWait"));
|
||||
assertEquals(CONNECTION_PROPERTIES, getPropertiesValue(ds, "connectionProperties"));
|
||||
}
|
||||
assertEquals(MIN_POOL_SIZE, getIntValue(ds, "minIdle"));
|
||||
assertEquals(MAX_POOL_SIZE, getIntValue(ds, "maxTotal"));
|
||||
assertEquals(MAX_WAIT_TIME, getIntValue(ds, "maxWaitMillis"));
|
||||
assertEquals(CONNECTION_PROPERTIES, getPropertiesValue(ds, "connectionProperties"));
|
||||
}
|
||||
|
||||
private void assertTomcatDbcpDataSource(DataSource ds) throws ClassNotFoundException {
|
||||
|
||||
Reference in New Issue
Block a user