Browse Source

update smart-servlet to 0.1.3-SNAPSHOT (#6271)

* update smart-servlet to 0.1.3-SNAPSHOT

* update aio-enhance to 1.0.3-SNAPSHOT
三刀 4 years ago
parent
commit
f08a4a8b01

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

@@ -11,8 +11,8 @@
         <maven.compiler.source>11</maven.compiler.source>
         <maven.compiler.source>11</maven.compiler.source>
         <maven.compiler.target>11</maven.compiler.target>
         <maven.compiler.target>11</maven.compiler.target>
         <log4j.version>2.11.0</log4j.version>
         <log4j.version>2.11.0</log4j.version>
-        <aio-enhance.version>1.0.2</aio-enhance.version>
-        <smartservlet.version>0.1.2-SNAPSHOT</smartservlet.version>
+        <aio-enhance.version>1.0.3-SNAPSHOT</aio-enhance.version>
+        <smartservlet.version>0.1.3-SNAPSHOT</smartservlet.version>
         <smartsocket.version>1.5.5-SNAPSHOT</smartsocket.version>
         <smartsocket.version>1.5.5-SNAPSHOT</smartsocket.version>
     </properties>
     </properties>
 
 

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

@@ -1,9 +1,12 @@
 package org.smartboot.servlet;
 package org.smartboot.servlet;
 
 
 import org.smartboot.aio.EnhanceAsynchronousChannelProvider;
 import org.smartboot.aio.EnhanceAsynchronousChannelProvider;
+import org.smartboot.http.HttpRequest;
+import org.smartboot.http.HttpResponse;
 import org.smartboot.http.server.HttpMessageProcessor;
 import org.smartboot.http.server.HttpMessageProcessor;
 import org.smartboot.http.server.HttpRequestProtocol;
 import org.smartboot.http.server.HttpRequestProtocol;
 import org.smartboot.http.server.Request;
 import org.smartboot.http.server.Request;
+import org.smartboot.http.server.handle.HttpHandle;
 import org.smartboot.servlet.conf.ServletInfo;
 import org.smartboot.servlet.conf.ServletInfo;
 import org.smartboot.socket.StateMachineEnum;
 import org.smartboot.socket.StateMachineEnum;
 import org.smartboot.socket.buffer.BufferFactory;
 import org.smartboot.socket.buffer.BufferFactory;
@@ -24,26 +27,30 @@ public class Bootstrap {
     public static void main(String[] args) {
     public static void main(String[] args) {
         System.setProperty("java.nio.channels.spi.AsynchronousChannelProvider", EnhanceAsynchronousChannelProvider.class.getName());
         System.setProperty("java.nio.channels.spi.AsynchronousChannelProvider", EnhanceAsynchronousChannelProvider.class.getName());
 
 
-        ServletHttpHandle httpHandle = new ServletHttpHandle();
-        ContainerRuntime containerRuntime = new ContainerRuntime("/");
+        ContainerRuntime containerRuntime = new ContainerRuntime();
         // plaintext
         // plaintext
+        ApplicationRuntime applicationRuntime = new ApplicationRuntime("/");
         ServletInfo plainTextServletInfo = new ServletInfo();
         ServletInfo plainTextServletInfo = new ServletInfo();
         plainTextServletInfo.setServletName("plaintext");
         plainTextServletInfo.setServletName("plaintext");
         plainTextServletInfo.setServletClass(HelloWorldServlet.class.getName());
         plainTextServletInfo.setServletClass(HelloWorldServlet.class.getName());
         plainTextServletInfo.addMapping("/plaintext");
         plainTextServletInfo.addMapping("/plaintext");
-        containerRuntime.getDeploymentInfo().addServlet(plainTextServletInfo);
+        applicationRuntime.getDeploymentInfo().addServlet(plainTextServletInfo);
 
 
         // json
         // json
         ServletInfo jsonServletInfo = new ServletInfo();
         ServletInfo jsonServletInfo = new ServletInfo();
         jsonServletInfo.setServletName("json");
         jsonServletInfo.setServletName("json");
         jsonServletInfo.setServletClass(HelloWorldServlet.class.getName());
         jsonServletInfo.setServletClass(HelloWorldServlet.class.getName());
         jsonServletInfo.addMapping("/json");
         jsonServletInfo.addMapping("/json");
-        containerRuntime.getDeploymentInfo().addServlet(jsonServletInfo);
-        httpHandle.addRuntime(containerRuntime);
-
-        httpHandle.start();
+        applicationRuntime.getDeploymentInfo().addServlet(jsonServletInfo);
+        containerRuntime.addRuntime(applicationRuntime);
+        containerRuntime.start();
         HttpMessageProcessor processor = new HttpMessageProcessor();
         HttpMessageProcessor processor = new HttpMessageProcessor();
-        processor.pipeline(httpHandle);
+        processor.pipeline(new HttpHandle() {
+            @Override
+            public void doHandle(HttpRequest request, HttpResponse response) throws IOException {
+                containerRuntime.doHandle(request, response);
+            }
+        });
         http(processor);
         http(processor);
     }
     }