Skip to content

Commit 434803d

Browse files
authored
upgrade feat (#9562)
* 适配最新版 * 适配最新版 * 适配最新版 * 适配最新版 * 适配最新版 * 适配最新版 * 适配最新版 * 适配最新版
1 parent 83db590 commit 434803d

File tree

6 files changed

+73
-33
lines changed

6 files changed

+73
-33
lines changed

frameworks/Java/smart-socket/benchmark_config.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"framework": "smart-socket",
2+
"framework": "feat",
33
"tests": [
44
{
55
"default": {
@@ -17,9 +17,9 @@
1717
"webserver": "None",
1818
"os": "Linux",
1919
"database_os": "Linux",
20-
"display_name": "smart-socket",
20+
"display_name": "feat",
2121
"notes": "",
22-
"versus": "smart-socket"
22+
"versus": "feat"
2323
},
2424
"smart-servlet": {
2525
"json_url": "/json",

frameworks/Java/smart-socket/smart-socket-smart-servlet.dockerfile renamed to frameworks/Java/smart-socket/feat-smart-servlet.dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ FROM maven:3.9.7-amazoncorretto-21 as maven
22
WORKDIR /smart-socket
33
COPY pom.xml pom.xml
44
COPY src src
5-
RUN mvn compile assembly:single -q
5+
RUN mvn install -q
66

77
FROM openjdk:21-jdk-slim
88
WORKDIR /smart-socket
9-
COPY --from=maven /smart-socket/target/smart-socket-benchmark-1.0-jar-with-dependencies.jar app.jar
9+
COPY --from=maven /smart-socket/target/smart-socket-benchmark-1.0.jar app.jar
1010

1111
EXPOSE 8080
1212

frameworks/Java/smart-socket/smart-socket.dockerfile renamed to frameworks/Java/smart-socket/feat.dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ FROM maven:3.9.7-amazoncorretto-21 as maven
22
WORKDIR /smart-socket
33
COPY pom.xml pom.xml
44
COPY src src
5-
RUN mvn compile assembly:single -q
5+
RUN mvn install -q
66

77
FROM openjdk:21-jdk-slim
88
WORKDIR /smart-socket
9-
COPY --from=maven /smart-socket/target/smart-socket-benchmark-1.0-jar-with-dependencies.jar app.jar
9+
COPY --from=maven /smart-socket/target/smart-socket-benchmark-1.0.jar app.jar
1010

1111
EXPOSE 8080
1212

frameworks/Java/smart-socket/pom.xml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
</properties>
1818

1919
<dependencies>
20+
<dependency>
21+
<groupId>tech.smartboot.feat</groupId>
22+
<artifactId>feat-restful</artifactId>
23+
<version>0.5</version>
24+
</dependency>
2025
<dependency>
2126
<groupId>io.edap</groupId>
2227
<artifactId>edapx-json</artifactId>
@@ -26,6 +31,12 @@
2631
<groupId>tech.smartboot.servlet</groupId>
2732
<artifactId>servlet-core</artifactId>
2833
<version>${smartservlet.version}</version>
34+
<exclusions>
35+
<exclusion>
36+
<groupId>tech.smartboot.feat</groupId>
37+
<artifactId>feat-restful</artifactId>
38+
</exclusion>
39+
</exclusions>
2940
</dependency>
3041
<dependency>
3142
<groupId>com.zaxxer</groupId>
@@ -114,20 +125,24 @@
114125
</plugin>
115126

116127
<plugin>
117-
<artifactId>maven-assembly-plugin</artifactId>
118-
<version>3.1.0</version>
119-
<configuration>
120-
<descriptorRefs>
121-
<descriptorRef>jar-with-dependencies</descriptorRef>
122-
</descriptorRefs>
123-
</configuration>
128+
<artifactId>maven-shade-plugin</artifactId>
129+
<version>3.3.0</version>
124130
<executions>
125131
<execution>
126-
<id>make-assembly</id>
127132
<phase>package</phase>
128133
<goals>
129-
<goal>single</goal>
134+
<goal>shade</goal>
130135
</goals>
136+
<configuration>
137+
<createDependencyReducedPom>false</createDependencyReducedPom>
138+
<transformers>
139+
<!-- 采用追加的方式 -->
140+
<transformer
141+
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
142+
<resource>META-INF/services/tech.smartboot.feat.core.apt.AptLoader</resource>
143+
</transformer>
144+
</transformers>
145+
</configuration>
131146
</execution>
132147
</executions>
133148
</plugin>

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,35 @@
88

99
package org.smartboot.http;
1010

11-
import org.smartboot.Message;
12-
import tech.smartboot.feat.core.Feat;
13-
import tech.smartboot.feat.core.common.enums.HeaderValueEnum;
14-
import tech.smartboot.feat.core.server.HttpHandler;
15-
import tech.smartboot.feat.core.server.HttpRequest;
16-
import tech.smartboot.feat.core.server.HttpResponse;
11+
import tech.smartboot.feat.restful.RestFeat;
1712

1813
public class Bootstrap {
1914
static byte[] body = "Hello, World!".getBytes();
2015

2116
public static void main(String[] args) {
2217
int cpuNum = Runtime.getRuntime().availableProcessors();
2318
// 定义服务器接受的消息类型以及各类消息对应的处理器
24-
Feat.createHttpServer(options -> {
19+
// Feat.createHttpServer(options -> {
20+
// options.threadNum(cpuNum + 1)
21+
// .headerLimiter(0)
22+
// .readBufferSize(1024 * 4)
23+
// .writeBufferSize(1024 * 4);
24+
// }).httpHandler(request -> {
25+
// HttpResponse response = request.getResponse();
26+
// if ("/plaintext".equals(request.getRequestURI())) {
27+
// response.setContentLength(body.length);
28+
// response.setContentType(HeaderValueEnum.ContentType.TEXT_PLAIN_UTF8);
29+
// response.write(body);
30+
// } else if ("/json".equals(request.getRequestURI())) {
31+
// response.setContentType("application/json");
32+
// JsonUtil.writeJsonBytes(response, new Message("Hello, World!"));
33+
// }
34+
// }).listen(8080);
35+
RestFeat.createServer(options -> {
2536
options.threadNum(cpuNum + 1)
2637
.headerLimiter(0)
2738
.readBufferSize(1024 * 4)
2839
.writeBufferSize(1024 * 4);
29-
}).httpHandler(request -> {
30-
HttpResponse response = request.getResponse();
31-
if ("/plaintext".equals(request.getRequestURI())) {
32-
response.setContentLength(body.length);
33-
response.setContentType(HeaderValueEnum.ContentType.TEXT_PLAIN_UTF8);
34-
response.write(body);
35-
} else if ("/json".equals(request.getRequestURI())) {
36-
response.setContentType("application/json");
37-
JsonUtil.writeJsonBytes(response, new Message("Hello, World!"));
38-
}
3940
}).listen(8080);
4041
}
4142

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.smartboot.http;
2+
3+
import org.smartboot.Message;
4+
import tech.smartboot.feat.core.apt.annotation.Controller;
5+
import tech.smartboot.feat.core.apt.annotation.RequestMapping;
6+
import tech.smartboot.feat.core.common.enums.HeaderValueEnum;
7+
import tech.smartboot.feat.core.server.HttpResponse;
8+
9+
@Controller
10+
public class FeatController {
11+
static byte[] body = "Hello, World!".getBytes();
12+
13+
@RequestMapping("/plaintext")
14+
public byte[] plaintext(HttpResponse response) {
15+
response.setContentType(HeaderValueEnum.ContentType.TEXT_PLAIN_UTF8);
16+
return body;
17+
}
18+
19+
@RequestMapping("/json")
20+
public Message json(HttpResponse response) {
21+
response.setContentType(HeaderValueEnum.ContentType.APPLICATION_JSON_UTF8);
22+
return new Message("Hello, World!");
23+
}
24+
}

0 commit comments

Comments
 (0)