From 4fec27498cba2fe7e97dd6b514ff91a0f1bbe1d5 Mon Sep 17 00:00:00 2001 From: Redkale <22250530@qq.com> Date: Mon, 20 Mar 2017 13:53:13 +0800 Subject: [PATCH] --- src/org/redkale/boot/Application.java | 2 +- src/org/redkale/boot/NodeServer.java | 2 +- src/org/redkale/source/{Sources.java => DataSources.java} | 6 +++--- src/org/redkale/source/EntityInfo.java | 8 ++++---- src/org/redkale/source/PoolJdbcSource.java | 2 +- test/org/redkale/test/source/JDBCTest.java | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) rename src/org/redkale/source/{Sources.java => DataSources.java} (95%) diff --git a/src/org/redkale/boot/Application.java b/src/org/redkale/boot/Application.java index 1fcbf3c71..101de81f9 100644 --- a/src/org/redkale/boot/Application.java +++ b/src/org/redkale/boot/Application.java @@ -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"); diff --git a/src/org/redkale/boot/NodeServer.java b/src/org/redkale/boot/NodeServer.java index f3a193685..2ffe3ddd7 100644 --- a/src/org/redkale/boot/NodeServer.java +++ b/src/org/redkale/boot/NodeServer.java @@ -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); diff --git a/src/org/redkale/source/Sources.java b/src/org/redkale/source/DataSources.java similarity index 95% rename from src/org/redkale/source/Sources.java rename to src/org/redkale/source/DataSources.java index 4d3223f8d..bd6fbbfc7 100644 --- a/src/org/redkale/source/Sources.java +++ b/src/org/redkale/source/DataSources.java @@ -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 map = loadPersistenceXml(in); diff --git a/src/org/redkale/source/EntityInfo.java b/src/org/redkale/source/EntityInfo.java index 1430d6f67..8bd5dead3 100644 --- a/src/org/redkale/source/EntityInfo.java +++ b/src/org/redkale/source/EntityInfo.java @@ -304,11 +304,11 @@ public final class EntityInfo { 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}"); } /** diff --git a/src/org/redkale/source/PoolJdbcSource.java b/src/org/redkale/source/PoolJdbcSource.java index 7367cb418..1b8a8cdf6 100644 --- a/src/org/redkale/source/PoolJdbcSource.java +++ b/src/org/redkale/source/PoolJdbcSource.java @@ -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.*; /** * diff --git a/test/org/redkale/test/source/JDBCTest.java b/test/org/redkale/test/source/JDBCTest.java index 543575e3d..835df0f6d 100644 --- a/test/org/redkale/test/source/JDBCTest.java +++ b/test/org/redkale/test/source/JDBCTest.java @@ -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();