Skip to content

Commit d62007f

Browse files
author
Dennis Kieselhorst
authored
Merge pull request #476 from jogep/feature/struts6
Feature/struts6
2 parents 98482d4 + c6a9a46 commit d62007f

File tree

35 files changed

+181
-140
lines changed

35 files changed

+181
-140
lines changed

.github/workflows/continuous-integration-workflow.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ jobs:
7575
run: ./gha_build.sh springboot2 false false -Dspringboot.version=2.5.14 -Dspring.version=5.3.20 -Dspringsecurity.version=5.5.8 -Ddependency-check.skip=true
7676

7777
build_struts2:
78-
name: Build and test Struts 2
78+
name: Build and test Struts
7979
runs-on: ubuntu-latest
8080
steps:
8181
- uses: actions/checkout@v2
8282
- name: Build latest
83-
run: ./gha_build.sh struts2 true true
83+
run: ./gha_build.sh struts true true

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ Follow the quick start guides in [our wiki](https://github.com/awslabs/aws-serve
99
* [Apache Struts quick start](https://github.com/awslabs/aws-serverless-java-container/wiki/Quick-start---Struts)
1010
* [Jersey quick start](https://github.com/awslabs/aws-serverless-java-container/wiki/Quick-start---Jersey)
1111
* [Spark quick start](https://github.com/awslabs/aws-serverless-java-container/wiki/Quick-start---Spark)
12+
* [Struts quick start](https://github.com/awslabs/aws-serverless-java-container/wiki/Quick-start---Struts)
1213

1314
* Micronaut [documentation](https://guides.micronaut.io/micronaut-function-aws-lambda/guide/index.html) and [demo](https://github.com/awslabs/aws-serverless-java-container/tree/master/samples/micronaut/pet-store) (outdated! - needs to be updated to latest Micronaut version)
1415

15-
Below is the most basic AWS Lambda handler example that launches a Spring application. You can also take a look at the [samples](https://github.com/awslabs/aws-serverless-java-container/tree/master/samples) in this repository, our main wiki page includes a [step-by-step guide](https://github.com/awslabs/aws-serverless-java-container/wiki#deploying-the-sample-applications) on how to deploy the various sample applications using Maven and [SAM](https://github.com/awslabs/serverless-application-model).
16+
Below is the most basic AWS Lambda handler example that launches a Spring application. You can also take a look at the [samples](https://github.com/awslabs/aws-serverless-java-container/tree/master/samples) in this repository, our main wiki page includes a [step-by-step guide](https://github.com/awslabs/aws-serverless-java-container/wiki#deploying-the-sample-applications) on how to deploy the various sample applications using Maven and [SAM](https://github.com/awslabs/serverless-application-model).
1617

1718
```java
1819
public class StreamLambdaHandler implements RequestStreamHandler {
19-
private static SpringLambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> handler;
20+
private static final SpringLambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> handler;
21+
2022
static {
2123
try {
2224
handler = SpringLambdaContainerHandler.getAwsProxyHandler(PetStoreSpringAppConfig.class);

aws-serverless-java-container-struts2/pom.xml renamed to aws-serverless-java-container-struts/pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44

5-
<artifactId>aws-serverless-java-container-struts2</artifactId>
6-
<name>AWS Serverless Java container support - Struts2 implementation</name>
7-
<description>Allows Java applications written for the Struts2 framework to run in AWS Lambda</description>
5+
<artifactId>aws-serverless-java-container-struts</artifactId>
6+
<name>AWS Serverless Java container support - Struts implementation</name>
7+
<description>Allows Java applications written for the Struts framework to run in AWS Lambda</description>
88
<url>https://aws.amazon.com/lambda</url>
99
<version>1.9-SNAPSHOT</version>
1010

@@ -15,7 +15,7 @@
1515
</parent>
1616

1717
<properties>
18-
<struts2.version>2.5.30</struts2.version>
18+
<struts.version>6.0.3</struts.version>
1919
</properties>
2020

2121
<dependencies>
@@ -29,7 +29,7 @@
2929
<dependency>
3030
<groupId>org.apache.struts</groupId>
3131
<artifactId>struts2-core</artifactId>
32-
<version>${struts2.version}</version>
32+
<version>${struts.version}</version>
3333
<exclusions>
3434
<exclusion>
3535
<groupId>commons-io</groupId>
@@ -40,14 +40,14 @@
4040
<dependency>
4141
<groupId>org.apache.struts</groupId>
4242
<artifactId>struts2-json-plugin</artifactId>
43-
<version>${struts2.version}</version>
43+
<version>${struts.version}</version>
4444
<scope>test</scope>
4545
</dependency>
4646

4747
<dependency>
4848
<groupId>org.apache.struts</groupId>
4949
<artifactId>struts2-junit-plugin</artifactId>
50-
<version>${struts2.version}</version>
50+
<version>${struts.version}</version>
5151
<scope>test</scope>
5252
</dependency>
5353

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,22 @@
1010
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
1111
* and limitations under the License.
1212
*/
13-
package com.amazonaws.serverless.proxy.struts2;
13+
package com.amazonaws.serverless.proxy.struts;
1414

1515
import com.amazonaws.serverless.exceptions.ContainerInitializationException;
16-
import com.amazonaws.serverless.proxy.*;
17-
import com.amazonaws.serverless.proxy.internal.servlet.*;
16+
import com.amazonaws.serverless.proxy.AwsHttpApiV2SecurityContextWriter;
17+
import com.amazonaws.serverless.proxy.AwsProxyExceptionHandler;
18+
import com.amazonaws.serverless.proxy.AwsProxySecurityContextWriter;
19+
import com.amazonaws.serverless.proxy.ExceptionHandler;
20+
import com.amazonaws.serverless.proxy.RequestReader;
21+
import com.amazonaws.serverless.proxy.ResponseWriter;
22+
import com.amazonaws.serverless.proxy.SecurityContextWriter;
23+
import com.amazonaws.serverless.proxy.internal.servlet.AwsHttpApiV2HttpServletRequestReader;
24+
import com.amazonaws.serverless.proxy.internal.servlet.AwsHttpServletRequest;
25+
import com.amazonaws.serverless.proxy.internal.servlet.AwsHttpServletResponse;
26+
import com.amazonaws.serverless.proxy.internal.servlet.AwsLambdaServletContainerHandler;
27+
import com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletRequestReader;
28+
import com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletResponseWriter;
1829
import com.amazonaws.serverless.proxy.internal.testutils.Timer;
1930
import com.amazonaws.serverless.proxy.model.AwsProxyRequest;
2031
import com.amazonaws.serverless.proxy.model.AwsProxyResponse;
@@ -32,26 +43,26 @@
3243
import java.util.concurrent.CountDownLatch;
3344

3445
/**
35-
* A Lambda handler to initialize the Struts2 filter and proxy the requests.
46+
* A Lambda handler to initialize the Struts filter and proxy the requests.
3647
*
3748
* @param <RequestType> request type
3849
* @param <ResponseType> response type
3950
*/
40-
public class Struts2LambdaContainerHandler<RequestType, ResponseType> extends AwsLambdaServletContainerHandler<RequestType, ResponseType, HttpServletRequest, AwsHttpServletResponse> {
51+
public class StrutsLambdaContainerHandler<RequestType, ResponseType> extends AwsLambdaServletContainerHandler<RequestType, ResponseType, HttpServletRequest, AwsHttpServletResponse> {
4152

42-
private static final Logger log = LoggerFactory.getLogger(Struts2LambdaContainerHandler.class);
53+
private static final Logger log = LoggerFactory.getLogger(StrutsLambdaContainerHandler.class);
4354

4455
public static final String HEADER_STRUTS_STATUS_CODE = "X-Struts-StatusCode";
4556

46-
private static final String TIMER_STRUTS_2_CONTAINER_CONSTRUCTOR = "STRUTS2_CONTAINER_CONSTRUCTOR";
47-
private static final String TIMER_STRUTS_2_HANDLE_REQUEST = "STRUTS2_HANDLE_REQUEST";
48-
private static final String TIMER_STRUTS_2_COLD_START_INIT = "STRUTS2_COLD_START_INIT";
49-
private static final String STRUTS_FILTER_NAME = "Struts2Filter";
57+
private static final String TIMER_STRUTS_CONTAINER_CONSTRUCTOR = "STRUTS_CONTAINER_CONSTRUCTOR";
58+
private static final String TIMER_STRUTS_HANDLE_REQUEST = "STRUTS_HANDLE_REQUEST";
59+
private static final String TIMER_STRUTS_COLD_START_INIT = "STRUTS_COLD_START_INIT";
60+
private static final String STRUTS_FILTER_NAME = "StrutsFilter";
5061

5162
private boolean initialized;
5263

53-
public static Struts2LambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> getAwsProxyHandler() {
54-
return new Struts2LambdaContainerHandler(
64+
public static StrutsLambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> getAwsProxyHandler() {
65+
return new StrutsLambdaContainerHandler(
5566
AwsProxyRequest.class,
5667
AwsProxyResponse.class,
5768
new AwsProxyHttpServletRequestReader(),
@@ -60,8 +71,8 @@ public static Struts2LambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> g
6071
new AwsProxyExceptionHandler());
6172
}
6273

63-
public static Struts2LambdaContainerHandler<HttpApiV2ProxyRequest, AwsProxyResponse> getHttpApiV2ProxyHandler() {
64-
return new Struts2LambdaContainerHandler(
74+
public static StrutsLambdaContainerHandler<HttpApiV2ProxyRequest, AwsProxyResponse> getHttpApiV2ProxyHandler() {
75+
return new StrutsLambdaContainerHandler(
6576
HttpApiV2ProxyRequest.class,
6677
AwsProxyResponse.class,
6778
new AwsHttpApiV2HttpServletRequestReader(),
@@ -70,17 +81,17 @@ public static Struts2LambdaContainerHandler<HttpApiV2ProxyRequest, AwsProxyRespo
7081
new AwsProxyExceptionHandler());
7182
}
7283

73-
public Struts2LambdaContainerHandler(Class<RequestType> requestTypeClass,
74-
Class<ResponseType> responseTypeClass,
75-
RequestReader<RequestType, HttpServletRequest> requestReader,
76-
ResponseWriter<AwsHttpServletResponse, ResponseType> responseWriter,
77-
SecurityContextWriter<RequestType> securityContextWriter,
78-
ExceptionHandler<ResponseType> exceptionHandler) {
84+
public StrutsLambdaContainerHandler(Class<RequestType> requestTypeClass,
85+
Class<ResponseType> responseTypeClass,
86+
RequestReader<RequestType, HttpServletRequest> requestReader,
87+
ResponseWriter<AwsHttpServletResponse, ResponseType> responseWriter,
88+
SecurityContextWriter<RequestType> securityContextWriter,
89+
ExceptionHandler<ResponseType> exceptionHandler) {
7990

8091
super(requestTypeClass, responseTypeClass, requestReader, responseWriter, securityContextWriter, exceptionHandler);
81-
Timer.start(TIMER_STRUTS_2_CONTAINER_CONSTRUCTOR);
92+
Timer.start(TIMER_STRUTS_CONTAINER_CONSTRUCTOR);
8293
this.initialized = false;
83-
Timer.stop(TIMER_STRUTS_2_CONTAINER_CONSTRUCTOR);
94+
Timer.stop(TIMER_STRUTS_CONTAINER_CONSTRUCTOR);
8495
}
8596

8697
@Override
@@ -92,7 +103,7 @@ protected AwsHttpServletResponse getContainerResponse(HttpServletRequest request
92103
protected void handleRequest(HttpServletRequest httpServletRequest,
93104
AwsHttpServletResponse httpServletResponse,
94105
Context lambdaContext) throws Exception {
95-
Timer.start(TIMER_STRUTS_2_HANDLE_REQUEST);
106+
Timer.start(TIMER_STRUTS_HANDLE_REQUEST);
96107
if (!this.initialized) {
97108
initialize();
98109
}
@@ -105,13 +116,13 @@ protected void handleRequest(HttpServletRequest httpServletRequest,
105116
if (responseStatusCode != null) {
106117
httpServletResponse.setStatus(Integer.parseInt(responseStatusCode));
107118
}
108-
Timer.stop(TIMER_STRUTS_2_HANDLE_REQUEST);
119+
Timer.stop(TIMER_STRUTS_HANDLE_REQUEST);
109120
}
110121

111122
@Override
112123
public void initialize() throws ContainerInitializationException {
113-
log.info("Initialize Struts2 Lambda Application ...");
114-
Timer.start(TIMER_STRUTS_2_COLD_START_INIT);
124+
log.info("Initialize Struts Lambda Application ...");
125+
Timer.start(TIMER_STRUTS_COLD_START_INIT);
115126
try {
116127
if (this.startupHandler != null) {
117128
this.startupHandler.onStartup(this.getServletContext());
@@ -123,12 +134,12 @@ public void initialize() throws ContainerInitializationException {
123134
EnumSet.of(DispatcherType.REQUEST, DispatcherType.ASYNC, DispatcherType.INCLUDE, DispatcherType.FORWARD),
124135
true, "/*");
125136
} catch (Exception e) {
126-
throw new ContainerInitializationException("Could not initialize Struts2", e);
137+
throw new ContainerInitializationException("Could not initialize Struts container", e);
127138
}
128139

129140
this.initialized = true;
130-
Timer.stop(TIMER_STRUTS_2_COLD_START_INIT);
131-
log.info("... initialize of Struts2 Lambda Application completed!");
141+
Timer.stop(TIMER_STRUTS_COLD_START_INIT);
142+
log.info("... initialize of Struts Lambda Application completed!");
132143
}
133144

134145
public Servlet getServlet() {
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
1111
* and limitations under the License.
1212
*/
13-
package com.amazonaws.serverless.proxy.struts2;
13+
package com.amazonaws.serverless.proxy.struts;
1414

1515
import com.amazonaws.serverless.proxy.model.AwsProxyRequest;
1616
import com.amazonaws.serverless.proxy.model.AwsProxyResponse;
@@ -25,12 +25,12 @@
2525
* The lambda handler to handle the requests.
2626
* <p>
2727
* <code>
28-
* com.amazonaws.serverless.proxy.struts2.Struts2LambdaHandler::handleRequest
28+
* com.amazonaws.serverless.proxy.struts.StrutsLambdaHandler::handleRequest
2929
* </code>
3030
*/
31-
public class Struts2LambdaHandler implements RequestStreamHandler {
31+
public class StrutsLambdaHandler implements RequestStreamHandler {
3232

33-
private final Struts2LambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> handler = Struts2LambdaContainerHandler
33+
private final StrutsLambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> handler = StrutsLambdaContainerHandler
3434
.getAwsProxyHandler();
3535

3636
@Override

0 commit comments

Comments
 (0)