From 8cc839a41d90f6038ff201034051f94aac8d1e20 Mon Sep 17 00:00:00 2001 From: Johannes Geppert Date: Wed, 17 Aug 2022 11:53:00 +0200 Subject: [PATCH 1/5] Add missing Struts Quick start reference https://github.com/awslabs/aws-serverless-java-container/issues/471 --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0e83ba97c..4c0a4c99d 100644 --- a/README.md +++ b/README.md @@ -9,14 +9,16 @@ Follow the quick start guides in [our wiki](https://github.com/awslabs/aws-serve * [Apache Struts quick start](https://github.com/awslabs/aws-serverless-java-container/wiki/Quick-start---Struts) * [Jersey quick start](https://github.com/awslabs/aws-serverless-java-container/wiki/Quick-start---Jersey) * [Spark quick start](https://github.com/awslabs/aws-serverless-java-container/wiki/Quick-start---Spark) +* [Struts quick start](https://github.com/awslabs/aws-serverless-java-container/wiki/Quick-start---Struts) * 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) -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). +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). ```java public class StreamLambdaHandler implements RequestStreamHandler { - private static SpringLambdaContainerHandler handler; + private static final SpringLambdaContainerHandler handler; + static { try { handler = SpringLambdaContainerHandler.getAwsProxyHandler(PetStoreSpringAppConfig.class); From e0074a9c8464185f106ffeb2b1ba8fd6f81b682e Mon Sep 17 00:00:00 2001 From: Johannes Geppert Date: Wed, 17 Aug 2022 11:55:12 +0200 Subject: [PATCH 2/5] Rename maven modules for Struts implementation without version number https://github.com/awslabs/aws-serverless-java-container/issues/471 --- .../pom.xml | 6 +++--- .../proxy/struts2/Struts2LambdaContainerHandler.java | 0 .../serverless/proxy/struts2/Struts2LambdaHandler.java | 0 .../serverless/proxy/struts2/Struts2AwsProxyTest.java | 0 .../serverless/proxy/struts2/echoapp/EchoAction.java | 0 .../proxy/struts2/echoapp/EchoRequestInfoAction.java | 0 .../src/test/resources/struts.xml | 0 .../pom.xml | 2 +- .../main/resources/META-INF/maven/archetype-metadata.xml | 0 .../src/main/resources/archetype-resources/README.md | 0 .../src/main/resources/archetype-resources/build.gradle | 0 .../src/main/resources/archetype-resources/pom.xml | 0 .../archetype-resources/src/main/assembly/dist.xml | 0 .../src/main/java/actions/PingController.java | 0 .../src/main/resources/application.properties | 0 .../archetype-resources/src/main/resources/log4j2.xml | 0 .../archetype-resources/src/main/resources/struts.xml | 0 .../src/test/java/StreamLambdaHandlerTest.java | 0 .../src/main/resources/archetype-resources/template.yml | 0 .../src/test/resources/projects/base/archetype.properties | 0 .../src/test/resources/projects/base/goal.txt | 0 pom.xml | 4 ++-- 22 files changed, 6 insertions(+), 6 deletions(-) rename {aws-serverless-java-container-struts2 => aws-serverless-java-container-struts}/pom.xml (97%) rename {aws-serverless-java-container-struts2 => aws-serverless-java-container-struts}/src/main/java/com/amazonaws/serverless/proxy/struts2/Struts2LambdaContainerHandler.java (100%) rename {aws-serverless-java-container-struts2 => aws-serverless-java-container-struts}/src/main/java/com/amazonaws/serverless/proxy/struts2/Struts2LambdaHandler.java (100%) rename {aws-serverless-java-container-struts2 => aws-serverless-java-container-struts}/src/test/java/com/amazonaws/serverless/proxy/struts2/Struts2AwsProxyTest.java (100%) rename {aws-serverless-java-container-struts2 => aws-serverless-java-container-struts}/src/test/java/com/amazonaws/serverless/proxy/struts2/echoapp/EchoAction.java (100%) rename {aws-serverless-java-container-struts2 => aws-serverless-java-container-struts}/src/test/java/com/amazonaws/serverless/proxy/struts2/echoapp/EchoRequestInfoAction.java (100%) rename {aws-serverless-java-container-struts2 => aws-serverless-java-container-struts}/src/test/resources/struts.xml (100%) rename {aws-serverless-struts2-archetype => aws-serverless-struts-archetype}/pom.xml (97%) rename {aws-serverless-struts2-archetype => aws-serverless-struts-archetype}/src/main/resources/META-INF/maven/archetype-metadata.xml (100%) rename {aws-serverless-struts2-archetype => aws-serverless-struts-archetype}/src/main/resources/archetype-resources/README.md (100%) rename {aws-serverless-struts2-archetype => aws-serverless-struts-archetype}/src/main/resources/archetype-resources/build.gradle (100%) rename {aws-serverless-struts2-archetype => aws-serverless-struts-archetype}/src/main/resources/archetype-resources/pom.xml (100%) rename {aws-serverless-struts2-archetype => aws-serverless-struts-archetype}/src/main/resources/archetype-resources/src/main/assembly/dist.xml (100%) rename {aws-serverless-struts2-archetype => aws-serverless-struts-archetype}/src/main/resources/archetype-resources/src/main/java/actions/PingController.java (100%) rename {aws-serverless-struts2-archetype => aws-serverless-struts-archetype}/src/main/resources/archetype-resources/src/main/resources/application.properties (100%) rename {aws-serverless-struts2-archetype => aws-serverless-struts-archetype}/src/main/resources/archetype-resources/src/main/resources/log4j2.xml (100%) rename {aws-serverless-struts2-archetype => aws-serverless-struts-archetype}/src/main/resources/archetype-resources/src/main/resources/struts.xml (100%) rename {aws-serverless-struts2-archetype => aws-serverless-struts-archetype}/src/main/resources/archetype-resources/src/test/java/StreamLambdaHandlerTest.java (100%) rename {aws-serverless-struts2-archetype => aws-serverless-struts-archetype}/src/main/resources/archetype-resources/template.yml (100%) rename {aws-serverless-struts2-archetype => aws-serverless-struts-archetype}/src/test/resources/projects/base/archetype.properties (100%) rename {aws-serverless-struts2-archetype => aws-serverless-struts-archetype}/src/test/resources/projects/base/goal.txt (100%) diff --git a/aws-serverless-java-container-struts2/pom.xml b/aws-serverless-java-container-struts/pom.xml similarity index 97% rename from aws-serverless-java-container-struts2/pom.xml rename to aws-serverless-java-container-struts/pom.xml index c2ec5923e..943887234 100644 --- a/aws-serverless-java-container-struts2/pom.xml +++ b/aws-serverless-java-container-struts/pom.xml @@ -2,9 +2,9 @@ 4.0.0 - aws-serverless-java-container-struts2 - AWS Serverless Java container support - Struts2 implementation - Allows Java applications written for the Struts2 framework to run in AWS Lambda + aws-serverless-java-container-struts + AWS Serverless Java container support - Struts implementation + Allows Java applications written for the Struts framework to run in AWS Lambda https://aws.amazon.com/lambda 1.9-SNAPSHOT diff --git a/aws-serverless-java-container-struts2/src/main/java/com/amazonaws/serverless/proxy/struts2/Struts2LambdaContainerHandler.java b/aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts2/Struts2LambdaContainerHandler.java similarity index 100% rename from aws-serverless-java-container-struts2/src/main/java/com/amazonaws/serverless/proxy/struts2/Struts2LambdaContainerHandler.java rename to aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts2/Struts2LambdaContainerHandler.java diff --git a/aws-serverless-java-container-struts2/src/main/java/com/amazonaws/serverless/proxy/struts2/Struts2LambdaHandler.java b/aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts2/Struts2LambdaHandler.java similarity index 100% rename from aws-serverless-java-container-struts2/src/main/java/com/amazonaws/serverless/proxy/struts2/Struts2LambdaHandler.java rename to aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts2/Struts2LambdaHandler.java diff --git a/aws-serverless-java-container-struts2/src/test/java/com/amazonaws/serverless/proxy/struts2/Struts2AwsProxyTest.java b/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts2/Struts2AwsProxyTest.java similarity index 100% rename from aws-serverless-java-container-struts2/src/test/java/com/amazonaws/serverless/proxy/struts2/Struts2AwsProxyTest.java rename to aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts2/Struts2AwsProxyTest.java diff --git a/aws-serverless-java-container-struts2/src/test/java/com/amazonaws/serverless/proxy/struts2/echoapp/EchoAction.java b/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts2/echoapp/EchoAction.java similarity index 100% rename from aws-serverless-java-container-struts2/src/test/java/com/amazonaws/serverless/proxy/struts2/echoapp/EchoAction.java rename to aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts2/echoapp/EchoAction.java diff --git a/aws-serverless-java-container-struts2/src/test/java/com/amazonaws/serverless/proxy/struts2/echoapp/EchoRequestInfoAction.java b/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts2/echoapp/EchoRequestInfoAction.java similarity index 100% rename from aws-serverless-java-container-struts2/src/test/java/com/amazonaws/serverless/proxy/struts2/echoapp/EchoRequestInfoAction.java rename to aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts2/echoapp/EchoRequestInfoAction.java diff --git a/aws-serverless-java-container-struts2/src/test/resources/struts.xml b/aws-serverless-java-container-struts/src/test/resources/struts.xml similarity index 100% rename from aws-serverless-java-container-struts2/src/test/resources/struts.xml rename to aws-serverless-java-container-struts/src/test/resources/struts.xml diff --git a/aws-serverless-struts2-archetype/pom.xml b/aws-serverless-struts-archetype/pom.xml similarity index 97% rename from aws-serverless-struts2-archetype/pom.xml rename to aws-serverless-struts-archetype/pom.xml index cb96c077b..9eed00809 100644 --- a/aws-serverless-struts2-archetype/pom.xml +++ b/aws-serverless-struts-archetype/pom.xml @@ -8,7 +8,7 @@ com.amazonaws.serverless.archetypes - aws-serverless-struts2-archetype + aws-serverless-struts-archetype 1.9-SNAPSHOT maven-archetype diff --git a/aws-serverless-struts2-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/aws-serverless-struts-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml similarity index 100% rename from aws-serverless-struts2-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml rename to aws-serverless-struts-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml diff --git a/aws-serverless-struts2-archetype/src/main/resources/archetype-resources/README.md b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/README.md similarity index 100% rename from aws-serverless-struts2-archetype/src/main/resources/archetype-resources/README.md rename to aws-serverless-struts-archetype/src/main/resources/archetype-resources/README.md diff --git a/aws-serverless-struts2-archetype/src/main/resources/archetype-resources/build.gradle b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/build.gradle similarity index 100% rename from aws-serverless-struts2-archetype/src/main/resources/archetype-resources/build.gradle rename to aws-serverless-struts-archetype/src/main/resources/archetype-resources/build.gradle diff --git a/aws-serverless-struts2-archetype/src/main/resources/archetype-resources/pom.xml b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/pom.xml similarity index 100% rename from aws-serverless-struts2-archetype/src/main/resources/archetype-resources/pom.xml rename to aws-serverless-struts-archetype/src/main/resources/archetype-resources/pom.xml diff --git a/aws-serverless-struts2-archetype/src/main/resources/archetype-resources/src/main/assembly/dist.xml b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/assembly/dist.xml similarity index 100% rename from aws-serverless-struts2-archetype/src/main/resources/archetype-resources/src/main/assembly/dist.xml rename to aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/assembly/dist.xml diff --git a/aws-serverless-struts2-archetype/src/main/resources/archetype-resources/src/main/java/actions/PingController.java b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/java/actions/PingController.java similarity index 100% rename from aws-serverless-struts2-archetype/src/main/resources/archetype-resources/src/main/java/actions/PingController.java rename to aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/java/actions/PingController.java diff --git a/aws-serverless-struts2-archetype/src/main/resources/archetype-resources/src/main/resources/application.properties b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/resources/application.properties similarity index 100% rename from aws-serverless-struts2-archetype/src/main/resources/archetype-resources/src/main/resources/application.properties rename to aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/resources/application.properties diff --git a/aws-serverless-struts2-archetype/src/main/resources/archetype-resources/src/main/resources/log4j2.xml b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/resources/log4j2.xml similarity index 100% rename from aws-serverless-struts2-archetype/src/main/resources/archetype-resources/src/main/resources/log4j2.xml rename to aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/resources/log4j2.xml diff --git a/aws-serverless-struts2-archetype/src/main/resources/archetype-resources/src/main/resources/struts.xml b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/resources/struts.xml similarity index 100% rename from aws-serverless-struts2-archetype/src/main/resources/archetype-resources/src/main/resources/struts.xml rename to aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/resources/struts.xml diff --git a/aws-serverless-struts2-archetype/src/main/resources/archetype-resources/src/test/java/StreamLambdaHandlerTest.java b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/test/java/StreamLambdaHandlerTest.java similarity index 100% rename from aws-serverless-struts2-archetype/src/main/resources/archetype-resources/src/test/java/StreamLambdaHandlerTest.java rename to aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/test/java/StreamLambdaHandlerTest.java diff --git a/aws-serverless-struts2-archetype/src/main/resources/archetype-resources/template.yml b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/template.yml similarity index 100% rename from aws-serverless-struts2-archetype/src/main/resources/archetype-resources/template.yml rename to aws-serverless-struts-archetype/src/main/resources/archetype-resources/template.yml diff --git a/aws-serverless-struts2-archetype/src/test/resources/projects/base/archetype.properties b/aws-serverless-struts-archetype/src/test/resources/projects/base/archetype.properties similarity index 100% rename from aws-serverless-struts2-archetype/src/test/resources/projects/base/archetype.properties rename to aws-serverless-struts-archetype/src/test/resources/projects/base/archetype.properties diff --git a/aws-serverless-struts2-archetype/src/test/resources/projects/base/goal.txt b/aws-serverless-struts-archetype/src/test/resources/projects/base/goal.txt similarity index 100% rename from aws-serverless-struts2-archetype/src/test/resources/projects/base/goal.txt rename to aws-serverless-struts-archetype/src/test/resources/projects/base/goal.txt diff --git a/pom.xml b/pom.xml index 87128512a..b752bb127 100644 --- a/pom.xml +++ b/pom.xml @@ -29,9 +29,9 @@ aws-serverless-java-container-jersey aws-serverless-java-container-spark aws-serverless-java-container-spring - aws-serverless-java-container-struts2 + aws-serverless-java-container-struts aws-serverless-java-container-springboot2 - aws-serverless-struts2-archetype + aws-serverless-struts-archetype aws-serverless-jersey-archetype aws-serverless-spark-archetype aws-serverless-spring-archetype From 72b0fd67e54b9d73f30d70c29486b9929c2627b8 Mon Sep 17 00:00:00 2001 From: Johannes Geppert Date: Wed, 17 Aug 2022 12:54:37 +0200 Subject: [PATCH 3/5] Rename class file names for Struts implementation without version number https://github.com/awslabs/aws-serverless-java-container/issues/471 --- .../continuous-integration-workflow.yml | 4 +- .../StrutsLambdaContainerHandler.java} | 67 +++++++++++-------- .../StrutsLambdaHandler.java} | 8 +-- .../StrutsAwsProxyTest.java} | 18 +++-- .../echoapp/EchoAction.java | 2 +- .../echoapp/EchoRequestInfoAction.java | 2 +- .../src/test/resources/struts.xml | 4 +- .../archetype-resources/build.gradle | 2 +- .../resources/archetype-resources/pom.xml | 10 +-- .../test/java/StreamLambdaHandlerTest.java | 6 +- .../archetype-resources/template.yml | 4 +- .../projects/base/archetype.properties | 2 +- .../{struts2 => struts}/pet-store/README.md | 6 +- .../pet-store/build.gradle | 0 samples/{struts2 => struts}/pet-store/pom.xml | 2 +- .../pet-store/src/main/assembly/dist.xml | 0 .../sample/struts/actions/PetsController.java | 0 .../serverless/sample/struts/model/Pet.java | 0 .../sample/struts/model/PetData.java | 0 .../pet-store/src/main/resources/log4j2.xml | 0 .../pet-store/src/main/resources/struts.xml | 0 .../pet-store/template.yml | 6 +- 22 files changed, 76 insertions(+), 67 deletions(-) rename aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/{struts2/Struts2LambdaContainerHandler.java => struts/StrutsLambdaContainerHandler.java} (59%) rename aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/{struts2/Struts2LambdaHandler.java => struts/StrutsLambdaHandler.java} (79%) rename aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/{struts2/Struts2AwsProxyTest.java => struts/StrutsAwsProxyTest.java} (95%) rename aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/{struts2 => struts}/echoapp/EchoAction.java (96%) rename aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/{struts2 => struts}/echoapp/EchoRequestInfoAction.java (98%) rename samples/{struts2 => struts}/pet-store/README.md (91%) rename samples/{struts2 => struts}/pet-store/build.gradle (100%) rename samples/{struts2 => struts}/pet-store/pom.xml (98%) rename samples/{struts2 => struts}/pet-store/src/main/assembly/dist.xml (100%) rename samples/{struts2 => struts}/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/actions/PetsController.java (100%) rename samples/{struts2 => struts}/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/model/Pet.java (100%) rename samples/{struts2 => struts}/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/model/PetData.java (100%) rename samples/{struts2 => struts}/pet-store/src/main/resources/log4j2.xml (100%) rename samples/{struts2 => struts}/pet-store/src/main/resources/struts.xml (100%) rename samples/{struts2 => struts}/pet-store/template.yml (84%) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index 5c55e7b70..e1ae0e00b 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -75,9 +75,9 @@ jobs: 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 build_struts2: - name: Build and test Struts 2 + name: Build and test Struts runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Build latest - run: ./gha_build.sh struts2 true true + run: ./gha_build.sh struts true true diff --git a/aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts2/Struts2LambdaContainerHandler.java b/aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts/StrutsLambdaContainerHandler.java similarity index 59% rename from aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts2/Struts2LambdaContainerHandler.java rename to aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts/StrutsLambdaContainerHandler.java index 99c89c449..42ff0aee8 100644 --- a/aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts2/Struts2LambdaContainerHandler.java +++ b/aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts/StrutsLambdaContainerHandler.java @@ -10,11 +10,22 @@ * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ -package com.amazonaws.serverless.proxy.struts2; +package com.amazonaws.serverless.proxy.struts; import com.amazonaws.serverless.exceptions.ContainerInitializationException; -import com.amazonaws.serverless.proxy.*; -import com.amazonaws.serverless.proxy.internal.servlet.*; +import com.amazonaws.serverless.proxy.AwsHttpApiV2SecurityContextWriter; +import com.amazonaws.serverless.proxy.AwsProxyExceptionHandler; +import com.amazonaws.serverless.proxy.AwsProxySecurityContextWriter; +import com.amazonaws.serverless.proxy.ExceptionHandler; +import com.amazonaws.serverless.proxy.RequestReader; +import com.amazonaws.serverless.proxy.ResponseWriter; +import com.amazonaws.serverless.proxy.SecurityContextWriter; +import com.amazonaws.serverless.proxy.internal.servlet.AwsHttpApiV2HttpServletRequestReader; +import com.amazonaws.serverless.proxy.internal.servlet.AwsHttpServletRequest; +import com.amazonaws.serverless.proxy.internal.servlet.AwsHttpServletResponse; +import com.amazonaws.serverless.proxy.internal.servlet.AwsLambdaServletContainerHandler; +import com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletRequestReader; +import com.amazonaws.serverless.proxy.internal.servlet.AwsProxyHttpServletResponseWriter; import com.amazonaws.serverless.proxy.internal.testutils.Timer; import com.amazonaws.serverless.proxy.model.AwsProxyRequest; import com.amazonaws.serverless.proxy.model.AwsProxyResponse; @@ -32,26 +43,26 @@ import java.util.concurrent.CountDownLatch; /** - * A Lambda handler to initialize the Struts2 filter and proxy the requests. + * A Lambda handler to initialize the Struts filter and proxy the requests. * * @param request type * @param response type */ -public class Struts2LambdaContainerHandler extends AwsLambdaServletContainerHandler { +public class StrutsLambdaContainerHandler extends AwsLambdaServletContainerHandler { - private static final Logger log = LoggerFactory.getLogger(Struts2LambdaContainerHandler.class); + private static final Logger log = LoggerFactory.getLogger(StrutsLambdaContainerHandler.class); public static final String HEADER_STRUTS_STATUS_CODE = "X-Struts-StatusCode"; - private static final String TIMER_STRUTS_2_CONTAINER_CONSTRUCTOR = "STRUTS2_CONTAINER_CONSTRUCTOR"; - private static final String TIMER_STRUTS_2_HANDLE_REQUEST = "STRUTS2_HANDLE_REQUEST"; - private static final String TIMER_STRUTS_2_COLD_START_INIT = "STRUTS2_COLD_START_INIT"; - private static final String STRUTS_FILTER_NAME = "Struts2Filter"; + private static final String TIMER_STRUTS_CONTAINER_CONSTRUCTOR = "STRUTS_CONTAINER_CONSTRUCTOR"; + private static final String TIMER_STRUTS_HANDLE_REQUEST = "STRUTS_HANDLE_REQUEST"; + private static final String TIMER_STRUTS_COLD_START_INIT = "STRUTS_COLD_START_INIT"; + private static final String STRUTS_FILTER_NAME = "StrutsFilter"; private boolean initialized; - public static Struts2LambdaContainerHandler getAwsProxyHandler() { - return new Struts2LambdaContainerHandler( + public static StrutsLambdaContainerHandler getAwsProxyHandler() { + return new StrutsLambdaContainerHandler( AwsProxyRequest.class, AwsProxyResponse.class, new AwsProxyHttpServletRequestReader(), @@ -60,8 +71,8 @@ public static Struts2LambdaContainerHandler g new AwsProxyExceptionHandler()); } - public static Struts2LambdaContainerHandler getHttpApiV2ProxyHandler() { - return new Struts2LambdaContainerHandler( + public static StrutsLambdaContainerHandler getHttpApiV2ProxyHandler() { + return new StrutsLambdaContainerHandler( HttpApiV2ProxyRequest.class, AwsProxyResponse.class, new AwsHttpApiV2HttpServletRequestReader(), @@ -70,17 +81,17 @@ public static Struts2LambdaContainerHandler requestTypeClass, - Class responseTypeClass, - RequestReader requestReader, - ResponseWriter responseWriter, - SecurityContextWriter securityContextWriter, - ExceptionHandler exceptionHandler) { + public StrutsLambdaContainerHandler(Class requestTypeClass, + Class responseTypeClass, + RequestReader requestReader, + ResponseWriter responseWriter, + SecurityContextWriter securityContextWriter, + ExceptionHandler exceptionHandler) { super(requestTypeClass, responseTypeClass, requestReader, responseWriter, securityContextWriter, exceptionHandler); - Timer.start(TIMER_STRUTS_2_CONTAINER_CONSTRUCTOR); + Timer.start(TIMER_STRUTS_CONTAINER_CONSTRUCTOR); this.initialized = false; - Timer.stop(TIMER_STRUTS_2_CONTAINER_CONSTRUCTOR); + Timer.stop(TIMER_STRUTS_CONTAINER_CONSTRUCTOR); } @Override @@ -92,7 +103,7 @@ protected AwsHttpServletResponse getContainerResponse(HttpServletRequest request protected void handleRequest(HttpServletRequest httpServletRequest, AwsHttpServletResponse httpServletResponse, Context lambdaContext) throws Exception { - Timer.start(TIMER_STRUTS_2_HANDLE_REQUEST); + Timer.start(TIMER_STRUTS_HANDLE_REQUEST); if (!this.initialized) { initialize(); } @@ -105,13 +116,13 @@ protected void handleRequest(HttpServletRequest httpServletRequest, if (responseStatusCode != null) { httpServletResponse.setStatus(Integer.parseInt(responseStatusCode)); } - Timer.stop(TIMER_STRUTS_2_HANDLE_REQUEST); + Timer.stop(TIMER_STRUTS_HANDLE_REQUEST); } @Override public void initialize() throws ContainerInitializationException { log.info("Initialize Struts2 Lambda Application ..."); - Timer.start(TIMER_STRUTS_2_COLD_START_INIT); + Timer.start(TIMER_STRUTS_COLD_START_INIT); try { if (this.startupHandler != null) { this.startupHandler.onStartup(this.getServletContext()); @@ -123,12 +134,12 @@ public void initialize() throws ContainerInitializationException { EnumSet.of(DispatcherType.REQUEST, DispatcherType.ASYNC, DispatcherType.INCLUDE, DispatcherType.FORWARD), true, "/*"); } catch (Exception e) { - throw new ContainerInitializationException("Could not initialize Struts2", e); + throw new ContainerInitializationException("Could not initialize Struts container", e); } this.initialized = true; - Timer.stop(TIMER_STRUTS_2_COLD_START_INIT); - log.info("... initialize of Struts2 Lambda Application completed!"); + Timer.stop(TIMER_STRUTS_COLD_START_INIT); + log.info("... initialize of Struts Lambda Application completed!"); } public Servlet getServlet() { diff --git a/aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts2/Struts2LambdaHandler.java b/aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts/StrutsLambdaHandler.java similarity index 79% rename from aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts2/Struts2LambdaHandler.java rename to aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts/StrutsLambdaHandler.java index b4aee76c9..0e1ccfa17 100644 --- a/aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts2/Struts2LambdaHandler.java +++ b/aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts/StrutsLambdaHandler.java @@ -10,7 +10,7 @@ * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ -package com.amazonaws.serverless.proxy.struts2; +package com.amazonaws.serverless.proxy.struts; import com.amazonaws.serverless.proxy.model.AwsProxyRequest; import com.amazonaws.serverless.proxy.model.AwsProxyResponse; @@ -25,12 +25,12 @@ * The lambda handler to handle the requests. *

