Skip to content

Commit 8f95f76

Browse files
author
lluo
committed
更新版本jrouter-servlet 2.0.0, 更新pom.xml.
更新依赖包jrouter至 1.8.8. 完善代码格式、注释及文档。
1 parent aa313f7 commit 8f95f76

24 files changed

+281
-292
lines changed

.gitignore

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,34 @@
1-
/nb-configuration.xml
2-
/target
3-
/jrouter-servlet.iml
4-
/.idea
1+
target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
!**/src/main/**/target/
4+
!**/src/test/**/target/
5+
6+
### STS ###
7+
.apt_generated
8+
.classpath
9+
.factorypath
10+
.project
11+
.settings
12+
.springBeans
13+
.sts4-cache
14+
15+
### IntelliJ IDEA ###
16+
.idea
17+
*.iws
18+
*.iml
19+
*.ipr
20+
21+
### NetBeans ###
22+
nb-configuration.xml
23+
/nbproject/
24+
/nbproject/private/
25+
/nbbuild/
26+
/dist/
27+
/nbdist/
28+
/.nb-gradle/
29+
build/
30+
!**/src/main/**/build/
31+
!**/src/test/**/build/
32+
33+
### VS Code ###
34+
.vscode/

.springjavaformatconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
indentation-style=spaces

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<dependency>
1212
<groupId>net.jrouter</groupId>
1313
<artifactId>jrouter-servlet</artifactId>
14-
<version>1.8.7</version>
14+
<version>1.8.8</version>
1515
</dependency>
1616
```
1717

pom.xml

Lines changed: 13 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,20 @@
55
<parent>
66
<groupId>net.jrouter</groupId>
77
<artifactId>j-parent</artifactId>
8-
<version>1.7</version>
8+
<version>2.0</version>
99
</parent>
1010
<artifactId>jrouter-servlet</artifactId>
1111
<packaging>jar</packaging>
12-
<version>1.8.8-SNAPSHOT</version>
12+
<version>2.0.0</version>
1313
<name>JRouter-servlet</name>
1414
<url>https://github.com/tripluo/jrouter-servlet</url>
1515
<licenses>
1616
<license>
17-
<name>The Apache Software License, Version 2.0</name>
18-
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
19-
<distribution>repo</distribution>
17+
<name>Apache License, Version 2.0</name>
18+
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
2019
</license>
2120
</licenses>
2221
<scm>
23-
<connection>scm:git:git@github.com:tripluo/jrouter-servlet.git</connection>
24-
<developerConnection>scm:git:git@github.com:tripluo/jrouter-servlet.git</developerConnection>
2522
<url>https://github.com/tripluo/jrouter-servlet</url>
2623
</scm>
2724
<developers>
@@ -34,15 +31,19 @@
3431
<description>jrouter for http request mapping also adapted servlet.</description>
3532
<properties>
3633
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
37-
<checkstyle.config.file></checkstyle.config.file>
38-
<pmd.rule.file></pmd.rule.file>
34+
<surefire.argLine>
35+
--add-opens=java.base/java.lang=ALL-UNNAMED
36+
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED
37+
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
38+
--add-opens=java.base/java.util=ALL-UNNAMED
39+
</surefire.argLine>
3940
</properties>
4041
<dependencies>
4142
<!-- jrouter -->
4243
<dependency>
4344
<groupId>net.jrouter</groupId>
4445
<artifactId>jrouter</artifactId>
45-
<version>${project.version}</version>
46+
<version>1.8.8</version>
4647
</dependency>
4748
<!-- logback -->
4849
<dependency>
@@ -59,14 +60,6 @@
5960
<dependency>
6061
<groupId>org.springframework</groupId>
6162
<artifactId>spring-web</artifactId>
62-
<exclusions>
63-
<!--
64-
<exclusion>
65-
<artifactId>commons-logging</artifactId>
66-
<groupId>commons-logging</groupId>
67-
</exclusion>
68-
-->
69-
</exclusions>
7063
<optional>true</optional>
7164
</dependency>
7265
<dependency>
@@ -88,9 +81,8 @@
8881
</dependency>
8982
<!-- servlet/jsp -->
9083
<dependency>
91-
<groupId>javax.servlet</groupId>
92-
<artifactId>javax.servlet-api</artifactId>
93-
<scope>provided</scope>
84+
<groupId>jakarta.servlet</groupId>
85+
<artifactId>jakarta.servlet-api</artifactId>
9486
</dependency>
9587
<!-- spring test -->
9688
<dependency>
@@ -109,32 +101,4 @@
109101
<scope>test</scope>
110102
</dependency>
111103
</dependencies>
112-
<build>
113-
<plugins>
114-
<plugin>
115-
<groupId>org.apache.maven.plugins</groupId>
116-
<artifactId>maven-compiler-plugin</artifactId>
117-
<configuration>
118-
<source>1.8</source>
119-
<target>1.8</target>
120-
<encoding>${project.build.sourceEncoding}</encoding>
121-
<showDeprecation>true</showDeprecation>
122-
</configuration>
123-
</plugin>
124-
<plugin>
125-
<groupId>org.apache.maven.plugins</groupId>
126-
<artifactId>maven-resources-plugin</artifactId>
127-
<configuration>
128-
<encoding>${project.build.sourceEncoding}</encoding>
129-
</configuration>
130-
</plugin>
131-
<!-- jar -->
132-
<plugin>
133-
<groupId>org.apache.maven.plugins</groupId>
134-
<artifactId>maven-jar-plugin</artifactId>
135-
<configuration>
136-
</configuration>
137-
</plugin>
138-
</plugins>
139-
</build>
140104
</project>

src/main/java/net/jrouter/http/netty/HttpActionInvocation.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,26 @@ public interface HttpActionInvocation extends ActionInvocation<String> {
3232

3333
/**
3434
* Gets the HTTP request object.
35-
*
3635
* @return the HTTP request object.
3736
*/
3837
FullHttpRequest getRequest();
3938

4039
/**
4140
* Gets the HTTP response object.
42-
*
4341
* @return the HTTP response object.
4442
*/
4543
FullHttpResponse getResponse();
4644

4745
/**
4846
* Gets the {@code ChannelHandlerContext} object.
49-
*
5047
* @return the {@code ChannelHandlerContext} object.
5148
*/
5249
ChannelHandlerContext getChannelHandlerContext();
5350

5451
/**
5552
* Get Invocation Context Map.
56-
*
5753
* @return the Context Map.
5854
*/
5955
Map<String, Object> getContextMap();
56+
6057
}

src/main/java/net/jrouter/http/netty/HttpServerActionFactory.java

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
import io.netty.channel.ChannelHandlerContext;
2121
import io.netty.handler.codec.http.FullHttpRequest;
2222
import io.netty.handler.codec.http.FullHttpResponse;
23-
import java.lang.reflect.Method;
24-
import java.util.HashMap;
25-
import java.util.Locale;
26-
import java.util.Map;
2723
import net.jrouter.ActionFactory;
2824
import net.jrouter.ActionInvocation;
2925
import net.jrouter.JRouterException;
@@ -32,23 +28,26 @@
3228
import net.jrouter.impl.PathActionFactory;
3329
import net.jrouter.support.ActionInvocationDelegate;
3430

31+
import java.lang.reflect.Method;
32+
import java.util.HashMap;
33+
import java.util.Locale;
34+
import java.util.Map;
35+
3536
/**
3637
* {@code HttpServerActionFactory} invoke Action with Http parameters.
3738
*/
3839
public interface HttpServerActionFactory extends ActionFactory<String> {
3940

4041
/**
41-
* Use this instead of {@link #invokeAction(Object, Object...)} to pass Http parameters.
42-
*
42+
* Use this instead of {@link #invokeAction(Object, Object...)} to pass Http
43+
* parameters.
4344
* @param <T> Generic type.
4445
* @param path Action path.
4546
* @param request FullHttpRequest.
4647
* @param response FullHttpResponse.
4748
* @param context ChannelHandlerContext.
48-
*
4949
* @return Action invoked result.
50-
*
51-
* @throws JRouterException if error occurrs.
50+
* @throws JRouterException if error occurs.
5251
* @see #invokeAction(Object, Object...)
5352
*/
5453
<T> T invokeAction(String path, FullHttpRequest request, FullHttpResponse response, ChannelHandlerContext context)
@@ -57,7 +56,7 @@ <T> T invokeAction(String path, FullHttpRequest request, FullHttpResponse respon
5756
/**
5857
* 提供{@code ServletActionFactory}接口默认实现。覆写{@link #createActionInvocation}方法创建{@code HttpServerActionFactory}接口对象。
5958
*
60-
* @see #createActionInvocation(java.lang.String, java.lang.Object...)
59+
* @see #createActionInvocation
6160
*/
6261
class DefaultHttpActionFactory extends PathActionFactory implements HttpServerActionFactory {
6362

@@ -69,7 +68,6 @@ class DefaultHttpActionFactory extends PathActionFactory implements HttpServerAc
6968

7069
/**
7170
* Constructor.
72-
*
7371
* @param properties Properties
7472
*/
7573
public DefaultHttpActionFactory(Properties properties) {
@@ -79,15 +77,14 @@ public DefaultHttpActionFactory(Properties properties) {
7977

8078
@Override
8179
public <T> T invokeAction(String path, FullHttpRequest request, FullHttpResponse response,
82-
ChannelHandlerContext sc) throws JRouterException {
80+
ChannelHandlerContext sc) throws JRouterException {
8381
// invoke and pass http parameters
8482
return (T) super.invokeAction(actionPathCaseSensitive ? path : path.toLowerCase(Locale.getDefault()),
8583
request, response, sc);
8684
}
8785

8886
/**
8987
* 创建并返回{@link ChannelHandlerContext}接口对象。
90-
*
9188
* @return {@link ChannelHandlerContext}接口对象。
9289
*/
9390
@Override
@@ -98,12 +95,8 @@ protected ActionInvocation<String> createActionInvocation(String path, Object...
9895

9996
// 优先从invokeAction参数中获取Http参数对象,已由invokeAction方法指定参数顺序
10097
if (checkHttpParameters(params)) {
101-
httpInvocation = new DefaultHttpActionInvocation(invocation,
102-
(FullHttpRequest) params[0],
103-
(FullHttpResponse) params[1],
104-
(ChannelHandlerContext) params[2],
105-
new HashMap<>(4)
106-
);
98+
httpInvocation = new DefaultHttpActionInvocation(invocation, (FullHttpRequest) params[0],
99+
(FullHttpResponse) params[1], (ChannelHandlerContext) params[2], new HashMap<>(4));
107100
return httpInvocation;
108101
}
109102
// return ActionInvocation if can't get any http parameters
@@ -112,18 +105,15 @@ protected ActionInvocation<String> createActionInvocation(String path, Object...
112105

113106
/**
114107
* 检测{@link #invokeAction}方法传递过来参数的正确性。
115-
*
116108
* @param params 由{@link #invokeAction}方法传递过来参数。
117-
*
118109
* @return 参数是否为正确的Http参数对象。
119110
*
120-
* @see #invokeAction(String, FullHttpRequest, FullHttpResponse, ChannelHandlerContext)
111+
* @see #invokeAction(String, FullHttpRequest,
112+
* FullHttpResponse,ChannelHandlerContext)
121113
*/
122114
private boolean checkHttpParameters(Object... params) {
123-
return params != null && params.length == 3
124-
&& (params[0] instanceof FullHttpRequest)
125-
&& (params[1] instanceof FullHttpResponse)
126-
&& (params[2] instanceof ChannelHandlerContext);
115+
return params != null && params.length == 3 && (params[0] instanceof FullHttpRequest)
116+
&& (params[1] instanceof FullHttpResponse) && (params[2] instanceof ChannelHandlerContext);
127117
}
128118

129119
/**
@@ -153,7 +143,9 @@ protected String buildActionPath(String namespace, String aname, Method method)
153143
}
154144
super.afterPropertiesSet();
155145
}
146+
156147
}
148+
157149
}
158150

159151
/**
@@ -182,8 +174,10 @@ class DefaultHttpActionInvocation extends ActionInvocationDelegate<String> imple
182174
*/
183175
private final Map<String, Object> contextMap;
184176

185-
public DefaultHttpActionInvocation(ActionInvocation<String> invocation, FullHttpRequest request, //NOPMD ExcessiveParameterList
186-
FullHttpResponse response, ChannelHandlerContext channelHandlerContext, Map<String, Object> contextMap) {
177+
public DefaultHttpActionInvocation(ActionInvocation<String> invocation, FullHttpRequest request, // NOPMD
178+
// ExcessiveParameterList
179+
FullHttpResponse response, ChannelHandlerContext channelHandlerContext,
180+
Map<String, Object> contextMap) {
187181
super();
188182
this.delegate = invocation;
189183
this.request = request;
@@ -212,6 +206,7 @@ public ChannelHandlerContext getChannelHandlerContext() {
212206
public Map<String, Object> getContextMap() {
213207
return contextMap;
214208
}
209+
215210
}
216211

217212
}

0 commit comments

Comments
 (0)