From 4952761c16b5d0b4bb1daf45f9af2752a85a5987 Mon Sep 17 00:00:00 2001 From: Willem Date: Sat, 14 Dec 2024 23:05:34 +0100 Subject: [PATCH] Upgraded jetty to jarkarta servlet spec --- .../nx01/warp/core/WarpCoreReactor.java | 1 - .../conf/logback-server-console.xml | 3 +- .../nx01/zerofungus/server/ZeroFungus.java | 40 ++++++++++++-- .../server/service/ZFunRtsConfigJetty.java | 9 +++- .../server/service/ZFunRtsConfigLogger.java | 44 ---------------- .../server/web/RedirectServlet.java | 6 +-- .../web/WarpCorePlasmaInspectorServlet.java | 52 +++++++++++++++++++ pom.xml | 2 +- 8 files changed, 102 insertions(+), 55 deletions(-) delete mode 100644 nx01-zerofungus-server/src/main/java/love/distributedrebirth/nx01/zerofungus/server/service/ZFunRtsConfigLogger.java create mode 100644 nx01-zerofungus-server/src/main/java/love/distributedrebirth/nx01/zerofungus/server/web/WarpCorePlasmaInspectorServlet.java diff --git a/nx01-warp-core/src/main/java/love/distributedrebirth/nx01/warp/core/WarpCoreReactor.java b/nx01-warp-core/src/main/java/love/distributedrebirth/nx01/warp/core/WarpCoreReactor.java index 4f3da58..a7fef09 100644 --- a/nx01-warp-core/src/main/java/love/distributedrebirth/nx01/warp/core/WarpCoreReactor.java +++ b/nx01-warp-core/src/main/java/love/distributedrebirth/nx01/warp/core/WarpCoreReactor.java @@ -39,7 +39,6 @@ public class WarpCoreReactor implements WarpReact { } public List listChilds(WarpReactPlasma slot) { - Objects.requireNonNull(slot); List result = new ArrayList<>(); synchronized (slots) { for (WarpReactPlasma slug : slots.keySet()) { diff --git a/nx01-zerofungus-server/conf/logback-server-console.xml b/nx01-zerofungus-server/conf/logback-server-console.xml index 016b04a..33b4b2f 100644 --- a/nx01-zerofungus-server/conf/logback-server-console.xml +++ b/nx01-zerofungus-server/conf/logback-server-console.xml @@ -21,7 +21,8 @@ - + + diff --git a/nx01-zerofungus-server/src/main/java/love/distributedrebirth/nx01/zerofungus/server/ZeroFungus.java b/nx01-zerofungus-server/src/main/java/love/distributedrebirth/nx01/zerofungus/server/ZeroFungus.java index d941ff9..448c659 100644 --- a/nx01-zerofungus-server/src/main/java/love/distributedrebirth/nx01/zerofungus/server/ZeroFungus.java +++ b/nx01-zerofungus-server/src/main/java/love/distributedrebirth/nx01/zerofungus/server/ZeroFungus.java @@ -5,7 +5,12 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; +import java.util.logging.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.bridge.SLF4JBridgeHandler; + +import ch.qos.logback.core.status.NopStatusListener; import love.distributedrebirth.nx01.no2all.react.nostr.client.NoStrRtsClient; import love.distributedrebirth.nx01.no2all.react.nostr.server.NoStrRtsServer; import love.distributedrebirth.nx01.no2all.react.nostr.server.relay.NoStrRtsServerRelay; @@ -16,7 +21,6 @@ import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllRtsServerLog; import love.distributedrebirth.nx01.warp.core.WarpCoreReactor; import love.distributedrebirth.nx01.warp.core.WarpCoreSpeedMonitor; import love.distributedrebirth.nx01.zerofungus.server.service.ZFunRtsConfigJetty; -import love.distributedrebirth.nx01.zerofungus.server.service.ZFunRtsConfigLogger; import love.distributedrebirth.nx01.zerofungus.server.service.ZFunRtsInitJdbc; public enum ZeroFungus /* implements BãßBȍőnAbacusInstanceMBeanʸᴰ */ { @@ -24,6 +28,7 @@ public enum ZeroFungus /* implements BãßBȍőnAbacusInstanceMBeanʸᴰ jetties = new ArrayList<>(); + private static final Logger logger = Logger.getLogger(ZeroFungus.class.getName()); public static void main(String[] args) { Iterator arguments = Arrays.asList(args).iterator(); @@ -31,6 +36,7 @@ public enum ZeroFungus /* implements BãßBȍőnAbacusInstanceMBeanʸᴰ v.stop()); // foei.fire(No2AllReactWarpCore.DILITHIUM, new EjectWrapCoreShutdown()); } public void start() { - // setup logger + warp monitor - foei.load(new ZFunRtsConfigLogger()); + // debug warp monitor foei.load(new WarpCoreSpeedMonitor()); // add websocket wire support + log diff --git a/nx01-zerofungus-server/src/main/java/love/distributedrebirth/nx01/zerofungus/server/service/ZFunRtsConfigJetty.java b/nx01-zerofungus-server/src/main/java/love/distributedrebirth/nx01/zerofungus/server/service/ZFunRtsConfigJetty.java index 445d66d..0cf91b1 100644 --- a/nx01-zerofungus-server/src/main/java/love/distributedrebirth/nx01/zerofungus/server/service/ZFunRtsConfigJetty.java +++ b/nx01-zerofungus-server/src/main/java/love/distributedrebirth/nx01/zerofungus/server/service/ZFunRtsConfigJetty.java @@ -19,6 +19,7 @@ import org.eclipse.jetty.webapp.Configuration; import org.eclipse.jetty.webapp.WebAppContext; import org.eclipse.jetty.webapp.WebInfConfiguration; import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer; +import org.h2.server.web.JakartaWebServlet; import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllActServer; import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllRtsServer; @@ -29,6 +30,7 @@ import love.distributedrebirth.nx01.warp.core.react.WarpReactPlasmaPulse; import love.distributedrebirth.nx01.warp.core.react.WarpReactTypeScript; import love.distributedrebirth.nx01.warp.core.space.WarpSpaceAntimatterInducer; import love.distributedrebirth.nx01.zerofungus.server.web.RedirectServlet; +import love.distributedrebirth.nx01.zerofungus.server.web.WarpCorePlasmaInspectorServlet; public final class ZFunRtsConfigJetty implements WarpReactTypeScript { @@ -70,9 +72,12 @@ public final class ZFunRtsConfigJetty implements WarpReactTypeScript { }); logger.info("Add H2 console on: /debug/jdbc/console"); - // TODO: upgrade jetty, H2 has added "JakartaWebServlet" - context.addServlet("org.h2.server.web.WebServlet", "/debug/jdbc/console/*"); + context.addServlet(JakartaWebServlet.class, "/debug/jdbc/console/*"); + logger.info("Add plasma inspector on: /debug/warpcore/inspector"); + context.addServlet(WarpCorePlasmaInspectorServlet.class, "/debug/warpcore/inspector"); + + context.addServlet(RedirectServlet.class, "/test"); // for static diff --git a/nx01-zerofungus-server/src/main/java/love/distributedrebirth/nx01/zerofungus/server/service/ZFunRtsConfigLogger.java b/nx01-zerofungus-server/src/main/java/love/distributedrebirth/nx01/zerofungus/server/service/ZFunRtsConfigLogger.java deleted file mode 100644 index 20420f7..0000000 --- a/nx01-zerofungus-server/src/main/java/love/distributedrebirth/nx01/zerofungus/server/service/ZFunRtsConfigLogger.java +++ /dev/null @@ -1,44 +0,0 @@ -package love.distributedrebirth.nx01.zerofungus.server.service; - -import java.util.logging.Logger; - -import org.slf4j.LoggerFactory; -import org.slf4j.bridge.SLF4JBridgeHandler; - -import ch.qos.logback.core.status.NopStatusListener; -import love.distributedrebirth.nx01.warp.core.react.WarpReactPlasma; -import love.distributedrebirth.nx01.warp.core.react.WarpReactPlasmaPulse; -import love.distributedrebirth.nx01.warp.core.react.WarpReactTypeScript; -import love.distributedrebirth.nx01.warp.core.space.WarpSpaceAntimatterInducer; - -public class ZFunRtsConfigLogger implements WarpReactTypeScript { - - public static final WarpReactPlasma API = WarpReactPlasma.ofClass(ZFunRtsConfigLogger.class); - private static final Logger logger = Logger.getLogger(ZFunRtsConfigLogger.class.getName()); - - @Override - public void onEvent(WarpReactPlasmaPulse signal) { - if (System.getProperty("logback.configurationFile") == null) { - String logConfig = null; - if (System.getProperty("java.class.path").contains("classes")) { - logConfig = "conf/logback-server-console.xml"; - } else { - logConfig = "conf/logback-server.xml"; - } - System.setProperty("logback.configurationFile", logConfig); - } - if (System.getProperty("logback.statusListenerClass") == null) { - System.setProperty("logback.statusListenerClass",NopStatusListener.class.getName()); - } - org.slf4j.Logger logger2 = LoggerFactory.getLogger(ZFunRtsConfigLogger.class); - logger2.info("Logging configured."); - - SLF4JBridgeHandler.removeHandlersForRootLogger(); - SLF4JBridgeHandler.install(); - logger.info(" ╦┬ ┬╦ ╦═╗┌─┐╦ ╦┬╦═╗┌─┐╔╦╗"); - logger.info(" ║│ │║ ╠╦╝├┤ ║║║│╠╦╝├┤ ║║"); - logger.info("╚╝└─┘╩═╝ ╩╚═└─┘╚╩╝┴╩╚═└─┘═╩╝"); - //https://patorjk.com/software/taag - // Calvin S - } -} diff --git a/nx01-zerofungus-server/src/main/java/love/distributedrebirth/nx01/zerofungus/server/web/RedirectServlet.java b/nx01-zerofungus-server/src/main/java/love/distributedrebirth/nx01/zerofungus/server/web/RedirectServlet.java index 6644d8a..47d47f0 100644 --- a/nx01-zerofungus-server/src/main/java/love/distributedrebirth/nx01/zerofungus/server/web/RedirectServlet.java +++ b/nx01-zerofungus-server/src/main/java/love/distributedrebirth/nx01/zerofungus/server/web/RedirectServlet.java @@ -2,9 +2,9 @@ package love.distributedrebirth.nx01.zerofungus.server.web; import java.io.IOException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; public class RedirectServlet extends HttpServlet { diff --git a/nx01-zerofungus-server/src/main/java/love/distributedrebirth/nx01/zerofungus/server/web/WarpCorePlasmaInspectorServlet.java b/nx01-zerofungus-server/src/main/java/love/distributedrebirth/nx01/zerofungus/server/web/WarpCorePlasmaInspectorServlet.java new file mode 100644 index 0000000..8d50c2a --- /dev/null +++ b/nx01-zerofungus-server/src/main/java/love/distributedrebirth/nx01/zerofungus/server/web/WarpCorePlasmaInspectorServlet.java @@ -0,0 +1,52 @@ +package love.distributedrebirth.nx01.zerofungus.server.web; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.List; + +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import love.distributedrebirth.nx01.warp.core.WarpCorePlasmaIntermixChamber; +import love.distributedrebirth.nx01.warp.core.WarpCoreReactor; +import love.distributedrebirth.nx01.warp.core.react.WarpReactPlasma; +import love.distributedrebirth.nx01.zerofungus.server.ZeroFungus; + +public class WarpCorePlasmaInspectorServlet extends HttpServlet { + + private static final long serialVersionUID = 1L; + + @Override + public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { + response.setContentType("text/xml"); + response.setCharacterEncoding("utf-8"); + PrintWriter out = response.getWriter(); + + WarpCoreReactor reactor = ZeroFungus.INSTANCE.getWarpCore(); + List slots = reactor.listChilds(null); + out.println("\n"); + out.println("\n"); + for (WarpReactPlasma slot : slots) { + WarpCorePlasmaIntermixChamber contract = reactor.getSlotContract(slot); + out.println("\t\n"); + printClaims(out, "in", contract.getSlotTypesIn()); + printClaims(out, "out", contract.getSlotTypesOut()); + out.println("\n"); + } + out.println("\t\n"); + out.flush(); + } + + private void printClaims(PrintWriter out, String tag, List> clazzes) { + if (clazzes.isEmpty()) { + return; + } + out.println("\t\t\n"); + for (Class cls : clazzes) { + out.print("\t\t\t"); + out.print(cls); + out.println("\n"); + } + out.println("\t\t\n"); + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 29ab63b..920f42d 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ UTF-8 11 - 10.0.20 + 11.0.24 5.3.6 1.2.10 2.0.7