Skip to content

Commit 1347601

Browse files
committed
适配最新版
1 parent 40ce60d commit 1347601

File tree

3 files changed

+6
-29
lines changed

3 files changed

+6
-29
lines changed

frameworks/Java/smart-socket/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<maven.compiler.source>21</maven.compiler.source>
1212
<maven.compiler.target>21</maven.compiler.target>
1313
<log4j.version>2.17.1</log4j.version>
14-
<smartservlet.version>2.3</smartservlet.version>
14+
<smartservlet.version>2.4</smartservlet.version>
1515
<hikaricp.version>5.0.0</hikaricp.version>
1616
<jsoniter.version>0.9.23</jsoniter.version>
1717
</properties>

frameworks/Java/smart-socket/src/main/java/org/smartboot/http/Bootstrap.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ public void handle(HttpRequest request, HttpResponse response) throws IOExceptio
5353
.threadNum(cpuNum)
5454
.headerLimiter(0)
5555
.readBufferSize(1024 * 4)
56-
.writeBufferSize(1024 * 4)
57-
.readMemoryPool(16384 * 1024 * 4)
58-
.writeMemoryPool(10 * 1024 * 1024 * cpuNum, cpuNum);
56+
.writeBufferSize(1024 * 4);
5957
bootstrap.httpHandler(routeHandle).setPort(8080).start();
6058
}
6159

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
package 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;
84
import tech.smartboot.servlet.Container;
95
import tech.smartboot.servlet.ServletContextRuntime;
106
import tech.smartboot.servlet.conf.ServletInfo;
117
import tech.smartboot.servlet.conf.ServletMappingInfo;
128

13-
import java.util.concurrent.CompletableFuture;
14-
159
/**
1610
* @author 三刀([email protected]
1711
* @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

Comments
 (0)