1
1
package org .smartboot .servlet ;
2
2
3
3
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 ;
8
4
import tech .smartboot .servlet .Container ;
9
5
import tech .smartboot .servlet .ServletContextRuntime ;
10
6
import tech .smartboot .servlet .conf .ServletInfo ;
11
7
import tech .smartboot .servlet .conf .ServletMappingInfo ;
12
8
13
- import java .util .concurrent .CompletableFuture ;
14
-
15
9
/**
16
10
17
11
* @version V1.0 , 2020/12/22
@@ -38,26 +32,11 @@ public static void main(String[] args) throws Throwable {
38
32
applicationRuntime .getDeploymentInfo ().addServlet (jsonServletInfo );
39
33
applicationRuntime .getDeploymentInfo ().addServletMapping (new ServletMappingInfo (jsonServletInfo .getServletName (), "/json" ));
40
34
containerRuntime .addRuntime (applicationRuntime );
41
-
42
35
int cpuNum = Runtime .getRuntime ().availableProcessors ();
43
36
// 定义服务器接受的消息类型以及各类消息对应的处理器
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 ();
62
41
}
63
42
}
0 commit comments