|
@@ -69,63 +69,65 @@ public class DataSourceFactory implements FactoryBean<DataSource>, InitializingB
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
- public void afterPropertiesSet() throws Exception {
|
|
|
|
- Properties properties = new Properties();
|
|
|
|
- loadProperties(properties);
|
|
|
|
|
|
+ public void afterPropertiesSet(Properties properties) {
|
|
if (dsType.equals("com.alibaba.druid.pool.DruidDataSource")) {
|
|
if (dsType.equals("com.alibaba.druid.pool.DruidDataSource")) {
|
|
- DruidDataSource druidDataSource = new DruidDataSource();
|
|
|
|
|
|
+ DruidDataSource druidDataSource = null;
|
|
|
|
+ druidDataSource = new DruidDataSource();
|
|
druidDataSource.configFromPropety(properties);
|
|
druidDataSource.configFromPropety(properties);
|
|
{
|
|
{
|
|
- String property = properties.getProperty("druid.url");
|
|
|
|
|
|
+ String property = properties.getProperty("url");
|
|
if (property != null && property.length() > 0) {
|
|
if (property != null && property.length() > 0) {
|
|
druidDataSource.setUrl(property);
|
|
druidDataSource.setUrl(property);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- String property = properties.getProperty("druid.username");
|
|
|
|
|
|
+ String driverClassName = properties.getProperty("driverClassName");
|
|
|
|
+ druidDataSource.setDriverClassName(driverClassName);
|
|
|
|
+ }
|
|
|
|
+ {
|
|
|
|
+ String property = properties.getProperty("username");
|
|
if (property != null && property.length() > 0) {
|
|
if (property != null && property.length() > 0) {
|
|
druidDataSource.setUsername(property);
|
|
druidDataSource.setUsername(property);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- String property = properties.getProperty("druid.password");
|
|
|
|
|
|
+ String property = properties.getProperty("password");
|
|
if (property != null && property.length() > 0) {
|
|
if (property != null && property.length() > 0) {
|
|
druidDataSource.setPassword(property);
|
|
druidDataSource.setPassword(property);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- String property = properties.getProperty("druid.initialSize");
|
|
|
|
|
|
+ String property = properties.getProperty("initialSize");
|
|
if (property != null && property.length() > 0) {
|
|
if (property != null && property.length() > 0) {
|
|
druidDataSource.setInitialSize(Integer.parseInt(property));
|
|
druidDataSource.setInitialSize(Integer.parseInt(property));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- String property = properties.getProperty("druid.minIdle");
|
|
|
|
|
|
+ String property = properties.getProperty("minIdle");
|
|
if (property != null && property.length() > 0) {
|
|
if (property != null && property.length() > 0) {
|
|
druidDataSource.setMinIdle(Integer.parseInt(property));
|
|
druidDataSource.setMinIdle(Integer.parseInt(property));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- String property = properties.getProperty("druid.maxActive");
|
|
|
|
|
|
+ String property = properties.getProperty("maxActive");
|
|
if (property != null && property.length() > 0) {
|
|
if (property != null && property.length() > 0) {
|
|
druidDataSource.setMaxActive(Integer.parseInt(property));
|
|
druidDataSource.setMaxActive(Integer.parseInt(property));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- String property = properties.getProperty("druid.timeBetweenEvictionRunsMillis");
|
|
|
|
|
|
+ String property = properties.getProperty("timeBetweenEvictionRunsMillis");
|
|
if (property != null && property.length() > 0) {
|
|
if (property != null && property.length() > 0) {
|
|
druidDataSource.setTimeBetweenEvictionRunsMillis(Long.parseLong(property));
|
|
druidDataSource.setTimeBetweenEvictionRunsMillis(Long.parseLong(property));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- String property = properties.getProperty("druid.minEvictableIdleTimeMillis");
|
|
|
|
|
|
+ String property = properties.getProperty("minEvictableIdleTimeMillis");
|
|
if (property != null && property.length() > 0) {
|
|
if (property != null && property.length() > 0) {
|
|
druidDataSource.setMinEvictableIdleTimeMillis(Integer.parseInt(property));
|
|
druidDataSource.setMinEvictableIdleTimeMillis(Integer.parseInt(property));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- String property = properties.getProperty("druid.testOnReturn");
|
|
|
|
|
|
+ String property = properties.getProperty("testOnReturn");
|
|
if ("true".equals(property)) {
|
|
if ("true".equals(property)) {
|
|
druidDataSource.setTestOnReturn(true);
|
|
druidDataSource.setTestOnReturn(true);
|
|
} else if ("false".equals(property)) {
|
|
} else if ("false".equals(property)) {
|
|
@@ -133,7 +135,7 @@ public class DataSourceFactory implements FactoryBean<DataSource>, InitializingB
|
|
}
|
|
}
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- String property = properties.getProperty("druid.poolPreparedStatements");
|
|
|
|
|
|
+ String property = properties.getProperty("poolPreparedStatements");
|
|
if ("true".equals(property)) {
|
|
if ("true".equals(property)) {
|
|
druidDataSource.setPoolPreparedStatements(true);
|
|
druidDataSource.setPoolPreparedStatements(true);
|
|
} else if ("false".equals(property)) {
|
|
} else if ("false".equals(property)) {
|
|
@@ -141,15 +143,28 @@ public class DataSourceFactory implements FactoryBean<DataSource>, InitializingB
|
|
}
|
|
}
|
|
}
|
|
}
|
|
{
|
|
{
|
|
- String property = properties.getProperty("druid.maxPoolPreparedStatementPerConnectionSize");
|
|
|
|
|
|
+ String property = properties.getProperty("maxPoolPreparedStatementPerConnectionSize");
|
|
if (property != null && property.length() > 0) {
|
|
if (property != null && property.length() > 0) {
|
|
druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(Integer.parseInt(property));
|
|
druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(Integer.parseInt(property));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ {
|
|
|
|
+ String validationQuery = properties.getProperty("validationQuery");
|
|
|
|
+ if (validationQuery != null && validationQuery.length() > 0) {
|
|
|
|
+ druidDataSource.setValidationQuery(validationQuery);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
ds = druidDataSource;
|
|
ds = druidDataSource;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void afterPropertiesSet() throws Exception {
|
|
|
|
+ Properties properties = new Properties();
|
|
|
|
+ loadProperties(properties);
|
|
|
|
+ afterPropertiesSet(properties);
|
|
|
|
+ }
|
|
|
|
+
|
|
public void setDsType(String dsType) {
|
|
public void setDsType(String dsType) {
|
|
this.dsType = dsType;
|
|
this.dsType = dsType;
|
|
}
|
|
}
|