Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fbc4436c7c | ||
|
|
3d847fb9b7 | ||
|
|
bdcebcb67d | ||
|
|
e85e8b745f | ||
|
|
be13d9711f | ||
|
|
76c4a36ec7 |
2
pom.xml
2
pom.xml
@@ -8,7 +8,7 @@
|
||||
<name>RedkaleProject</name>
|
||||
<url>https://redkale.org</url>
|
||||
<description>redkale -- java framework</description>
|
||||
<version>2.8.0-SNAPSHOT</version>
|
||||
<version>2.8.1-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
@@ -31,6 +31,13 @@ public interface ApplicationListener {
|
||||
*/
|
||||
default void onPreStart(Application application) {}
|
||||
|
||||
/**
|
||||
* Application在运行start后调用
|
||||
*
|
||||
* @param application Application
|
||||
*/
|
||||
default void onPostStart(Application application) {}
|
||||
|
||||
/**
|
||||
* 服务全部停掉前被调用
|
||||
*
|
||||
@@ -45,13 +52,6 @@ public interface ApplicationListener {
|
||||
*/
|
||||
default void onServersPostStop(Application application) {}
|
||||
|
||||
/**
|
||||
* Application在运行start后调用
|
||||
*
|
||||
* @param application Application
|
||||
*/
|
||||
default void onPostStart(Application application) {}
|
||||
|
||||
/**
|
||||
* Application在运行Compile前调用
|
||||
*
|
||||
|
||||
@@ -58,7 +58,12 @@ public class JsonObject extends LinkedHashMap<String, Object> implements JsonEle
|
||||
return convertFrom(JsonConvert.root().convertTo(bean));
|
||||
}
|
||||
|
||||
@Deprecated(since = "2.8.1")
|
||||
public <T> T toObject(Type type) {
|
||||
return cast(type);
|
||||
}
|
||||
|
||||
public <T> T cast(Type type) {
|
||||
return (T) JsonConvert.root().convertFrom(type, JsonConvert.root().convertTo(this));
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,9 @@
|
||||
*/
|
||||
package org.redkale.net.http;
|
||||
|
||||
import static java.nio.file.StandardWatchEventKinds.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import static java.nio.file.StandardWatchEventKinds.*;
|
||||
import java.util.*;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -52,7 +51,7 @@ public class HttpResourceServlet extends HttpServlet {
|
||||
key.cancel();
|
||||
continue;
|
||||
}
|
||||
key.pollEvents().stream().forEach((event) -> {
|
||||
key.pollEvents().forEach(event -> {
|
||||
try {
|
||||
Path path = parent.resolve((Path) event.context());
|
||||
final String uri =
|
||||
@@ -92,10 +91,10 @@ public class HttpResourceServlet extends HttpServlet {
|
||||
protected final LongAdder cachedLength = new LongAdder();
|
||||
|
||||
// 缓存总大小, 默认0
|
||||
protected long cachelimit = 0 * 1024 * 1024L;
|
||||
protected long cachelimit = 0L * 1024 * 1024L;
|
||||
|
||||
// 最大可缓存的文件大小, 大于该值的文件将不被缓存
|
||||
protected long cachelengthmax = 1 * 1024 * 1024;
|
||||
protected long cachelengthmax = 1L * 1024 * 1024;
|
||||
|
||||
// 是否监控缓存文件的变化, 默认不监控
|
||||
protected boolean watch = false;
|
||||
|
||||
@@ -97,6 +97,22 @@ public class RetResult<T> implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public <V> RetResult<V> cast(Type newType) {
|
||||
return cast(this, newType);
|
||||
}
|
||||
|
||||
public static <V> RetResult<V> cast(RetResult rs, Type newType) {
|
||||
Object d = rs.result;
|
||||
if (d != null) {
|
||||
String text = d instanceof CharSequence
|
||||
? d.toString()
|
||||
: JsonConvert.root().convertTo(d);
|
||||
V n = JsonConvert.root().convertFrom(newType, text);
|
||||
return new RetResult(rs.retcode, rs.retinfo, n).convert(rs.convert);
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
public CompletableFuture<RetResult<T>> toFuture() {
|
||||
return CompletableFuture.completedFuture(this);
|
||||
}
|
||||
|
||||
@@ -1084,6 +1084,12 @@ public final class EntityCache<T> {
|
||||
case SET:
|
||||
if (val instanceof ColumnExpNode) {
|
||||
val = updateColumnExpNode(attr, entity, (ColumnExpNode) val);
|
||||
} else if (val instanceof ColumnNameNode) {
|
||||
val = ((ColumnNameNode) val).getColumn();
|
||||
} else if (val instanceof ColumnStringNode) {
|
||||
val = ((ColumnStringNode) val).getValue();
|
||||
} else if (val instanceof ColumnNumberNode) {
|
||||
val = ((ColumnNumberNode) val).getValue();
|
||||
}
|
||||
newVal = val;
|
||||
if (val instanceof Number) {
|
||||
|
||||
@@ -81,6 +81,17 @@ public interface Copier<S, D> extends BiFunction<S, D, D> {
|
||||
.apply(src, dest);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将源对象复制一份
|
||||
*
|
||||
* @param <S> 源类泛型
|
||||
* @param src 源对象
|
||||
* @return 目标对象
|
||||
*/
|
||||
public static <S> S copy(final S src) {
|
||||
return src == null ? null : (S) copy(src, src.getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将源对象字段复制到目标对象
|
||||
*
|
||||
|
||||
@@ -23,7 +23,7 @@ public final class Redkale {
|
||||
}
|
||||
|
||||
public static String getDotedVersion() {
|
||||
return "2.8.0";
|
||||
return "2.8.1";
|
||||
}
|
||||
|
||||
public static int getMajorVersion() {
|
||||
|
||||
@@ -21,6 +21,8 @@ public final class Times {
|
||||
|
||||
private static final int ZONE_RAW_OFFSET = TimeZone.getDefault().getRawOffset();
|
||||
|
||||
static final String FORMAT_DAY = "%1$tY-%1$tm-%1$td"; // yyyy-MM-dd
|
||||
|
||||
static final String FORMAT_SECONDS = "%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS"; // yyyy-MM-dd HH:mm:ss
|
||||
|
||||
static final String FORMAT_MILLS = "%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS.%1$tL"; // yyyy-MM-dd HH:mm:ss.fff
|
||||
@@ -47,6 +49,25 @@ public final class Times {
|
||||
return String.format(FORMAT_MILLS, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当天2015-01-01格式的string值
|
||||
*
|
||||
* @return 2015-01-01格式的string值
|
||||
*/
|
||||
public static String nowDay() {
|
||||
return String.format(FORMAT_DAY, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
* 将指定时间格式化为 yyyy-MM-dd
|
||||
*
|
||||
* @param time 待格式化的时间
|
||||
* @return 格式为yyyy-MM-dd的时间值
|
||||
*/
|
||||
public static String formatDay(long time) {
|
||||
return String.format(FORMAT_DAY, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将指定时间格式化为 yyyy-MM-dd HH:mm:ss
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user