Skip to content

Commit ac2da77

Browse files
Feature2.4.7 (#277)
* added afterService() into HttpLifecycleListener, called after sending response to client, before starting logging * added afterService() into HttpLifecycleListener, called after sending response to client, before starting logging * release 2.4.7
1 parent b421e4e commit ac2da77

File tree

6 files changed

+40
-15
lines changed

6 files changed

+40
-15
lines changed

pom.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>org.summerboot</groupId>
66
<artifactId>jexpress</artifactId>
7-
<version>2.4.6</version>
7+
<version>2.4.7</version>
88
<packaging>jar</packaging>
99
<name>Summer Boot jExpress</name>
1010
<description>Summer Boot jExpress focuses on solving non-functional and operational maintainability requirements,
@@ -181,7 +181,7 @@
181181
<maven-surefire.version>3.2.5</maven-surefire.version>
182182
<!-- Commons -->
183183
<commons-lang3.version>3.14.0</commons-lang3.version>
184-
<commons-cli.version>1.7.0</commons-cli.version>
184+
<commons-cli.version>1.8.0</commons-cli.version>
185185
<commons-io.version>2.16.1</commons-io.version>
186186
<!-- <commons-text.version>1.11.0</commons-text.version>-->
187187
<!-- <owasp.encoder.version>1.2.3</owasp.encoder.version>-->
@@ -196,14 +196,14 @@
196196
<jwt.version>0.11.5</jwt.version>
197197

198198
<!-- NIO Netty -->
199-
<netty.version>4.1.109.Final</netty.version>
199+
<netty.version>4.1.110.Final</netty.version>
200200
<netty-tcnative.version>2.0.65.Final</netty-tcnative.version>
201201
<!-- gRPC and protobuf -->
202-
<grpc.version>1.63.0</grpc.version>
202+
<grpc.version>1.64.0</grpc.version>
203203
<guava.version>33.2.0-jre</guava.version>
204-
<protobuf.version>4.26.1</protobuf.version>
204+
<protobuf.version>4.27.0</protobuf.version>
205205
<!-- Web JAX-RS -->
206-
<swagger.core.version>2.2.21</swagger.core.version>
206+
<swagger.core.version>2.2.22</swagger.core.version>
207207
<!--<elastic-apm.version>1.36.0</elastic-apm.version>-->
208208

209209

@@ -224,11 +224,11 @@
224224
<guice.version>7.0.0</guice.version>
225225

226226
<!-- JPA -->
227-
<hibernate.version>6.5.0.Final</hibernate.version>
227+
<hibernate.version>6.5.2.Final</hibernate.version>
228228
<hikari-cp.version>5.1.0</hikari-cp.version>
229229

230230
<!-- Cache -->
231-
<jedis.version>5.1.2</jedis.version>
231+
<jedis.version>5.1.3</jedis.version>
232232

233233
<quartz.version>2.5.0-rc1</quartz.version>
234234
<mqtt.version>1.2.5</mqtt.version>
@@ -338,13 +338,13 @@
338338

339339

340340
<!-- Security -->
341-
<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk18on BouncyCastle-->
341+
<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcpkix-jdk18on -->
342342
<dependency>
343343
<groupId>org.bouncycastle</groupId>
344344
<artifactId>bcpkix-jdk18on</artifactId>
345345
<version>${bouncycastle.version}</version>
346346
</dependency>
347-
<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk18on BouncyCastle
347+
<!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk18on
348348
<dependency>
349349
<groupId>org.bouncycastle</groupId>
350350
<artifactId>bcprov-jdk18on</artifactId>

src/main/java/org/summerboot/jexpress/boot/BootConstant.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public interface BootConstant {
2525
String APP_ID = String.format("%06d", new Random().nextInt(999999));
2626

2727
//version
28-
String VERSION = "SummerBoot.jExpress 2.4.6";
28+
String VERSION = "SummerBoot.jExpress 2.4.7";
2929
String JEXPRESS_PACKAGE_NAME = "org.summerboot.jexpress";
3030

3131
String DEFAULT_ADMIN_MM = "changeit";

src/main/java/org/summerboot/jexpress/boot/event/HttpLifecycleHandler.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ public void afterProcess(RequestProcessor processor, ChannelHandlerContext ctx,
5353
// }
5454
}
5555

56+
@Override
57+
public void afterService(HttpHeaders httpHeaders, HttpMethod httpMethod, String httpRequestPath, Map<String, List<String>> queryParams, String httpPostRequestBody, ServiceContext context) {
58+
}
59+
5660
@Override
5761
public String beforeSendingError(String errorContent) {
5862
//return FormatterUtil.protectContent(errorContent, "UnknownHostException", ":", null, " ***");

src/main/java/org/summerboot/jexpress/boot/event/HttpLifecycleListener.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public interface HttpLifecycleListener {
4747
boolean beofreProcess(RequestProcessor processor, HttpHeaders httpRequestHeaders, String httpRequestPath, ServiceContext context) throws Exception;
4848

4949
/**
50-
* step1
50+
* step1 - after process is done, before sending response to client
5151
*
5252
* @param processor
5353
* @param ctx
@@ -61,16 +61,29 @@ public interface HttpLifecycleListener {
6161
void afterProcess(RequestProcessor processor, ChannelHandlerContext ctx, HttpHeaders httpRequestHeaders, HttpMethod httptMethod, String httpRequestPath,
6262
Map<String, List<String>> queryParams, String httpPostRequestBody, ServiceContext context);
6363

64+
6465
/**
65-
* step2
66+
* step2 - after sending response to client, before starting logging
67+
*
68+
* @param httpHeaders
69+
* @param httpMethod
70+
* @param httpRequestPath
71+
* @param queryParams
72+
* @param httpPostRequestBody
73+
* @param context
74+
*/
75+
void afterService(HttpHeaders httpHeaders, HttpMethod httpMethod, String httpRequestPath, Map<String, List<String>> queryParams, String httpPostRequestBody, ServiceContext context);
76+
77+
/**
78+
* step3
6679
*
6780
* @param errorContent
6881
* @return
6982
*/
7083
String beforeSendingError(String errorContent);
7184

7285
/**
73-
* step3
86+
* step4
7487
*
7588
* @param originallLogContent
7689
* @param httpHeaders
@@ -89,7 +102,7 @@ String beforeLogging(final String originallLogContent, final HttpHeaders httpHea
89102
final ServiceContext context, long queuingTime, long processTime, long responseTime, long responseContentLength, Throwable ioEx);
90103

91104
/**
92-
* step4
105+
* step5
93106
*
94107
* @param logContent
95108
* @param httpHeaders

src/main/java/org/summerboot/jexpress/nio/server/BootHttpRequestHandler.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ protected ProcessorSettings service(final ChannelHandlerContext ctx, final HttpH
146146
return processorSettings;
147147
}
148148

149+
@Override
150+
protected void afterService(HttpHeaders httpHeaders, HttpMethod httpMethod, String httpRequestPath, Map<String, List<String>> queryParams, String httpPostRequestBody, ServiceContext context) {
151+
httpLifecycleListener.afterService(httpHeaders, httpMethod, httpRequestPath, queryParams, httpPostRequestBody, context);
152+
}
153+
149154
/**
150155
* create User object based on token in the header, then set User object to
151156
* context

src/main/java/org/summerboot/jexpress/nio/server/NioServerHttpRequestHandler.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ public void channelRead0(final ChannelHandlerContext ctx, final FullHttpRequest
169169
} finally {
170170
NioCounter.COUNTER_SENT.incrementAndGet();
171171
long responseTime = System.currentTimeMillis() - start;
172+
this.afterService(requestHeaders, httpMethod, httpRequestUri, queryStringDecoder.parameters(), httpPostRequestBody, context);
172173
String report = null;
173174
try {
174175
boolean overtime = responseTime > nioCfg.getBizTimeoutWarnThresholdMs();
@@ -419,6 +420,8 @@ protected void verboseClientServerCommunication(NioConfig cfg, HttpHeaders httpH
419420

420421
abstract protected ProcessorSettings service(final ChannelHandlerContext ctx, final HttpHeaders httpHeaders, final HttpMethod httpMethod, final String httpRequestPath, final Map<String, List<String>> queryParams, final String httpPostRequestBody, final ServiceContext context);
421422

423+
abstract protected void afterService(final HttpHeaders httpHeaders, final HttpMethod httpMethod, final String httpRequestPath, final Map<String, List<String>> queryParams, final String httpPostRequestBody, final ServiceContext context);
424+
422425
abstract protected String beforeLogging(final String originallLogContent, final HttpHeaders httpHeaders, final HttpMethod httpMethod, final String httpRequestUri, final String httpPostRequestBody,
423426
final ServiceContext context, long queuingTime, long processTime, long responseTime, long responseContentLength, Throwable ioEx) throws Exception;
424427

0 commit comments

Comments
 (0)