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