Skip to content

Commit 410e38b

Browse files
Merge pull request #9668 from smartboot/master
update feat
2 parents 6e4dc0b + 09b1eaf commit 410e38b

File tree

7 files changed

+31
-43
lines changed

7 files changed

+31
-43
lines changed

frameworks/Java/smart-socket/pom.xml

+4-9
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,16 @@
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.8</smartservlet.version>
14+
<smartservlet.version>2.9.1</smartservlet.version>
1515
<hikaricp.version>5.0.0</hikaricp.version>
1616
<jsoniter.version>0.9.23</jsoniter.version>
1717
</properties>
1818

1919
<dependencies>
2020
<dependency>
2121
<groupId>tech.smartboot.feat</groupId>
22-
<artifactId>feat-restful</artifactId>
23-
<version>0.5</version>
24-
</dependency>
25-
<dependency>
26-
<groupId>io.edap</groupId>
27-
<artifactId>edapx-json</artifactId>
28-
<version>0.1-SNAPSHOT</version>
22+
<artifactId>feat-cloud-starter</artifactId>
23+
<version>0.8.2</version>
2924
</dependency>
3025
<dependency>
3126
<groupId>tech.smartboot.servlet</groupId>
@@ -34,7 +29,7 @@
3429
<exclusions>
3530
<exclusion>
3631
<groupId>tech.smartboot.feat</groupId>
37-
<artifactId>feat-restful</artifactId>
32+
<artifactId>feat-core</artifactId>
3833
</exclusion>
3934
</exclusions>
4035
</dependency>

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

+3-20
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,14 @@
88

99
package org.smartboot.http;
1010

11-
import tech.smartboot.feat.restful.RestFeat;
11+
12+
import tech.smartboot.feat.cloud.FeatCloud;
1213