* - * com.amazonaws.serverless.proxy.struts2.Struts2LambdaHandler::handleRequest + * com.amazonaws.serverless.proxy.struts.StrutsLambdaHandler::handleRequest * */ -public class Struts2LambdaHandler implements RequestStreamHandler { +public class StrutsLambdaHandler implements RequestStreamHandler { - private final Struts2LambdaContainerHandler handler = Struts2LambdaContainerHandler + private final StrutsLambdaContainerHandler handler = StrutsLambdaContainerHandler .getAwsProxyHandler(); @Override diff --git a/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts2/Struts2AwsProxyTest.java b/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/StrutsAwsProxyTest.java similarity index 95% rename from aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts2/Struts2AwsProxyTest.java rename to aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/StrutsAwsProxyTest.java index 60666f4af..b4f9ecf95 100644 --- a/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts2/Struts2AwsProxyTest.java +++ b/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/StrutsAwsProxyTest.java @@ -10,7 +10,7 @@ * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions * and limitations under the License. */ -package com.amazonaws.serverless.proxy.struts2; +package com.amazonaws.serverless.proxy.struts; import com.amazonaws.serverless.proxy.internal.testutils.AwsProxyRequestBuilder; @@ -18,7 +18,7 @@ import com.amazonaws.serverless.proxy.model.AwsProxyRequest; import com.amazonaws.serverless.proxy.model.AwsProxyResponse; import com.amazonaws.serverless.proxy.model.HttpApiV2ProxyRequest; -import com.amazonaws.serverless.proxy.struts2.echoapp.EchoAction; +import com.amazonaws.serverless.proxy.struts.echoapp.EchoAction; import com.amazonaws.services.lambda.runtime.Context; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; @@ -33,7 +33,11 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; -import java.util.*; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -45,7 +49,7 @@ * Unit test class for the Struts2 AWS_PROXY default implementation */ @RunWith(Parameterized.class) -public class Struts2AwsProxyTest extends StrutsJUnit4TestCase { +public class StrutsAwsProxyTest extends StrutsJUnit4TestCase { private static final String CUSTOM_HEADER_KEY = "x-custom-header"; private static final String CUSTOM_HEADER_VALUE = "my-custom-value"; private static final String AUTHORIZER_PRINCIPAL_ID = "test-principal-" + UUID.randomUUID().toString(); @@ -56,15 +60,15 @@ public class Struts2AwsProxyTest extends StrutsJUnit4TestCase { private static ObjectMapper objectMapper = new ObjectMapper(); - private final Struts2LambdaContainerHandler handler = Struts2LambdaContainerHandler + private final StrutsLambdaContainerHandler handler = StrutsLambdaContainerHandler .getAwsProxyHandler(); - private final Struts2LambdaContainerHandler httpApiHandler = Struts2LambdaContainerHandler + private final StrutsLambdaContainerHandler httpApiHandler = StrutsLambdaContainerHandler .getHttpApiV2ProxyHandler(); private static Context lambdaContext = new MockLambdaContext(); private String type; - public Struts2AwsProxyTest(String reqType) { + public StrutsAwsProxyTest(String reqType) { type = reqType; } diff --git a/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts2/echoapp/EchoAction.java b/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/echoapp/EchoAction.java similarity index 96% rename from aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts2/echoapp/EchoAction.java rename to aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/echoapp/EchoAction.java index bfaa0a69f..d64a54eca 100644 --- a/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts2/echoapp/EchoAction.java +++ b/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/echoapp/EchoAction.java @@ -1,4 +1,4 @@ -package com.amazonaws.serverless.proxy.struts2.echoapp; +package com.amazonaws.serverless.proxy.struts.echoapp; import com.opensymphony.xwork2.ActionSupport; import org.apache.commons.io.IOUtils; diff --git a/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts2/echoapp/EchoRequestInfoAction.java b/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/echoapp/EchoRequestInfoAction.java similarity index 98% rename from aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts2/echoapp/EchoRequestInfoAction.java rename to aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/echoapp/EchoRequestInfoAction.java index 1d9c1697e..554156e9d 100644 --- a/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts2/echoapp/EchoRequestInfoAction.java +++ b/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/echoapp/EchoRequestInfoAction.java @@ -1,4 +1,4 @@ -package com.amazonaws.serverless.proxy.struts2.echoapp; +package com.amazonaws.serverless.proxy.struts.echoapp; import com.amazonaws.serverless.proxy.RequestReader; import com.amazonaws.serverless.proxy.model.AwsProxyRequestContext; diff --git a/aws-serverless-java-container-struts/src/test/resources/struts.xml b/aws-serverless-java-container-struts/src/test/resources/struts.xml index 0c5dd8328..92070be83 100644 --- a/aws-serverless-java-container-struts/src/test/resources/struts.xml +++ b/aws-serverless-java-container-struts/src/test/resources/struts.xml @@ -7,7 +7,7 @@ - + message @@ -15,7 +15,7 @@ - diff --git a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/build.gradle b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/build.gradle index a2cb228b8..240979c70 100644 --- a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/build.gradle +++ b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/build.gradle @@ -13,7 +13,7 @@ configurations { dependencies { - implementation ('com.amazonaws.serverless:aws-serverless-java-container-struts2:[1.0,)') { + implementation ('com.amazonaws.serverless:aws-serverless-java-container-struts:[1.0,)') { exclude group: 'org.apache.struts', module: 'struts2-core' exclude group: 'org.apache.logging.log4j', module: 'log4j-api' exclude group: 'org.apache.logging.log4j', module: 'log4j-to-slf4j' diff --git a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/pom.xml b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/pom.xml index 19204eac7..e2957a69e 100644 --- a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/pom.xml +++ b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/pom.xml @@ -9,7 +9,7 @@ \${version} jar - Serverless Struts2 API + Serverless Struts API https://github.com/awslabs/aws-serverless-java-container @@ -24,7 +24,7 @@ com.amazonaws.serverless - aws-serverless-java-container-struts2 + aws-serverless-java-container-struts ${project.version} @@ -101,12 +101,6 @@ \${log4j.version} - - org.apache.logging.log4j - log4j-slf4j-impl - \${log4j.version} - - com.amazonaws aws-lambda-java-log4j2 diff --git a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/test/java/StreamLambdaHandlerTest.java b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/test/java/StreamLambdaHandlerTest.java index f429ce66b..12fc9fc07 100644 --- a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/test/java/StreamLambdaHandlerTest.java +++ b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/test/java/StreamLambdaHandlerTest.java @@ -7,7 +7,7 @@ import com.amazonaws.serverless.proxy.model.AwsProxyResponse; import com.amazonaws.services.lambda.runtime.Context; -import com.amazonaws.serverless.proxy.struts2.Struts2LambdaHandler; +import com.amazonaws.serverless.proxy.struts.StrutsLambdaHandler; import org.junit.BeforeClass; import org.junit.Test; @@ -26,12 +26,12 @@ public class StreamLambdaHandlerTest { - private static Struts2LambdaHandler handler; + private static StrutsLambdaHandler handler; private static Context lambdaContext; @BeforeClass public static void setUp() { - handler = new Struts2LambdaHandler(); + handler = new StrutsLambdaHandler(); lambdaContext = new MockLambdaContext(); } diff --git a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/template.yml b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/template.yml index 2025da620..fe446dedd 100644 --- a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/template.yml +++ b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/template.yml @@ -22,7 +22,7 @@ #set($awsRegion = $awsRegion.replaceAll("\n", "").trim()) AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 -Description: AWS Serverless Apache Struts2 API - ${groupId}::${artifactId} +Description: AWS Serverless Apache Struts API - ${groupId}::${artifactId} Globals: Api: EndpointConfiguration: REGIONAL @@ -31,7 +31,7 @@ Resources: ${resourceName}Function: Type: AWS::Serverless::Function Properties: - Handler: com.amazonaws.serverless.proxy.struts2.Struts2LambdaHandler::handleRequest + Handler: com.amazonaws.serverless.proxy.struts.StrutsLambdaHandler::handleRequest Runtime: java11 CodeUri: . MemorySize: 512 diff --git a/aws-serverless-struts-archetype/src/test/resources/projects/base/archetype.properties b/aws-serverless-struts-archetype/src/test/resources/projects/base/archetype.properties index d731ebe81..80acd0f43 100644 --- a/aws-serverless-struts-archetype/src/test/resources/projects/base/archetype.properties +++ b/aws-serverless-struts-archetype/src/test/resources/projects/base/archetype.properties @@ -1,3 +1,3 @@ groupId=test.service -artifactId=struts2-archetype-test +artifactId=struts-archetype-test version=1.0-SNAPSHOT diff --git a/samples/struts2/pet-store/README.md b/samples/struts/pet-store/README.md similarity index 91% rename from samples/struts2/pet-store/README.md rename to samples/struts/pet-store/README.md index 80ad76b6c..e421ac4e2 100644 --- a/samples/struts2/pet-store/README.md +++ b/samples/struts/pet-store/README.md @@ -1,5 +1,5 @@ -# Serverless Struts2 example -A basic pet store written with the [Apache Struts framework](https://struts.apache.org). The `Struts2LambdaHandler` object provided by the `aws-serverless-java-container-struts2` is the main entry point for Lambda. +# Serverless Struts example +A basic pet store written with the [Apache Struts framework](https://struts.apache.org). The `StrutsLambdaHandler` object provided by the `aws-serverless-java-container-struts` is the main entry point for Lambda. The application can be deployed in an AWS account using the [Serverless Application Model](https://github.com/awslabs/serverless-application-model). The `template.yml` file in the root folder contains the application definition @@ -29,7 +29,7 @@ Once the deployment is completed, the SAM CLI will print out the stack's outputs ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Outputs ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -Key Struts2PetStoreApi +Key StrutsPetStoreApi Description URL for application Value https://n60c1ycwa2.execute-api.eu-central-1.amazonaws.com/pets ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ diff --git a/samples/struts2/pet-store/build.gradle b/samples/struts/pet-store/build.gradle similarity index 100% rename from samples/struts2/pet-store/build.gradle rename to samples/struts/pet-store/build.gradle diff --git a/samples/struts2/pet-store/pom.xml b/samples/struts/pet-store/pom.xml similarity index 98% rename from samples/struts2/pet-store/pom.xml rename to samples/struts/pet-store/pom.xml index 562c8fb8f..4f0a1e8d5 100644 --- a/samples/struts2/pet-store/pom.xml +++ b/samples/struts/pet-store/pom.xml @@ -7,7 +7,7 @@ com.amazonaws.serverless.sample serverless-struts-example 1.0-SNAPSHOT - Struts2 example for the aws-serverless-java-container library + Struts example for the aws-serverless-java-container library Simple pet store written with the Apache Struts framework https://aws.amazon.com/lambda/ diff --git a/samples/struts2/pet-store/src/main/assembly/dist.xml b/samples/struts/pet-store/src/main/assembly/dist.xml similarity index 100% rename from samples/struts2/pet-store/src/main/assembly/dist.xml rename to samples/struts/pet-store/src/main/assembly/dist.xml diff --git a/samples/struts2/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/actions/PetsController.java b/samples/struts/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/actions/PetsController.java similarity index 100% rename from samples/struts2/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/actions/PetsController.java rename to samples/struts/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/actions/PetsController.java diff --git a/samples/struts2/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/model/Pet.java b/samples/struts/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/model/Pet.java similarity index 100% rename from samples/struts2/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/model/Pet.java rename to samples/struts/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/model/Pet.java diff --git a/samples/struts2/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/model/PetData.java b/samples/struts/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/model/PetData.java similarity index 100% rename from samples/struts2/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/model/PetData.java rename to samples/struts/pet-store/src/main/java/com/amazonaws/serverless/sample/struts/model/PetData.java diff --git a/samples/struts2/pet-store/src/main/resources/log4j2.xml b/samples/struts/pet-store/src/main/resources/log4j2.xml similarity index 100% rename from samples/struts2/pet-store/src/main/resources/log4j2.xml rename to samples/struts/pet-store/src/main/resources/log4j2.xml diff --git a/samples/struts2/pet-store/src/main/resources/struts.xml b/samples/struts/pet-store/src/main/resources/struts.xml similarity index 100% rename from samples/struts2/pet-store/src/main/resources/struts.xml rename to samples/struts/pet-store/src/main/resources/struts.xml diff --git a/samples/struts2/pet-store/template.yml b/samples/struts/pet-store/template.yml similarity index 84% rename from samples/struts2/pet-store/template.yml rename to samples/struts/pet-store/template.yml index a3e794e9c..94902ac9f 100644 --- a/samples/struts2/pet-store/template.yml +++ b/samples/struts/pet-store/template.yml @@ -11,7 +11,7 @@ Resources: PetStoreFunction: Type: AWS::Serverless::Function Properties: - Handler: com.amazonaws.serverless.proxy.struts2.Struts2LambdaHandler::handleRequest + Handler: com.amazonaws.serverless.proxy.struts.StrutsLambdaHandler::handleRequest Runtime: java11 CodeUri: . MemorySize: 256 @@ -25,8 +25,8 @@ Resources: PayloadFormatVersion: '1.0' Outputs: - Struts2PetStoreApi: + StrutsPetStoreApi: Description: URL for application Value: !Sub 'https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com/pets' Export: - Name: Struts2PetStoreApi + Name: StrutsPetStoreApi From cd60e6d537a46ec71999d2a0833866238b7651ee Mon Sep 17 00:00:00 2001 From: Johannes Geppert Date: Wed, 17 Aug 2022 13:04:09 +0200 Subject: [PATCH 4/5] Rename maven struts version property for Struts implementation without version number https://github.com/awslabs/aws-serverless-java-container/issues/471 --- aws-serverless-java-container-struts/pom.xml | 8 ++++---- .../src/main/resources/archetype-resources/pom.xml | 10 +++++----- samples/struts/pet-store/pom.xml | 10 +++++----- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/aws-serverless-java-container-struts/pom.xml b/aws-serverless-java-container-struts/pom.xml index 943887234..a30571ca2 100644 --- a/aws-serverless-java-container-struts/pom.xml +++ b/aws-serverless-java-container-struts/pom.xml @@ -15,7 +15,7 @@ - 2.5.30 + 2.5.30 @@ -29,7 +29,7 @@ org.apache.struts struts2-core - ${struts2.version} + ${struts.version} commons-io @@ -40,14 +40,14 @@ org.apache.struts struts2-json-plugin - ${struts2.version} + ${struts.version} test org.apache.struts struts2-junit-plugin - ${struts2.version} + ${struts.version} test diff --git a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/pom.xml b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/pom.xml index e2957a69e..05685d6d3 100644 --- a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/pom.xml +++ b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/pom.xml @@ -15,7 +15,7 @@ 1.8 1.8 - 2.5.30 + 2.5.30 2.13.3 4.13.2 2.17.2 @@ -37,25 +37,25 @@ org.apache.struts struts2-convention-plugin - \${struts2.version} + \${struts.version} org.apache.struts struts2-rest-plugin - \${struts2.version} + \${struts.version} org.apache.struts struts2-bean-validation-plugin - \${struts2.version} + \${struts.version} org.apache.struts struts2-junit-plugin - \${struts2.version} + \${struts.version} test diff --git a/samples/struts/pet-store/pom.xml b/samples/struts/pet-store/pom.xml index 4f0a1e8d5..751fa1a57 100644 --- a/samples/struts/pet-store/pom.xml +++ b/samples/struts/pet-store/pom.xml @@ -26,7 +26,7 @@ 1.8 1.8 - 2.5.30 + 2.5.30 2.13.3 4.13.2 2.17.2 @@ -48,25 +48,25 @@ org.apache.struts struts2-convention-plugin - ${struts2.version} + ${struts.version} org.apache.struts struts2-rest-plugin - ${struts2.version} + ${struts.version} org.apache.struts struts2-bean-validation-plugin - ${struts2.version} + ${struts.version} org.apache.struts struts2-junit-plugin - ${struts2.version} + ${struts.version} test From c6a9a462db7f983d10e3c173a0fb708c69d09223 Mon Sep 17 00:00:00 2001 From: Johannes Geppert Date: Fri, 16 Sep 2022 22:46:13 +0200 Subject: [PATCH 5/5] Use latest available Apache Struts2 GA version 6.0.3 https://github.com/awslabs/aws-serverless-java-container/issues/471 --- aws-serverless-java-container-struts/pom.xml | 2 +- .../struts/StrutsLambdaContainerHandler.java | 2 +- .../proxy/struts/StrutsAwsProxyTest.java | 65 ++++++++++--------- .../src/test/resources/log4j2.xml | 17 +++++ .../archetype-resources/build.gradle | 14 ++-- .../resources/archetype-resources/pom.xml | 20 ++++-- .../src/main/resources/struts.xml | 2 +- samples/struts/pet-store/build.gradle | 12 ++-- samples/struts/pet-store/pom.xml | 6 +- 9 files changed, 85 insertions(+), 55 deletions(-) create mode 100644 aws-serverless-java-container-struts/src/test/resources/log4j2.xml diff --git a/aws-serverless-java-container-struts/pom.xml b/aws-serverless-java-container-struts/pom.xml index a30571ca2..c39bf516d 100644 --- a/aws-serverless-java-container-struts/pom.xml +++ b/aws-serverless-java-container-struts/pom.xml @@ -15,7 +15,7 @@ - 2.5.30 + 6.0.3 diff --git a/aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts/StrutsLambdaContainerHandler.java b/aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts/StrutsLambdaContainerHandler.java index 42ff0aee8..09c460cfa 100644 --- a/aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts/StrutsLambdaContainerHandler.java +++ b/aws-serverless-java-container-struts/src/main/java/com/amazonaws/serverless/proxy/struts/StrutsLambdaContainerHandler.java @@ -121,7 +121,7 @@ protected void handleRequest(HttpServletRequest httpServletRequest, @Override public void initialize() throws ContainerInitializationException { - log.info("Initialize Struts2 Lambda Application ..."); + log.info("Initialize Struts Lambda Application ..."); Timer.start(TIMER_STRUTS_COLD_START_INIT); try { if (this.startupHandler != null) { diff --git a/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/StrutsAwsProxyTest.java b/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/StrutsAwsProxyTest.java index b4f9ecf95..eb890cf5b 100644 --- a/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/StrutsAwsProxyTest.java +++ b/aws-serverless-java-container-struts/src/test/java/com/amazonaws/serverless/proxy/struts/StrutsAwsProxyTest.java @@ -24,7 +24,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.codec.binary.Base64; -import org.apache.struts2.StrutsJUnit4TestCase; +import org.apache.struts2.StrutsRestTestCase; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -49,24 +49,25 @@ * Unit test class for the Struts2 AWS_PROXY default implementation */ @RunWith(Parameterized.class) -public class StrutsAwsProxyTest extends StrutsJUnit4TestCase { +public class StrutsAwsProxyTest extends StrutsRestTestCase { private static final String CUSTOM_HEADER_KEY = "x-custom-header"; private static final String CUSTOM_HEADER_VALUE = "my-custom-value"; private static final String AUTHORIZER_PRINCIPAL_ID = "test-principal-" + UUID.randomUUID().toString(); + private static final String HTTP_METHOD_GET = "GET"; + private static final String QUERY_STRING_MODE = "mode"; private static final String QUERY_STRING_KEY = "message"; private static final String QUERY_STRING_ENCODED_VALUE = "Hello Struts2"; private static final String USER_PRINCIPAL = "user1"; private static final String CONTENT_TYPE_APPLICATION_JSON = "application/json; charset=UTF-8"; - private static ObjectMapper objectMapper = new ObjectMapper(); + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private final StrutsLambdaContainerHandler handler = StrutsLambdaContainerHandler .getAwsProxyHandler(); private final StrutsLambdaContainerHandler httpApiHandler = StrutsLambdaContainerHandler .getHttpApiV2ProxyHandler(); - private static Context lambdaContext = new MockLambdaContext(); - - private String type; + private final Context lambdaContext = new MockLambdaContext(); + private final String type; public StrutsAwsProxyTest(String reqType) { type = reqType; @@ -92,8 +93,8 @@ private AwsProxyResponse executeRequest(AwsProxyRequestBuilder requestBuilder, C @Test public void headers_getHeaders_echo() { - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", "GET") - .queryString("mode", "headers") + AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", HTTP_METHOD_GET) + .queryString(QUERY_STRING_MODE, "headers") .header(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE) .json(); @@ -106,7 +107,7 @@ public void headers_getHeaders_echo() { @Test public void context_servletResponse_setCustomHeader() { - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo", "GET") + AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo", HTTP_METHOD_GET) .queryString("customHeader", "true") .json(); @@ -118,7 +119,7 @@ public void context_servletResponse_setCustomHeader() { @Test public void context_serverInfo_correctContext() { assumeTrue("API_GW".equals(type)); - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo", "GET") + AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo", HTTP_METHOD_GET) .queryString(QUERY_STRING_KEY, "Hello Struts2") .header("Content-Type", "application/json") .queryString("contentType", "true"); @@ -131,8 +132,8 @@ public void context_serverInfo_correctContext() { @Test public void queryString_uriInfo_echo() { - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", "GET") - .queryString("mode", "query-string") + AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", HTTP_METHOD_GET) + .queryString(QUERY_STRING_MODE, "query-string") .queryString(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE) .json(); @@ -146,8 +147,8 @@ public void queryString_uriInfo_echo() { @Test public void requestScheme_valid_expectHttps() { - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", "GET") - .queryString("mode", "scheme") + AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", HTTP_METHOD_GET) + .queryString(QUERY_STRING_MODE, "scheme") .queryString(QUERY_STRING_KEY, QUERY_STRING_ENCODED_VALUE) .json(); @@ -161,8 +162,8 @@ public void requestScheme_valid_expectHttps() { @Test public void authorizer_securityContext_customPrincipalSuccess() { assumeTrue("API_GW".equals(type)); - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", "GET") - .queryString("mode", "principal") + AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", HTTP_METHOD_GET) + .queryString(QUERY_STRING_MODE, "principal") .json() .authorizerPrincipal(AUTHORIZER_PRINCIPAL_ID); @@ -175,7 +176,7 @@ public void authorizer_securityContext_customPrincipalSuccess() { @Test public void errors_unknownRoute_expect404() { - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/unknown", "GET"); + AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/unknown", HTTP_METHOD_GET); AwsProxyResponse output = executeRequest(request, lambdaContext); assertEquals(404, output.getStatusCode()); @@ -184,7 +185,7 @@ public void errors_unknownRoute_expect404() { @Test public void error_contentType_invalidContentType() { AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", "POST") - .queryString("mode", "content-type") + .queryString(QUERY_STRING_MODE, "content-type") .header("Content-Type", "application/octet-stream") .body("asdasdasd"); @@ -195,7 +196,7 @@ public void error_contentType_invalidContentType() { @Test public void error_statusCode_methodNotAllowed() { AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", "POST") - .queryString("mode", "not-allowed") + .queryString(QUERY_STRING_MODE, "not-allowed") .json(); AwsProxyResponse output = executeRequest(request, lambdaContext); @@ -209,7 +210,7 @@ public void responseBody_responseWriter_validBody() throws JsonProcessingExcepti value.put(QUERY_STRING_KEY, CUSTOM_HEADER_VALUE); AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo", "POST") .json() - .body(objectMapper.writeValueAsString(value)); + .body(OBJECT_MAPPER.writeValueAsString(value)); AwsProxyResponse output = executeRequest(request, lambdaContext); assertEquals(200, output.getStatusCode()); @@ -220,8 +221,8 @@ public void responseBody_responseWriter_validBody() throws JsonProcessingExcepti @Test public void statusCode_responseStatusCode_customStatusCode() { - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", "GET") - .queryString("mode", "custom-status-code") + AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", HTTP_METHOD_GET) + .queryString(QUERY_STRING_MODE, "custom-status-code") .queryString("status", "201") .json(); @@ -231,7 +232,7 @@ public void statusCode_responseStatusCode_customStatusCode() { @Test public void base64_binaryResponse_base64Encoding() { - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo", "GET"); + AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo", HTTP_METHOD_GET); AwsProxyResponse response = executeRequest(request, lambdaContext); assertNotNull(response.getBody()); @@ -241,7 +242,7 @@ public void base64_binaryResponse_base64Encoding() { @Test public void exception_mapException_mapToNotImplemented() { AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", "POST") - .queryString("mode", "not-implemented"); + .queryString(QUERY_STRING_MODE, "not-implemented"); AwsProxyResponse response = executeRequest(request, lambdaContext); assertNotNull(response.getBody()); @@ -251,7 +252,7 @@ public void exception_mapException_mapToNotImplemented() { @Test public void stripBasePath_route_shouldRouteCorrectly() { - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/custompath/echo", "GET") + AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/custompath/echo", HTTP_METHOD_GET) .json() .queryString(QUERY_STRING_KEY, "stripped"); handler.stripBasePath("/custompath"); @@ -263,7 +264,7 @@ public void stripBasePath_route_shouldRouteCorrectly() { @Test public void stripBasePath_route_shouldReturn404() { - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/custompath/echo/status-code", "GET") + AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/custompath/echo/status-code", HTTP_METHOD_GET) .json() .queryString("status", "201"); handler.stripBasePath("/custom"); @@ -275,8 +276,8 @@ public void stripBasePath_route_shouldReturn404() { @Test public void securityContext_injectPrincipal_expectPrincipalName() { assumeTrue("API_GW".equals(type)); - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", "GET") - .queryString("mode", "principal") + AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo-request-info", HTTP_METHOD_GET) + .queryString(QUERY_STRING_MODE, "principal") .authorizerPrincipal(USER_PRINCIPAL); AwsProxyResponse resp = executeRequest(request, lambdaContext); @@ -295,7 +296,7 @@ public void queryParam_encoding_expectUnencodedParam() { e.printStackTrace(); fail("Could not decode parameter"); } - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo", "GET").queryString(QUERY_STRING_KEY, decodedParam); + AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo", HTTP_METHOD_GET).queryString(QUERY_STRING_KEY, decodedParam); AwsProxyResponse resp = executeRequest(request, lambdaContext); assertEquals(200, resp.getStatusCode()); @@ -306,7 +307,7 @@ public void queryParam_encoding_expectUnencodedParam() { public void queryParam_encoding_expectEncodedParam() { assumeTrue("API_GW".equals(type)); String paramValue = "p%2Fz%2B3"; - AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo", "GET").queryString(QUERY_STRING_KEY, paramValue); + AwsProxyRequestBuilder request = new AwsProxyRequestBuilder("/echo", HTTP_METHOD_GET).queryString(QUERY_STRING_KEY, paramValue); AwsProxyResponse resp = executeRequest(request, lambdaContext); assertEquals(200, resp.getStatusCode()); @@ -323,7 +324,7 @@ private void validateMapResponseModel(AwsProxyResponse output, String key, Strin TypeReference> typeRef = new TypeReference>() { }; - HashMap response = objectMapper.readValue(output.getBody(), typeRef); + HashMap response = OBJECT_MAPPER.readValue(output.getBody(), typeRef); assertNotNull(response.get(key)); assertEquals(value, response.get(key)); } catch (IOException e) { @@ -335,7 +336,7 @@ private void validateMapResponseModel(AwsProxyResponse output, String key, Strin private void validateSingleValueModel(AwsProxyResponse output, String value) { try { assertNotNull(output.getBody()); - assertEquals(value, objectMapper.readerFor(String.class).readValue(output.getBody())); + assertEquals(value, OBJECT_MAPPER.readerFor(String.class).readValue(output.getBody())); } catch (Exception e) { e.printStackTrace(); fail("Exception while parsing response body: " + e.getMessage()); diff --git a/aws-serverless-java-container-struts/src/test/resources/log4j2.xml b/aws-serverless-java-container-struts/src/test/resources/log4j2.xml new file mode 100644 index 000000000..55ed0d21c --- /dev/null +++ b/aws-serverless-java-container-struts/src/test/resources/log4j2.xml @@ -0,0 +1,17 @@ + + + + + + %d{yyyy-MM-dd HH:mm:ss} %X{AWSRequestId} %-5p %c{1}:%L - %m%n + + + + + + + + + + + \ No newline at end of file diff --git a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/build.gradle b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/build.gradle index 240979c70..b44a7dfa8 100644 --- a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/build.gradle +++ b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/build.gradle @@ -18,22 +18,22 @@ dependencies { exclude group: 'org.apache.logging.log4j', module: 'log4j-api' exclude group: 'org.apache.logging.log4j', module: 'log4j-to-slf4j' } - implementation ('org.apache.struts:struts2-convention-plugin:2.5.30') { + implementation ('org.apache.struts:struts2-convention-plugin:6.0.3') { exclude group: 'org.apache.struts', module: 'struts2-core' } - implementation ('org.apache.struts:struts2-rest-plugin:2.5.30') { + implementation ('org.apache.struts:struts2-rest-plugin:6.0.3') { exclude group: 'org.apache.struts', module: 'struts2-core' } - implementation ('org.apache.struts:struts2-bean-validation-plugin:2.5.30') { + implementation ('org.apache.struts:struts2-bean-validation-plugin:6.0.3') { exclude group: 'org.apache.struts', module: 'struts2-core' } - implementation ('com.jgeppert.struts2:struts2-aws-lambda-support-plugin:1.3.0') { + implementation ('com.jgeppert.struts2:struts2-aws-lambda-support-plugin:1.4.0') { exclude group: 'org.apache.struts', module: 'struts2-core' } - implementation ('org.apache.struts:struts2-core:2.5.30') { + implementation ('org.apache.struts:struts2-core:6.0.3') { exclude group: 'org.apache.logging.log4j', module: 'log4j-api' } - implementation ('org.hibernate:hibernate-validator:5.4.3.Final') + implementation ('org.hibernate:hibernate-validator:6.1.7.Final') implementation ('com.fasterxml.jackson.core:jackson-databind:2.13.3') implementation ('org.apache.logging.log4j:log4j-core:2.17.2') implementation ('org.apache.logging.log4j:log4j-api:2.17.2') @@ -41,7 +41,7 @@ dependencies { implementation ('com.amazonaws:aws-lambda-java-log4j2:1.5.1') testImplementation('junit:junit:4.13.2') - testImplementation('org.apache.struts:struts2-junit-plugin:2.5.30') { + testImplementation('org.apache.struts:struts2-junit-plugin:6.0.3') { exclude group: 'org.apache.struts', module: 'struts2-core' } } diff --git a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/pom.xml b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/pom.xml index 05685d6d3..e9d3b8b40 100644 --- a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/pom.xml +++ b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/pom.xml @@ -15,12 +15,19 @@ 1.8 1.8 - 2.5.30 + 6.0.3 2.13.3 4.13.2 - 2.17.2 + 2.18.0 + + + struts-staging + https://repository.apache.org/content/repositories/staging/ + + + com.amazonaws.serverless @@ -63,14 +70,14 @@ com.jgeppert.struts2 struts2-aws-lambda-support-plugin - 1.3.0 + 1.4.0 org.hibernate hibernate-validator - 5.4.3.Final + 6.1.7.Final @@ -88,6 +95,11 @@ jackson-databind \${jackson.version} + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + \${jackson.version} + org.apache.logging.log4j diff --git a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/resources/struts.xml b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/resources/struts.xml index 5b86eb974..f6975ffd0 100644 --- a/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/resources/struts.xml +++ b/aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/main/resources/struts.xml @@ -24,7 +24,7 @@ + class="org.apache.struts2.rest.handler.JacksonJsonHandler"/> diff --git a/samples/struts/pet-store/build.gradle b/samples/struts/pet-store/build.gradle index 1d734194c..a28ffc6c3 100644 --- a/samples/struts/pet-store/build.gradle +++ b/samples/struts/pet-store/build.gradle @@ -14,12 +14,12 @@ configurations { dependencies { implementation ( 'com.amazonaws.serverless:aws-serverless-java-container-struts2:[1.0,)', - 'org.apache.struts:struts2-convention-plugin:2.5.30', - 'org.apache.struts:struts2-rest-plugin:2.5.30', - 'org.apache.struts:struts2-bean-validation-plugin:2.5.30', - 'org.apache.struts:struts2-junit-plugin:2.5.30', - 'com.jgeppert.struts2:struts2-aws-lambda-support-plugin:1.3.0', - 'org.hibernate:hibernate-validator:5.4.3.Final', + 'org.apache.struts:struts2-convention-plugin:6.0.3', + 'org.apache.struts:struts2-rest-plugin:6.0.3', + 'org.apache.struts:struts2-bean-validation-plugin:6.0.3', + 'org.apache.struts:struts2-junit-plugin:6.0.3', + 'com.jgeppert.struts2:struts2-aws-lambda-support-plugin:1.4.0', + 'org.hibernate:hibernate-validator:6.1.7.Final', 'com.fasterxml.jackson.core:jackson-databind:2.13.3', 'org.apache.logging.log4j:log4j-core:2.17.2', 'org.apache.logging.log4j:log4j-api:2.17.2', diff --git a/samples/struts/pet-store/pom.xml b/samples/struts/pet-store/pom.xml index 751fa1a57..bb307b015 100644 --- a/samples/struts/pet-store/pom.xml +++ b/samples/struts/pet-store/pom.xml @@ -26,7 +26,7 @@ 1.8 1.8 - 2.5.30 + 6.0.3 2.13.3 4.13.2 2.17.2 @@ -74,14 +74,14 @@ com.jgeppert.struts2 struts2-aws-lambda-support-plugin - 1.3.0 + 1.4.0 org.hibernate hibernate-validator - 5.4.3.Final + 6.1.7.Final