13 Commits

Author SHA1 Message Date
Redkale
2b2fd9965b Redkale 2.0.0.beta1 结束 2019-05-25 10:46:10 +08:00
Redkale
0938635eb2 2019-05-18 08:37:53 +08:00
Redkale
a4a186751e 2019-05-01 08:05:37 +08:00
Redkale
ea5169b5c5 修改mysql中字符串带\会丢失的bug 2019-04-27 11:17:28 +08:00
Redkale
01bd195847 2019-04-26 21:24:02 +08:00
Redkale
a72c26a935 修复Utility.encodeUTF8和decodeUTF8 对4字节字符不能正常编码的bug 2019-04-22 12:24:55 +08:00
Redkale
a9900d9bfa 2019-04-19 19:41:04 +08:00
Redkale
6896401d2d 2019-04-19 19:32:24 +08:00
Redkale
886f01c9f3 DataSource在Cachable定时load时屏蔽log 2019-04-19 19:31:09 +08:00
Redkale
59c9251d70 2019-04-12 12:14:52 +08:00
Redkale
fad5f010d2 2019-04-12 11:57:21 +08:00
Redkale
737c4a92b9 修复ConvertFactory.registerIgnoreAll方法出现不生效的bug 2019-04-04 22:20:16 +08:00
Redkale
d3e8675948 Redkale 2.0.0.alpha2 开始 2019-04-04 22:18:49 +08:00
15 changed files with 91 additions and 40 deletions

View File

@@ -192,7 +192,7 @@ public class NodeHttpServer extends NodeServer {
} }
int max = 0; int max = 0;
if (ss != null && sb != null) { if (ss != null && sb != null) {
Collections.sort(ss, (AbstractMap.SimpleEntry<String, String[]> o1, AbstractMap.SimpleEntry<String, String[]> o2) -> o1.getKey().compareTo(o2.getKey())); ss.sort((AbstractMap.SimpleEntry<String, String[]> o1, AbstractMap.SimpleEntry<String, String[]> o2) -> o1.getKey().compareTo(o2.getKey()));
for (AbstractMap.SimpleEntry<String, String[]> as : ss) { for (AbstractMap.SimpleEntry<String, String[]> as : ss) {
if (as.getKey().length() > max) max = as.getKey().length(); if (as.getKey().length() > max) max = as.getKey().length();
} }
@@ -340,7 +340,7 @@ public class NodeHttpServer extends NodeServer {
} }
//输出信息 //输出信息
if (ss != null && !ss.isEmpty() && sb != null) { if (ss != null && !ss.isEmpty() && sb != null) {
Collections.sort(ss, (AbstractMap.SimpleEntry<String, String[]> o1, AbstractMap.SimpleEntry<String, String[]> o2) -> o1.getKey().compareTo(o2.getKey())); ss.sort((AbstractMap.SimpleEntry<String, String[]> o1, AbstractMap.SimpleEntry<String, String[]> o2) -> o1.getKey().compareTo(o2.getKey()));
int max = 0; int max = 0;
for (AbstractMap.SimpleEntry<String, String[]> as : ss) { for (AbstractMap.SimpleEntry<String, String[]> as : ss) {
if (as.getKey().length() > max) max = as.getKey().length(); if (as.getKey().length() > max) max = as.getKey().length();

View File

@@ -498,7 +498,7 @@ public abstract class NodeServer {
} }
//----------------- init ----------------- //----------------- init -----------------
List<Service> swlist = new ArrayList<>(localServices); List<Service> swlist = new ArrayList<>(localServices);
Collections.sort(swlist, (o1, o2) -> { swlist.sort((o1, o2) -> {
Priority p1 = o1.getClass().getAnnotation(Priority.class); Priority p1 = o1.getClass().getAnnotation(Priority.class);
Priority p2 = o2.getClass().getAnnotation(Priority.class); Priority p2 = o2.getClass().getAnnotation(Priority.class);
int v = (p2 == null ? 0 : p2.value()) - (p1 == null ? 0 : p1.value()); int v = (p2 == null ? 0 : p2.value()) - (p1 == null ? 0 : p1.value());

View File

@@ -89,4 +89,9 @@ public final class ConvertColumnEntry {
this.index = index; this.index = index;
} }
@Override
public String toString() {
return "ConvertColumnEntry{" + "index=" + index + ", name=" + name + ", ignore=" + ignore + ", convertType=" + convertType + '}';
}
} }

View File

@@ -251,8 +251,8 @@ public abstract class ConvertFactory<R extends Reader, W extends Writer> {
} }
for (ConvertColumn ref : ccs) { for (ConvertColumn ref : ccs) {
if (ref.type().contains(ct)) { if (ref.type().contains(ct)) {
String realName = ref.name().isEmpty() ? fieldName : ref.name();
if (onlyColumns != null && fieldName != null) { if (onlyColumns != null && fieldName != null) {
String realName = ref.name().isEmpty() ? fieldName : ref.name();
if (!onlyColumns.contains(realName)) return new ConvertColumnEntry(realName, true); if (!onlyColumns.contains(realName)) return new ConvertColumnEntry(realName, true);
} }
ConvertColumnEntry entry = new ConvertColumnEntry(ref); ConvertColumnEntry entry = new ConvertColumnEntry(ref);
@@ -260,7 +260,10 @@ public abstract class ConvertFactory<R extends Reader, W extends Writer> {
entry.setIgnore(false); entry.setIgnore(false);
return entry; return entry;
} }
if (skipIgnores.isEmpty()) return entry; if (skipIgnores.isEmpty()) {
if (onlyColumns != null && realName != null && onlyColumns.contains(realName)) entry.setIgnore(false);
return entry;
}
if (skipIgnores.contains(((Member) element).getDeclaringClass())) entry.setIgnore(false); if (skipIgnores.contains(((Member) element).getDeclaringClass())) entry.setIgnore(false);
return entry; return entry;
} }

View File

@@ -481,7 +481,7 @@ public abstract class Server<K extends Serializable, C extends Context, R extend
classLoader.addURL(url); classLoader.addURL(url);
} }
List<URL> list = new ArrayList<>(set); List<URL> list = new ArrayList<>(set);
Collections.sort(list, (URL o1, URL o2) -> o1.getFile().compareTo(o2.getFile())); list.sort((URL o1, URL o2) -> o1.getFile().compareTo(o2.getFile()));
return list.toArray(new URL[list.size()]); return list.toArray(new URL[list.size()]);
} }

View File

@@ -254,7 +254,7 @@ public class HttpPrepareServlet extends PrepareServlet<String, HttpContext, Http
logger.log(Level.WARNING, "init HttpRender(" + renderType + ") error", e); logger.log(Level.WARNING, "init HttpRender(" + renderType + ") error", e);
} }
} }
Collections.sort(renders, (o1, o2) -> o1.getType().isAssignableFrom(o2.getType()) ? 1 : -1); renders.sort((o1, o2) -> o1.getType().isAssignableFrom(o2.getType()) ? 1 : -1);
} }
} }
} }

