From 3d847fb9b7a9781100e2b8ad31927718aa01eb78 Mon Sep 17 00:00:00 2001 From: redkale Date: Sat, 15 Mar 2025 11:51:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/redkale/boot/ApplicationListener.java | 14 +++++++------- .../java/org/redkale/convert/json/JsonObject.java | 5 +++++ .../org/redkale/net/http/HttpResourceServlet.java | 9 ++++----- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/redkale/boot/ApplicationListener.java b/src/main/java/org/redkale/boot/ApplicationListener.java index ee83b87cf..637c7cccf 100644 --- a/src/main/java/org/redkale/boot/ApplicationListener.java +++ b/src/main/java/org/redkale/boot/ApplicationListener.java @@ -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前调用 * diff --git a/src/main/java/org/redkale/convert/json/JsonObject.java b/src/main/java/org/redkale/convert/json/JsonObject.java index 7f1b4619f..c7c89faeb 100644 --- a/src/main/java/org/redkale/convert/json/JsonObject.java +++ b/src/main/java/org/redkale/convert/json/JsonObject.java @@ -58,7 +58,12 @@ public class JsonObject extends LinkedHashMap implements JsonEle return convertFrom(JsonConvert.root().convertTo(bean)); } + @Deprecated(since = "2.8.1") public T toObject(Type type) { + return cast(type); + } + + public T cast(Type type) { return (T) JsonConvert.root().convertFrom(type, JsonConvert.root().convertTo(this)); } diff --git a/src/main/java/org/redkale/net/http/HttpResourceServlet.java b/src/main/java/org/redkale/net/http/HttpResourceServlet.java index dfe929ebf..fd3413d5f 100644 --- a/src/main/java/org/redkale/net/http/HttpResourceServlet.java +++ b/src/main/java/org/redkale/net/http/HttpResourceServlet.java @@ -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;