This commit is contained in:
Redkale
2018-12-10 19:51:31 +08:00
parent 087b4cb571
commit 1b188c863c
2 changed files with 15 additions and 7 deletions

View File

@@ -242,13 +242,7 @@ public abstract class NodeServer {
if (sourceConf != null) {
final Class sourceType = resEntry.getKey();
if (sourceType == DataJdbcSource.class) {
Properties prop = new Properties();
for (AnyValue itemConf : sourceConf.getAnyValues("property")) {
String name = itemConf.getValue("name");
String value = itemConf.getValue("value");
if (name != null && value != null) prop.put(name, value);
}
source = DataSources.createDataSource(resourceName, prop);
source = DataSources.createDataSource(resourceName, sourceConf);
} else {
boolean can = false;
for (Constructor cr : sourceType.getConstructors()) {

View File

@@ -10,6 +10,7 @@ import java.lang.reflect.Constructor;
import java.net.URL;
import java.util.*;
import javax.xml.stream.*;
import org.redkale.util.AnyValue;
/**
*
@@ -56,6 +57,19 @@ public final class DataSources {
private DataSources() {
}
public static DataSource createDataSource(final String unitName, final AnyValue conf) throws IOException {
Properties prop = new Properties();
AnyValue[] confs = conf.getAnyValues("property");
if (confs != null) {
for (AnyValue itemConf : confs) {
String name = itemConf.getValue("name");
String value = itemConf.getValue("value");
if (name != null && value != null) prop.put(name, value);
}
}
return createDataSource(unitName, prop, prop);
}
public static DataSource createDataSource(final String unitName, Properties prop) throws IOException {
return createDataSource(unitName, prop, prop);
}