View File

@@ -181,7 +181,7 @@ class WebSocketRunner implements Runnable {
} }
} else if (packet.type == FrameType.PONG) { } else if (packet.type == FrameType.PONG) {
try { try {
if (debug) context.getLogger().log(Level.FINEST, "WebSocketRunner onMessage by PONG FrameType : " + packet); //if (debug) context.getLogger().log(Level.FINEST, "WebSocketRunner onMessage by PONG FrameType : " + packet);
webSocket.onPong((byte[]) packet.receiveMessage); webSocket.onPong((byte[]) packet.receiveMessage);
} catch (Exception e) { } catch (Exception e) {
context.getLogger().log(Level.SEVERE, "WebSocket onPong error (" + packet + ")", e); context.getLogger().log(Level.SEVERE, "WebSocket onPong error (" + packet + ")", e);

View File

@@ -54,11 +54,11 @@ public class RetResult<T> {
this.result = result; this.result = result;
} }
public static <T> RetResult<T> success() { public static RetResult success() {
return new RetResult<>(); return new RetResult();
} }
public static <V, T> RetResult<T> success(V result) { public static <T> RetResult<T> success(T result) {
return new RetResult().result(result); return new RetResult().result(result);
} }

View File

@@ -350,7 +350,7 @@ public class DataJdbcSource extends DataSqlSource<Connection> {
Connection conn = null; Connection conn = null;
try { try {
conn = readPool.poll(); conn = readPool.poll();
conn.setReadOnly(true); //conn.setReadOnly(true);
final Statement stmt = conn.createStatement(); final Statement stmt = conn.createStatement();
ResultSet set = stmt.executeQuery(sql); ResultSet set = stmt.executeQuery(sql);
final Map map = new HashMap<>(); final Map map = new HashMap<>();
@@ -382,7 +382,7 @@ public class DataJdbcSource extends DataSqlSource<Connection> {
Connection conn = null; Connection conn = null;
try { try {
conn = readPool.poll(); conn = readPool.poll();
conn.setReadOnly(true); //conn.setReadOnly(true);
final Statement stmt = conn.createStatement(); final Statement stmt = conn.createStatement();
Number rs = defVal; Number rs = defVal;
ResultSet set = stmt.executeQuery(sql); ResultSet set = stmt.executeQuery(sql);
@@ -407,7 +407,7 @@ public class DataJdbcSource extends DataSqlSource<Connection> {
Connection conn = null; Connection conn = null;
try { try {
conn = readPool.poll(); conn = readPool.poll();
conn.setReadOnly(true); //conn.setReadOnly(true);
final Statement stmt = conn.createStatement(); final Statement stmt = conn.createStatement();
Map<K, N> rs = new LinkedHashMap<>(); Map<K, N> rs = new LinkedHashMap<>();
ResultSet set = stmt.executeQuery(sql); ResultSet set = stmt.executeQuery(sql);
@@ -433,7 +433,7 @@ public class DataJdbcSource extends DataSqlSource<Connection> {
Connection conn = null; Connection conn = null;
try { try {
conn = readPool.poll(); conn = readPool.poll();
conn.setReadOnly(true); //conn.setReadOnly(true);
final PreparedStatement ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); final PreparedStatement ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
ps.setFetchSize(1); ps.setFetchSize(1);
final ResultSet set = ps.executeQuery(); final ResultSet set = ps.executeQuery();
@@ -456,7 +456,7 @@ public class DataJdbcSource extends DataSqlSource<Connection> {
Connection conn = null; Connection conn = null;
try { try {
conn = readPool.poll(); conn = readPool.poll();
conn.setReadOnly(true); //conn.setReadOnly(true);
final Attribute<T, Serializable> attr = info.getAttribute(column); final Attribute<T, Serializable> attr = info.getAttribute(column);
final PreparedStatement ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); final PreparedStatement ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
ps.setFetchSize(1); ps.setFetchSize(1);
@@ -483,7 +483,7 @@ public class DataJdbcSource extends DataSqlSource<Connection> {
Connection conn = null; Connection conn = null;
try { try {
conn = readPool.poll(); conn = readPool.poll();
conn.setReadOnly(true); //conn.setReadOnly(true);
final PreparedStatement ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); final PreparedStatement ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
final ResultSet set = ps.executeQuery(); final ResultSet set = ps.executeQuery();
boolean rs = set.next() ? (set.getInt(1) > 0) : false; boolean rs = set.next() ? (set.getInt(1) > 0) : false;
@@ -502,11 +502,11 @@ public class DataJdbcSource extends DataSqlSource<Connection> {
} }
@Override @Override
protected <T> CompletableFuture<Sheet<T>> querySheetDB(EntityInfo<T> info, boolean needtotal, SelectColumn selects, Flipper flipper, FilterNode node) { protected <T> CompletableFuture<Sheet<T>> querySheetDB(EntityInfo<T> info, final boolean readcache, boolean needtotal, SelectColumn selects, Flipper flipper, FilterNode node) {
Connection conn = null; Connection conn = null;
try { try {
conn = readPool.poll(); conn = readPool.poll();
conn.setReadOnly(true); //conn.setReadOnly(true);
final SelectColumn sels = selects; final SelectColumn sels = selects;
final List<T> list = new ArrayList(); final List<T> list = new ArrayList();
final Map<Class, String> joinTabalis = node == null ? null : node.getJoinTabalis(); final Map<Class, String> joinTabalis = node == null ? null : node.getJoinTabalis();
@@ -516,7 +516,7 @@ public class DataJdbcSource extends DataSqlSource<Connection> {
if ("mysql".equals(dbtype) || "postgresql".equals(dbtype)) { if ("mysql".equals(dbtype) || "postgresql".equals(dbtype)) {
final String listsql = "SELECT " + info.getQueryColumns("a", selects) + " FROM " + info.getTable(node) + " a" + (join == null ? "" : join) final String listsql = "SELECT " + info.getQueryColumns("a", selects) + " FROM " + info.getTable(node) + " a" + (join == null ? "" : join)
+ ((where == null || where.length() == 0) ? "" : (" WHERE " + where)) + createSQLOrderby(info, flipper) + (flipper == null || flipper.getLimit() < 1 ? "" : (" LIMIT " + flipper.getLimit() + " OFFSET " + flipper.getOffset())); + ((where == null || where.length() == 0) ? "" : (" WHERE " + where)) + createSQLOrderby(info, flipper) + (flipper == null || flipper.getLimit() < 1 ? "" : (" LIMIT " + flipper.getLimit() + " OFFSET " + flipper.getOffset()));
if (info.isLoggable(logger, Level.FINEST, listsql)) { if (readcache && info.isLoggable(logger, Level.FINEST, listsql)) {
logger.finest(info.getType().getSimpleName() + " query sql=" + listsql); logger.finest(info.getType().getSimpleName() + " query sql=" + listsql);
} }
PreparedStatement ps = conn.prepareStatement(listsql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); PreparedStatement ps = conn.prepareStatement(listsql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
@@ -529,7 +529,7 @@ public class DataJdbcSource extends DataSqlSource<Connection> {
long total = list.size(); long total = list.size();
if (needtotal) { if (needtotal) {
final String countsql = "SELECT COUNT(*) FROM " + info.getTable(node) + " a" + (join == null ? "" : join) + ((where == null || where.length() == 0) ? "" : (" WHERE " + where)); final String countsql = "SELECT COUNT(*) FROM " + info.getTable(node) + " a" + (join == null ? "" : join) + ((where == null || where.length() == 0) ? "" : (" WHERE " + where));
if (info.isLoggable(logger, Level.FINEST, countsql)) { if (readcache && info.isLoggable(logger, Level.FINEST, countsql)) {
logger.finest(info.getType().getSimpleName() + " query countsql=" + countsql); logger.finest(info.getType().getSimpleName() + " query countsql=" + countsql);
} }
ps = conn.prepareStatement(countsql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); ps = conn.prepareStatement(countsql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
@@ -542,10 +542,10 @@ public class DataJdbcSource extends DataSqlSource<Connection> {
} }
final String sql = "SELECT " + info.getQueryColumns("a", selects) + " FROM " + info.getTable(node) + " a" + (join == null ? "" : join) final String sql = "SELECT " + info.getQueryColumns("a", selects) + " FROM " + info.getTable(node) + " a" + (join == null ? "" : join)
+ ((where == null || where.length() == 0) ? "" : (" WHERE " + where)) + info.createSQLOrderby(flipper); + ((where == null || where.length() == 0) ? "" : (" WHERE " + where)) + info.createSQLOrderby(flipper);
if (info.isLoggable(logger, Level.FINEST, sql)) { if (readcache && info.isLoggable(logger, Level.FINEST, sql)) {
logger.finest(info.getType().getSimpleName() + " query sql=" + sql + (flipper == null || flipper.getLimit() < 1 ? "" : (" LIMIT " + flipper.getLimit() + " OFFSET " + flipper.getOffset()))); logger.finest(info.getType().getSimpleName() + " query sql=" + sql + (flipper == null || flipper.getLimit() < 1 ? "" : (" LIMIT " + flipper.getLimit() + " OFFSET " + flipper.getOffset())));
} }
conn.setReadOnly(true); //conn.setReadOnly(true);
final PreparedStatement ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); final PreparedStatement ps = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
if (flipper != null && flipper.getLimit() > 0) ps.setFetchSize(flipper.getLimit()); if (flipper != null && flipper.getLimit() > 0) ps.setFetchSize(flipper.getLimit());
final ResultSet set = ps.executeQuery(); final ResultSet set = ps.executeQuery();
@@ -635,7 +635,7 @@ public class DataJdbcSource extends DataSqlSource<Connection> {
final Connection conn = readPool.poll(); final Connection conn = readPool.poll();
try { try {
if (logger.isLoggable(Level.FINEST)) logger.finest("direct query sql=" + sql); if (logger.isLoggable(Level.FINEST)) logger.finest("direct query sql=" + sql);
conn.setReadOnly(true); //conn.setReadOnly(true);
final Statement statement = conn.createStatement(); final Statement statement = conn.createStatement();
//final PreparedStatement statement = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); //final PreparedStatement statement = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
final ResultSet set = statement.executeQuery(sql);// ps.executeQuery(); final ResultSet set = statement.executeQuery(sql);// ps.executeQuery();

View File

@@ -144,7 +144,7 @@ public class DataMemorySource extends DataSqlSource<Void> {
} }
@Override @Override
protected <T> CompletableFuture<Sheet<T>> querySheetDB(EntityInfo<T> info, boolean needtotal, SelectColumn selects, Flipper flipper, FilterNode node) { protected <T> CompletableFuture<Sheet<T>> querySheetDB(EntityInfo<T> info, final boolean readcache, boolean needtotal, SelectColumn selects, Flipper flipper, FilterNode node) {
return CompletableFuture.completedFuture(new Sheet<>()); return CompletableFuture.completedFuture(new Sheet<>());
} }

View File

@@ -164,7 +164,7 @@ public abstract class DataSqlSource<DBChannel> extends AbstractService implement
protected abstract <T> CompletableFuture<Boolean> existsDB(final EntityInfo<T> info, final String sql, final boolean onlypk); protected abstract <T> CompletableFuture<Boolean> existsDB(final EntityInfo<T> info, final String sql, final boolean onlypk);
//查询一页数据 //查询一页数据
protected abstract <T> CompletableFuture<Sheet<T>> querySheetDB(final EntityInfo<T> info, final boolean needtotal, final SelectColumn selects, final Flipper flipper, final FilterNode node); protected abstract <T> CompletableFuture<Sheet<T>> querySheetDB(final EntityInfo<T> info, final boolean readcache, final boolean needtotal, final SelectColumn selects, final Flipper flipper, final FilterNode node);
protected <T> T getEntityValue(EntityInfo<T> info, final SelectColumn sels, final ResultSet set) throws SQLException { protected <T> T getEntityValue(EntityInfo<T> info, final SelectColumn sels, final ResultSet set) throws SQLException {
return info.getEntityValue(sels, set); return info.getEntityValue(sels, set);
@@ -284,6 +284,21 @@ public abstract class DataSqlSource<DBChannel> extends AbstractService implement
return null; return null;
} }
protected <T> String formatValueToString(final EntityInfo<T> info, Object value) {
final String dbtype = this.readPool.getDbtype();
if ("mysql".equals(dbtype)) {
if (value == null) return null;
if (value instanceof CharSequence) {
return new StringBuilder().append('\'').append(value.toString().replace("\\", "\\\\").replace("'", "\\'")).append('\'').toString();
} else if (!(value instanceof Number) && !(value instanceof java.util.Date)
&& !value.getClass().getName().startsWith("java.sql.") && !value.getClass().getName().startsWith("java.time.")) {
return new StringBuilder().append('\'').append(info.getJsonConvert().convertTo(value).replace("\\", "\\\\").replace("'", "\\'")).append('\'').toString();
}
return String.valueOf(value);
}
return info.formatToString(value);
}
//----------------------------- insert ----------------------------- //----------------------------- insert -----------------------------
/** /**
* 新增对象, 必须是Entity对象 * 新增对象, 必须是Entity对象
@@ -784,7 +799,7 @@ public abstract class DataSqlSource<DBChannel> extends AbstractService implement
return updateDB(info, null, sql, true, colval); return updateDB(info, null, sql, true, colval);
} else { } else {
String sql = "UPDATE " + info.getTable(pk) + " SET " + info.getSQLColumn(null, column) + " = " String sql = "UPDATE " + info.getTable(pk) + " SET " + info.getSQLColumn(null, column) + " = "
+ info.formatToString(info.getSQLValue(column, colval)) + " WHERE " + info.getPrimarySQLColumn() + " = " + FilterNode.formatToString(info.getSQLValue(info.getPrimarySQLColumn(), pk)); + formatValueToString(info, info.getSQLValue(column, colval)) + " WHERE " + info.getPrimarySQLColumn() + " = " + FilterNode.formatToString(info.getSQLValue(info.getPrimarySQLColumn(), pk));
return updateDB(info, null, sql, false); return updateDB(info, null, sql, false);
} }
} }
@@ -856,7 +871,7 @@ public abstract class DataSqlSource<DBChannel> extends AbstractService implement
return updateDB(info, null, sql, true, colval); return updateDB(info, null, sql, true, colval);
} else { } else {
String sql = "UPDATE " + info.getTable(node) + " a " + (join1 == null ? "" : (", " + join1)) String sql = "UPDATE " + info.getTable(node) + " a " + (join1 == null ? "" : (", " + join1))
+ " SET " + info.getSQLColumn(alias, column) + " = " + info.formatToString(colval) + " SET " + info.getSQLColumn(alias, column) + " = " + formatValueToString(info, colval)
+ ((where == null || where.length() == 0) ? (join2 == null ? "" : (" WHERE " + join2)) + ((where == null || where.length() == 0) ? (join2 == null ? "" : (" WHERE " + join2))
: (" WHERE " + where + (join2 == null ? "" : (" AND " + join2)))); : (" WHERE " + where + (join2 == null ? "" : (" AND " + join2))));
return updateDB(info, null, sql, false); return updateDB(info, null, sql, false);
@@ -1142,7 +1157,7 @@ public abstract class DataSqlSource<DBChannel> extends AbstractService implement
blobs.add((byte[]) val); blobs.add((byte[]) val);
setsql.append(" = ").append(prepareParamSign(++index)); setsql.append(" = ").append(prepareParamSign(++index));
} else { } else {
setsql.append(" = ").append(info.formatToString(val)); setsql.append(" = ").append(formatValueToString(info, val));
} }
} }
if (neednode) { if (neednode) {
@@ -2321,6 +2336,6 @@ public abstract class DataSqlSource<DBChannel> extends AbstractService implement
return CompletableFuture.completedFuture(cache.querySheet(needtotal, selects, flipper, node)); return CompletableFuture.completedFuture(cache.querySheet(needtotal, selects, flipper, node));
} }
} }
return querySheetDB(info, needtotal, selects, flipper, node); return querySheetDB(info, readcache, needtotal, selects, flipper, node);
} }
} }

View File

@@ -473,6 +473,15 @@ public final class EntityInfo<T> {
this.tablecopySQL = conf.getProperty(DataSources.JDBC_TABLECOPY_SQLTEMPLATE, "CREATE TABLE ${newtable} LIKE ${oldtable}"); this.tablecopySQL = conf.getProperty(DataSources.JDBC_TABLECOPY_SQLTEMPLATE, "CREATE TABLE ${newtable} LIKE ${oldtable}");
} }
/**
* 获取JsonConvert
*
* @return JsonConvert
*/
public JsonConvert getJsonConvert() {
return jsonConvert;
}
/** /**
* 创建主键值目前只支持UUID赋值 * 创建主键值目前只支持UUID赋值
* *

View File

@@ -17,7 +17,7 @@ public final class Redkale {
} }
public static String getDotedVersion() { public static String getDotedVersion() {
return "2.0.0"; return "2.0.0";
} }
public static int getMajorVersion() { public static int getMajorVersion() {

View File

@@ -566,6 +566,10 @@ public final class ResourceFactory {
list.add(src); list.add(src);
Class clazz = src.getClass(); Class clazz = src.getClass();
do { do {
if (java.lang.Enum.class.isAssignableFrom(clazz)) break;
final String cname = clazz.getName();
if (cname.startsWith("java.") || cname.startsWith("javax.")
|| cname.startsWith("jdk.") || cname.startsWith("sun.")) break;
for (Field field : clazz.getDeclaredFields()) { for (Field field : clazz.getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers())) continue; if (Modifier.isStatic(field.getModifiers())) continue;
field.setAccessible(true); field.setAccessible(true);
@@ -583,11 +587,10 @@ public final class ResourceFactory {
} }
} }
if (ns == null) continue; if (ns == null) continue;
final String nsname = ns.getClass().getName();
if (ns.getClass().isPrimitive() || ns.getClass().isArray() if (ns.getClass().isPrimitive() || ns.getClass().isArray()
|| ns.getClass().getName().startsWith("java.") || nsname.startsWith("java.") || nsname.startsWith("javax.")
|| ns.getClass().getName().startsWith("javax.") || nsname.startsWith("jdk.") || nsname.startsWith("sun.")) continue;
|| ns.getClass().getName().startsWith("jdk.")
|| ns.getClass().getName().startsWith("sun.")) continue;
if (flag) this.inject(ns, attachment, consumer, list); if (flag) this.inject(ns, attachment, consumer, list);
continue; continue;
} }

View File

@@ -1474,9 +1474,11 @@ public final class Utility {
final int limit = start + len; final int limit = start + len;
for (int i = start; i < limit; i++) { for (int i = start; i < limit; i++) {
b = bytes[i]; b = bytes[i];
if ((b >> 5) == -2) { if ((b >> 5) == -2) {// 2 bytes, 11 bits: 110xxxxx 10xxxxxx
size--; size--;
} else if ((b >> 4) == -2) { } else if ((b >> 4) == -2) {// 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
size -= 2;
} else if ((b >> 3) == -2) {// 4 bytes, 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
size -= 2; size -= 2;
} }
} }
@@ -1484,12 +1486,17 @@ public final class Utility {
size = 0; size = 0;
for (int i = start; i < limit;) { for (int i = start; i < limit;) {
b = bytes[i++]; b = bytes[i++];
if (b >= 0) { if (b >= 0) {// 1 byte, 7 bits: 0xxxxxxx
text[size++] = (char) b; text[size++] = (char) b;
} else if ((b >> 5) == -2) { } else if ((b >> 5) == -2) {// 2 bytes, 11 bits: 110xxxxx 10xxxxxx
text[size++] = (char) (((b << 6) ^ bytes[i++]) ^ (((byte) 0xC0 << 6) ^ ((byte) 0x80))); text[size++] = (char) (((b << 6) ^ bytes[i++]) ^ (((byte) 0xC0 << 6) ^ ((byte) 0x80)));
} else if ((b >> 4) == -2) { } else if ((b >> 4) == -2) {// 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
text[size++] = (char) ((b << 12) ^ (bytes[i++] << 6) ^ (bytes[i++] ^ (((byte) 0xE0 << 12) ^ ((byte) 0x80 << 6) ^ ((byte) 0x80)))); text[size++] = (char) ((b << 12) ^ (bytes[i++] << 6) ^ (bytes[i++] ^ (((byte) 0xE0 << 12) ^ ((byte) 0x80 << 6) ^ ((byte) 0x80))));
} else if ((b >> 3) == -2) {// 4 bytes, 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
int uc = ((b << 18) ^ (bytes[i++] << 12) ^ (bytes[i++] << 6) ^ (bytes[i++] ^ (((byte) 0xF0 << 18) ^ ((byte) 0x80 << 12) ^ ((byte) 0x80 << 6) ^ ((byte) 0x80))));
text[size++] = Character.highSurrogate(uc);
text[size++] = Character.lowSurrogate(uc);
//测试代码 byte[] bs = {(byte)34, (byte)76, (byte)105, (byte)108, (byte)121, (byte)240, (byte)159, (byte)146, (byte)171, (byte)34};
} }
} }
return text; return text;
@@ -1516,6 +1523,8 @@ public final class Utility {
size++; size++;
} else if (c < 0x800) { } else if (c < 0x800) {
size += 2; size += 2;
} else if (Character.isSurrogate(c)) {
size += 2;
} else { } else {
size += 3; size += 3;
} }
@@ -1529,6 +1538,13 @@ public final class Utility {
} else if (c < 0x800) { } else if (c < 0x800) {
bytes[size++] = (byte) (0xc0 | (c >> 6)); bytes[size++] = (byte) (0xc0 | (c >> 6));
bytes[size++] = (byte) (0x80 | (c & 0x3f)); bytes[size++] = (byte) (0x80 | (c & 0x3f));
} else if (Character.isSurrogate(c)) { //连取两个
int uc = Character.toCodePoint(c, chars[i + 1]);
bytes[size++] = (byte) (0xf0 | ((uc >> 18)));
bytes[size++] = (byte) (0x80 | ((uc >> 12) & 0x3f));
bytes[size++] = (byte) (0x80 | ((uc >> 6) & 0x3f));
bytes[size++] = (byte) (0x80 | (uc & 0x3f));
i++;
} else { } else {
bytes[size++] = (byte) (0xe0 | ((c >> 12))); bytes[size++] = (byte) (0xe0 | ((c >> 12)));
bytes[size++] = (byte) (0x80 | ((c >> 6) & 0x3f)); bytes[size++] = (byte) (0x80 | ((c >> 6) & 0x3f));