Browse Source

适配最新版

zhengjw22 9 months ago
parent
commit
75844297ee

+ 2 - 2
frameworks/Java/smart-socket/pom.xml

@@ -11,7 +11,7 @@
         <maven.compiler.source>21</maven.compiler.source>
         <maven.compiler.target>21</maven.compiler.target>
         <log4j.version>2.17.1</log4j.version>
-        <smartservlet.version>1.5-SNAPSHOT</smartservlet.version>
+        <smartservlet.version>2.3</smartservlet.version>
         <hikaricp.version>5.0.0</hikaricp.version>
         <jsoniter.version>0.9.23</jsoniter.version>
     </properties>
@@ -23,7 +23,7 @@
             <version>0.1-SNAPSHOT</version>
         </dependency>
         <dependency>
-            <groupId>org.smartboot.servlet</groupId>
+            <groupId>tech.smartboot.servlet</groupId>
             <artifactId>servlet-core</artifactId>
             <version>${smartservlet.version}</version>
         </dependency>

+ 1 - 1
frameworks/Java/smart-socket/src/main/java/org/smartboot/http/JsonUtil.java

@@ -4,9 +4,9 @@ import com.jsoniter.output.JsonStream;
 import com.jsoniter.output.JsonStreamPool;
 import com.jsoniter.spi.JsonException;
 import com.jsoniter.spi.Slice;
+import jakarta.servlet.http.HttpServletResponse;
 import org.smartboot.http.server.HttpResponse;
 
-import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 
 /**

+ 8 - 4
frameworks/Java/smart-socket/src/main/java/org/smartboot/servlet/Bootstrap.java

@@ -1,10 +1,14 @@
 package org.smartboot.servlet;
 
+
 import org.smartboot.http.server.HttpBootstrap;
 import org.smartboot.http.server.HttpRequest;
 import org.smartboot.http.server.HttpResponse;
 import org.smartboot.http.server.HttpServerHandler;
-import org.smartboot.servlet.conf.ServletInfo;
+import tech.smartboot.servlet.Container;
+import tech.smartboot.servlet.ServletContextRuntime;
+import tech.smartboot.servlet.conf.ServletInfo;
+import tech.smartboot.servlet.conf.ServletMappingInfo;
 
 import java.util.concurrent.CompletableFuture;
 
@@ -15,7 +19,7 @@ import java.util.concurrent.CompletableFuture;
 public class Bootstrap {
 
     public static void main(String[] args) throws Throwable {
-        ContainerRuntime containerRuntime = new ContainerRuntime();
+        Container containerRuntime = new Container();
         // plaintext
         ServletContextRuntime applicationRuntime = new ServletContextRuntime(null, Thread.currentThread().getContextClassLoader(), "/");
         applicationRuntime.setVendorProvider(response -> {
@@ -24,15 +28,15 @@ public class Bootstrap {
         ServletInfo plainTextServletInfo = new ServletInfo();
         plainTextServletInfo.setServletName("plaintext");
         plainTextServletInfo.setServletClass(HelloWorldServlet.class.getName());
-        plainTextServletInfo.addMapping("/plaintext");
+        applicationRuntime.getDeploymentInfo().addServletMapping(new ServletMappingInfo(plainTextServletInfo.getServletName(), "/plaintext"));
         applicationRuntime.getDeploymentInfo().addServlet(plainTextServletInfo);
 
         // json
         ServletInfo jsonServletInfo = new ServletInfo();
         jsonServletInfo.setServletName("json");
         jsonServletInfo.setServletClass(JsonServlet.class.getName());
-        jsonServletInfo.addMapping("/json");
         applicationRuntime.getDeploymentInfo().addServlet(jsonServletInfo);
+        applicationRuntime.getDeploymentInfo().addServletMapping(new ServletMappingInfo(jsonServletInfo.getServletName(), "/json"));
         containerRuntime.addRuntime(applicationRuntime);
 
         int cpuNum = Runtime.getRuntime().availableProcessors();

+ 5 - 4
frameworks/Java/smart-socket/src/main/java/org/smartboot/servlet/HelloWorldServlet.java

@@ -1,10 +1,11 @@
 package org.smartboot.servlet;
 
 
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServlet;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+
 import java.io.IOException;
 
 /**

+ 4 - 4
frameworks/Java/smart-socket/src/main/java/org/smartboot/servlet/JsonServlet.java

@@ -1,12 +1,12 @@
 package org.smartboot.servlet;
 
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServlet;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
 import org.smartboot.Message;
 import org.smartboot.http.JsonUtil;
 
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 
 /**