This commit is contained in:
Redkale
2017-03-20 13:53:13 +08:00
parent 7a195ecf23
commit 4fec27498c
6 changed files with 11 additions and 11 deletions

View File

@@ -307,7 +307,7 @@ public final class Application {
File persist = new File(this.home, "conf/persistence.xml");
final String homepath = this.home.getCanonicalPath();
if (persist.isFile()) System.setProperty(Sources.DATASOURCE_CONFPATH, persist.getCanonicalPath());
if (persist.isFile()) System.setProperty(DataSources.DATASOURCE_CONFPATH, persist.getCanonicalPath());
logger.log(Level.INFO, RESNAME_APP_HOME + "= " + homepath + "\r\n" + RESNAME_APP_ADDR + "= " + this.localAddress.getHostAddress());
String lib = config.getValue("lib", "").trim().replace("${APP_HOME}", homepath);
lib = lib.isEmpty() ? (homepath + "/conf") : (lib + ";" + homepath + "/conf");

View File

@@ -220,7 +220,7 @@ public abstract class NodeServer {
try {
if (field.getAnnotation(Resource.class) == null) return;
if ((src instanceof Service) && Sncp.isRemote((Service) src)) return; //远程模式不得注入 DataSource
DataSource source = Sources.createDataSource(resourceName);
DataSource source = DataSources.createDataSource(resourceName);
application.dataSources.add(source);
appResFactory.register(resourceName, DataSource.class, source);

View File

@@ -15,7 +15,7 @@ import javax.xml.stream.*;
*
* @author zhangjx
*/
public final class Sources {
public final class DataSources {
public static final String DATASOURCE_CONFPATH = "DATASOURCE_CONFPATH";
@@ -41,7 +41,7 @@ public final class Sources {
public static final String JDBC_SOURCE = "javax.persistence.jdbc.source";
private Sources() {
private DataSources() {
}
public static DataSource createDataSource(final String unitName) throws IOException {
@@ -51,7 +51,7 @@ public final class Sources {
}
public static DataSource createDataSource(final String unitName, URL url) throws IOException {
if (url == null) url = Sources.class.getResource("/persistence.xml");
if (url == null) url = DataSources.class.getResource("/persistence.xml");
InputStream in = url.openStream();
if (in == null) return null;
Map<String, Properties> map = loadPersistenceXml(in);

View File

@@ -304,11 +304,11 @@ public final class EntityInfo<T> {
this.cache = null;
}
if (conf == null) conf = new Properties();
this.containSQL = conf.getProperty(Sources.JDBC_CONTAIN_SQLTEMPLATE, "LOCATE(${keystr}, ${column}) > 0");
this.notcontainSQL = conf.getProperty(Sources.JDBC_NOTCONTAIN_SQLTEMPLATE, "LOCATE(${keystr}, ${column}) = 0");
this.containSQL = conf.getProperty(DataSources.JDBC_CONTAIN_SQLTEMPLATE, "LOCATE(${keystr}, ${column}) > 0");
this.notcontainSQL = conf.getProperty(DataSources.JDBC_NOTCONTAIN_SQLTEMPLATE, "LOCATE(${keystr}, ${column}) = 0");
this.tablenotexistSqlstates = ";" + conf.getProperty(Sources.JDBC_TABLENOTEXIST_SQLSTATES, "42000;42S02") + ";";
this.tablecopySQL = conf.getProperty(Sources.JDBC_TABLECOPY_SQLTEMPLATE, "CREATE TABLE ${newtable} LIKE ${oldtable}");
this.tablenotexistSqlstates = ";" + conf.getProperty(DataSources.JDBC_TABLENOTEXIST_SQLSTATES, "42000;42S02") + ";";
this.tablecopySQL = conf.getProperty(DataSources.JDBC_TABLECOPY_SQLTEMPLATE, "CREATE TABLE ${newtable} LIKE ${oldtable}");
}
/**

View File

@@ -16,7 +16,7 @@ import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import javax.sql.*;
import static org.redkale.source.Sources.*;
import static org.redkale.source.DataSources.*;
/**
*

View File

@@ -14,7 +14,7 @@ import org.redkale.source.*;
public class JDBCTest {
public static void main(String[] args) throws Exception {
DataSource source = Sources.createDataSource(""); //耗时37415
DataSource source = DataSources.createDataSource(""); //耗时37415
int count = 1000;
LoginTestRecord last = null;
long s = System.currentTimeMillis();