This commit is contained in:
@@ -242,13 +242,7 @@ public abstract class NodeServer {
|
|||||||
if (sourceConf != null) {
|
if (sourceConf != null) {
|
||||||
final Class sourceType = resEntry.getKey();
|
final Class sourceType = resEntry.getKey();
|
||||||
if (sourceType == DataJdbcSource.class) {
|
if (sourceType == DataJdbcSource.class) {
|
||||||
Properties prop = new Properties();
|
source = DataSources.createDataSource(resourceName, sourceConf);
|
||||||
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);
|
|
||||||
} else {
|
} else {
|
||||||
boolean can = false;
|
boolean can = false;
|
||||||
for (Constructor cr : sourceType.getConstructors()) {
|
for (Constructor cr : sourceType.getConstructors()) {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import java.lang.reflect.Constructor;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import javax.xml.stream.*;
|
import javax.xml.stream.*;
|
||||||
|
import org.redkale.util.AnyValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -56,6 +57,19 @@ public final class DataSources {
|
|||||||
private 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 {
|
public static DataSource createDataSource(final String unitName, Properties prop) throws IOException {
|
||||||
return createDataSource(unitName, prop, prop);
|
return createDataSource(unitName, prop, prop);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user