1314
public class Bootstrap {
14-
static byte[] body = "Hello, World!".getBytes();
1515

1616
public static void main(String[] args) {
1717
int cpuNum = Runtime.getRuntime().availableProcessors();
18-
// 定义服务器接受的消息类型以及各类消息对应的处理器
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 -> {
18+
FeatCloud.cloudServer(options -> {
3619
options.threadNum(cpuNum + 1)
3720
.headerLimiter(0)
3821
.readBufferSize(1024 * 4)
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package org.smartboot.http;
22

33
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;
4+
import tech.smartboot.feat.cloud.annotation.Controller;
5+
import tech.smartboot.feat.cloud.annotation.RequestMapping;
6+
import tech.smartboot.feat.core.common.HeaderValue;
77
import tech.smartboot.feat.core.server.HttpResponse;
88

99
@Controller
@@ -12,13 +12,13 @@ public class FeatController {
1212

1313
@RequestMapping("/plaintext")
1414
public byte[] plaintext(HttpResponse response) {
15-
response.setContentType(HeaderValueEnum.ContentType.TEXT_PLAIN_UTF8);
15+
response.setContentType(HeaderValue.ContentType.TEXT_PLAIN_UTF8);
1616
return body;
1717
}
1818

1919
@RequestMapping("/json")
2020
public Message json(HttpResponse response) {
21-
response.setContentType(HeaderValueEnum.ContentType.APPLICATION_JSON_UTF8);
21+
response.setContentType(HeaderValue.ContentType.APPLICATION_JSON_UTF8);
2222
return new Message("Hello, World!");
2323
}
2424
}

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33

44
import tech.smartboot.feat.core.common.utils.NumberUtils;
5+
import tech.smartboot.feat.core.server.HttpHandler;
56
import tech.smartboot.feat.core.server.HttpRequest;
67
import tech.smartboot.feat.core.server.HttpResponse;
7-
import tech.smartboot.feat.core.server.handler.BaseHttpHandler;
88

99
import javax.sql.DataSource;
1010
import java.io.IOException;
@@ -19,7 +19,7 @@
1919
* @author 三刀
2020
* @version V1.0 , 2020/6/16
2121
*/
22-
public class MultipleQueriesHandler extends BaseHttpHandler {
22+
public class MultipleQueriesHandler implements HttpHandler {
2323
private DataSource dataSource;
2424

2525
public MultipleQueriesHandler(DataSource dataSource) {
@@ -59,6 +59,11 @@ public void handle(HttpRequest httpRequest, CompletableFuture<Object> completabl
5959

6060
}
6161

62+
@Override
63+
public void handle(HttpRequest request) throws Throwable {
64+
65+
}
66+
6267
protected int getRandomNumber() {
6368
return 1 + ThreadLocalRandom.current().nextInt(10000);
6469
}

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package org.smartboot.http;
22

33

4+
import tech.smartboot.feat.core.server.HttpHandler;
45
import tech.smartboot.feat.core.server.HttpRequest;
56
import tech.smartboot.feat.core.server.HttpResponse;
6-
import tech.smartboot.feat.core.server.handler.BaseHttpHandler;
77

88
import javax.sql.DataSource;
99
import java.io.IOException;
@@ -18,7 +18,7 @@
1818
* @author 三刀
1919
* @version V1.0 , 2020/6/16
2020
*/
21-
public class SingleQueryHandler extends BaseHttpHandler {
21+
public class SingleQueryHandler implements HttpHandler {
2222
private DataSource dataSource;
2323

2424
public SingleQueryHandler(DataSource dataSource) {
@@ -49,6 +49,11 @@ public void handle(HttpRequest httpRequest, CompletableFuture<Object> completabl
4949

5050
}
5151

52+
@Override
53+
public void handle(HttpRequest request) throws Throwable {
54+
55+
}
56+
5257
protected int getRandomNumber() {
5358
return 1 + ThreadLocalRandom.current().nextInt(10000);
5459
}

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import tech.smartboot.servlet.Container;
55
import tech.smartboot.servlet.ServletContextRuntime;
66
import tech.smartboot.servlet.conf.ServletInfo;
7-
import tech.smartboot.servlet.conf.ServletMappingInfo;
87

98
/**
109
* @author 三刀([email protected]
@@ -13,7 +12,7 @@
1312
public class Bootstrap {
1413

1514
public static void main(String[] args) throws Throwable {
16-
System.setProperty("smart-servlet-spring-boot-starter","true");
15+
System.setProperty("smart-servlet-spring-boot-starter", "true");
1716
Container containerRuntime = new Container();
1817
// plaintext
1918
ServletContextRuntime applicationRuntime = new ServletContextRuntime(null, Thread.currentThread().getContextClassLoader(), "/");
@@ -23,23 +22,24 @@ public static void main(String[] args) throws Throwable {
2322
ServletInfo plainTextServletInfo = new ServletInfo();
2423
plainTextServletInfo.setServletName("plaintext");
2524
plainTextServletInfo.setServletClass(HelloWorldServlet.class.getName());
26-
applicationRuntime.getDeploymentInfo().addServletMapping(new ServletMappingInfo(plainTextServletInfo.getServletName(), "/plaintext"));
25+
plainTextServletInfo.addServletMapping("/plaintext", applicationRuntime);
2726
applicationRuntime.getDeploymentInfo().addServlet(plainTextServletInfo);
2827

2928
// json
3029
ServletInfo jsonServletInfo = new ServletInfo();
3130
jsonServletInfo.setServletName("json");
3231
jsonServletInfo.setServletClass(JsonServlet.class.getName());
32+
jsonServletInfo.addServletMapping("/json", applicationRuntime);
3333
applicationRuntime.getDeploymentInfo().addServlet(jsonServletInfo);
34-
applicationRuntime.getDeploymentInfo().addServletMapping(new ServletMappingInfo(jsonServletInfo.getServletName(), "/json"));
3534
containerRuntime.addRuntime(applicationRuntime);
3635
int cpuNum = Runtime.getRuntime().availableProcessors();
3736
// 定义服务器接受的消息类型以及各类消息对应的处理器
3837
containerRuntime.getConfiguration()
3938
.setThreadNum(cpuNum)
39+
.setHeaderLimiter(0)
4040
.setReadBufferSize(1024 * 4);
4141
containerRuntime.initialize();
4242
containerRuntime.start();
43-
43+
4444
}
4545
}
Binary file not shown.

0 commit comments

Comments
 (0)