ARTEMIS-2823 Apply default datasource configs if not overridden
This commit is contained in:
parent
10debc3478
commit
b39c9c9221
|
@ -152,19 +152,32 @@ public class DatabaseStorageConfiguration implements StoreConfiguration {
|
||||||
private DataSource getDataSource() {
|
private DataSource getDataSource() {
|
||||||
if (dataSource == null) {
|
if (dataSource == null) {
|
||||||
// the next settings are going to be applied only if the datasource is the default one
|
// the next settings are going to be applied only if the datasource is the default one
|
||||||
if (dataSourceProperties.isEmpty() && ActiveMQDefaultConfiguration.getDefaultDataSourceClassName().equals(dataSourceClassName)) {
|
if (ActiveMQDefaultConfiguration.getDefaultDataSourceClassName().equals(dataSourceClassName)) {
|
||||||
addDataSourceProperty("driverClassName", jdbcDriverClassName);
|
// these default settings will be applied only if a custom configuration won't override them
|
||||||
addDataSourceProperty("url", jdbcConnectionUrl);
|
if (!dataSourceProperties.containsKey("driverClassName")) {
|
||||||
if (jdbcUser != null) {
|
addDataSourceProperty("driverClassName", jdbcDriverClassName);
|
||||||
addDataSourceProperty("username", jdbcUser);
|
|
||||||
}
|
}
|
||||||
if (jdbcPassword != null) {
|
if (!dataSourceProperties.containsKey("url")) {
|
||||||
addDataSourceProperty("password", jdbcPassword);
|
addDataSourceProperty("url", jdbcConnectionUrl);
|
||||||
|
}
|
||||||
|
if (!dataSourceProperties.containsKey("username")) {
|
||||||
|
if (jdbcUser != null) {
|
||||||
|
addDataSourceProperty("username", jdbcUser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!dataSourceProperties.containsKey("password")) {
|
||||||
|
if (jdbcPassword != null) {
|
||||||
|
addDataSourceProperty("password", jdbcPassword);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!dataSourceProperties.containsKey("maxTotal")) {
|
||||||
|
// Let the pool to have unbounded number of connections by default to prevent connection starvation
|
||||||
|
addDataSourceProperty("maxTotal", "-1");
|
||||||
|
}
|
||||||
|
if (!dataSourceProperties.containsKey("poolPreparedStatements")) {
|
||||||
|
// Let the pool to have unbounded number of cached prepared statements to save the initialization cost
|
||||||
|
addDataSourceProperty("poolPreparedStatements", "true");
|
||||||
}
|
}
|
||||||
// Let the pool to have unbounded number of connections by default to prevent connection starvation
|
|
||||||
addDataSourceProperty("maxTotal", "-1");
|
|
||||||
// Let the pool to have unbounded number of cached prepared statements to save the initialization cost
|
|
||||||
addDataSourceProperty("poolPreparedStatements", "true");
|
|
||||||
}
|
}
|
||||||
dataSource = JDBCDataSourceUtils.getDataSource(dataSourceClassName, dataSourceProperties);
|
dataSource = JDBCDataSourceUtils.getDataSource(dataSourceClassName, dataSourceProperties);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue