11package org .smartboot .servlet ;
22
33
4- import org .smartboot .http .server .HttpBootstrap ;
5- import org .smartboot .http .server .HttpRequest ;
6- import org .smartboot .http .server .HttpResponse ;
7- import org .smartboot .http .server .HttpServerHandler ;
84import tech .smartboot .servlet .Container ;
95import tech .smartboot .servlet .ServletContextRuntime ;
106import tech .smartboot .servlet .conf .ServletInfo ;
117import tech .smartboot .servlet .conf .ServletMappingInfo ;
128
13- import java .util .concurrent .CompletableFuture ;
14-
159/**
16101711 * @version V1.0 , 2020/12/22
@@ -38,26 +32,11 @@ public static void main(String[] args) throws Throwable {
3832 applicationRuntime .getDeploymentInfo ().addServlet (jsonServletInfo );
3933 applicationRuntime .getDeploymentInfo ().addServletMapping (new ServletMappingInfo (jsonServletInfo .getServletName (), "/json" ));
4034 containerRuntime .addRuntime (applicationRuntime );
41-
4235 int cpuNum = Runtime .getRuntime ().availableProcessors ();
4336 // 定义服务器接受的消息类型以及各类消息对应的处理器
44- HttpBootstrap bootstrap = new HttpBootstrap ();
45- bootstrap .configuration ()
46- .threadNum (cpuNum )
47- .bannerEnabled (false )
48- .headerLimiter (0 )
49- .readBufferSize (1024 * 4 )
50- .writeBufferSize (1024 * 4 )
51- .readMemoryPool (16384 * 1024 * 4 )
52- .writeMemoryPool (10 * 1024 * 1024 * cpuNum , cpuNum );
53- containerRuntime .start (bootstrap .configuration ());
54- bootstrap .setPort (8080 )
55- .httpHandler (new HttpServerHandler () {
56- @ Override
57- public void handle (HttpRequest request , HttpResponse response , CompletableFuture <Object > completableFuture ) throws Throwable {
58- containerRuntime .doHandle (request , response , completableFuture );
59- }
60- })
61- .start ();
37+ containerRuntime .getConfiguration ()
38+ .setThreadNum (cpuNum )
39+ .setReadBufferSize (1024 * 4 );
40+ containerRuntime .start ();
6241 }
6342}
0 commit comments