add a special prefix into ha-datasource properties file

In order to put HA Datasource properties and other properties altogether into one properties file, HighAvailableDataSource add a new field named propertyPrefix.
This commit is contained in:
DigitalSonic
2018-12-13 00:15:47 +08:00
parent 6ce53e3203
commit 65fafdb67a
4 changed files with 64 additions and 4 deletions
@@ -88,6 +88,7 @@ public class HighAvailableDataSource extends WrapperAdapter implements DataSourc
private Map<String, DataSource> dataSourceMap = new ConcurrentHashMap<String, DataSource>();
private DataSourceSelector selector = new RandomDataSourceSelector(this);
private String dataSourceFile = DEFAULT_DATA_SOURCE_FILE;
private String propertyPrefix = "";
private boolean inited = false;
@@ -100,7 +101,7 @@ public class HighAvailableDataSource extends WrapperAdapter implements DataSourc
return;
}
if (dataSourceMap == null || dataSourceMap.isEmpty()) {
dataSourceMap = new DataSourceCreator(dataSourceFile).createMap(this);
dataSourceMap = new DataSourceCreator(dataSourceFile, propertyPrefix).createMap(this);
}
if (selector == null) {
selector = new RandomDataSourceSelector(this);
@@ -146,6 +147,14 @@ public class HighAvailableDataSource extends WrapperAdapter implements DataSourc
this.dataSourceFile = dataSourceFile;
}
public String getPropertyPrefix() {
return propertyPrefix;
}
public void setPropertyPrefix(String propertyPrefix) {
this.propertyPrefix = propertyPrefix;
}
public void setDataSourceMap(Map<String, DataSource> dataSourceMap) {
if (dataSourceMap != null) {
this.dataSourceMap = dataSourceMap;