Skip to content

Commit 72b0fd6

Browse files
committed
Rename class file names for Struts implementation without version number
#471
1 parent e0074a9 commit 72b0fd6

File tree

22 files changed

+76
-67
lines changed

22 files changed

+76
-67
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
Lines changed: 39 additions & 28 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 {
113124
log.info("Initialize Struts2 Lambda Application ...");
114-
Timer.start(TIMER_STRUTS_2_COLD_START_INIT);
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
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
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

1616
import com.amazonaws.serverless.proxy.internal.testutils.AwsProxyRequestBuilder;
1717
import com.amazonaws.serverless.proxy.internal.testutils.MockLambdaContext;
1818
import com.amazonaws.serverless.proxy.model.AwsProxyRequest;
1919
import com.amazonaws.serverless.proxy.model.AwsProxyResponse;
2020
import com.amazonaws.serverless.proxy.model.HttpApiV2ProxyRequest;
21-
import com.amazonaws.serverless.proxy.struts2.echoapp.EchoAction;
21+
import com.amazonaws.serverless.proxy.struts.echoapp.EchoAction;
2222
import com.amazonaws.services.lambda.runtime.Context;
2323
import com.fasterxml.jackson.core.JsonProcessingException;
2424
import com.fasterxml.jackson.core.type.TypeReference;
@@ -33,7 +33,11 @@
3333
import java.io.IOException;
3434
import java.io.UnsupportedEncodingException;
3535
import java.net.URLDecoder;
36-
import java.util.*;
36+
import java.util.Arrays;
37+
import java.util.Collection;
38+
import java.util.HashMap;
39+
import java.util.Map;
40+
import java.util.UUID;
3741

3842
import static org.junit.Assert.assertEquals;
3943
import static org.junit.Assert.assertNotNull;
@@ -45,7 +49,7 @@
4549
* Unit test class for the Struts2 AWS_PROXY default implementation
4650
*/
4751
@RunWith(Parameterized.class)
48-
public class Struts2AwsProxyTest extends StrutsJUnit4TestCase<EchoAction> {
52+
public class StrutsAwsProxyTest extends StrutsJUnit4TestCase<EchoAction> {
4953
private static final String CUSTOM_HEADER_KEY = "x-custom-header";
5054
private static final String CUSTOM_HEADER_VALUE = "my-custom-value";
5155
private static final String AUTHORIZER_PRINCIPAL_ID = "test-principal-" + UUID.randomUUID().toString();
@@ -56,15 +60,15 @@ public class Struts2AwsProxyTest extends StrutsJUnit4TestCase<EchoAction> {
5660

5761

5862
private static ObjectMapper objectMapper = new ObjectMapper();
59-
private final Struts2LambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> handler = Struts2LambdaContainerHandler
63+
private final StrutsLambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> handler = StrutsLambdaContainerHandler
6064
.getAwsProxyHandler();
61-
private final Struts2LambdaContainerHandler<HttpApiV2ProxyRequest, AwsProxyResponse> httpApiHandler = Struts2LambdaContainerHandler
65+
private final StrutsLambdaContainerHandler<HttpApiV2ProxyRequest, AwsProxyResponse> httpApiHandler = StrutsLambdaContainerHandler
6266
.getHttpApiV2ProxyHandler();
6367
private static Context lambdaContext = new MockLambdaContext();
6468

6569
private String type;
6670

67-
public Struts2AwsProxyTest(String reqType) {
71+
public StrutsAwsProxyTest(String reqType) {
6872
type = reqType;
6973
}
7074

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.amazonaws.serverless.proxy.struts2.echoapp;
1+
package com.amazonaws.serverless.proxy.struts.echoapp;
22

33
import com.opensymphony.xwork2.ActionSupport;
44
import org.apache.commons.io.IOUtils;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.amazonaws.serverless.proxy.struts2.echoapp;
1+
package com.amazonaws.serverless.proxy.struts.echoapp;
22

33
import com.amazonaws.serverless.proxy.RequestReader;
44
import com.amazonaws.serverless.proxy.model.AwsProxyRequestContext;

aws-serverless-java-container-struts/src/test/resources/struts.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
<constant name="struts.action.extension" value=","/>
88

99
<package name="test" extends="json-default" namespace="/">
10-
<action name="echo" class="com.amazonaws.serverless.proxy.struts2.echoapp.EchoAction" method="execute">
10+
<action name="echo" class="com.amazonaws.serverless.proxy.struts.echoapp.EchoAction" method="execute">
1111
<result type="json">
1212
<param name="root">
1313
message
1414
</param>
1515
</result>
1616
</action>
1717

18-
<action name="echo-request-info" class="com.amazonaws.serverless.proxy.struts2.echoapp.EchoRequestInfoAction"
18+
<action name="echo-request-info" class="com.amazonaws.serverless.proxy.struts.echoapp.EchoRequestInfoAction"
1919
method="execute">
2020
<result type="json">
2121
<param name="root">

aws-serverless-struts-archetype/src/main/resources/archetype-resources/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ configurations {
1313

1414
dependencies {
1515

16-
implementation ('com.amazonaws.serverless:aws-serverless-java-container-struts2:[1.0,)') {
16+
implementation ('com.amazonaws.serverless:aws-serverless-java-container-struts:[1.0,)') {
1717
exclude group: 'org.apache.struts', module: 'struts2-core'
1818
exclude group: 'org.apache.logging.log4j', module: 'log4j-api'
1919
exclude group: 'org.apache.logging.log4j', module: 'log4j-to-slf4j'

aws-serverless-struts-archetype/src/main/resources/archetype-resources/pom.xml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<version>\${version}</version>
1010
<packaging>jar</packaging>
1111

12-
<name>Serverless Struts2 API</name>
12+
<name>Serverless Struts API</name>
1313
<url>https://github.com/awslabs/aws-serverless-java-container</url>
1414

1515
<properties>
@@ -24,7 +24,7 @@
2424
<dependencies>
2525
<dependency>
2626
<groupId>com.amazonaws.serverless</groupId>
27-
<artifactId>aws-serverless-java-container-struts2</artifactId>
27+
<artifactId>aws-serverless-java-container-struts</artifactId>
2828
<version>${project.version}</version>
2929
</dependency>
3030

@@ -101,12 +101,6 @@
101101
<version>\${log4j.version}</version>
102102
</dependency>
103103

104-
<dependency>
105-
<groupId>org.apache.logging.log4j</groupId>
106-
<artifactId>log4j-slf4j-impl</artifactId>
107-
<version>\${log4j.version}</version>
108-
</dependency>
109-
110104
<dependency>
111105
<groupId>com.amazonaws</groupId>
112106
<artifactId>aws-lambda-java-log4j2</artifactId>

aws-serverless-struts-archetype/src/main/resources/archetype-resources/src/test/java/StreamLambdaHandlerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import com.amazonaws.serverless.proxy.model.AwsProxyResponse;
88
import com.amazonaws.services.lambda.runtime.Context;
99

10-
import com.amazonaws.serverless.proxy.struts2.Struts2LambdaHandler;
10+
import com.amazonaws.serverless.proxy.struts.StrutsLambdaHandler;
1111

1212
import org.junit.BeforeClass;
1313
import org.junit.Test;
@@ -26,12 +26,12 @@
2626

2727
public class StreamLambdaHandlerTest {
2828

29-
private static Struts2LambdaHandler handler;
29+
private static StrutsLambdaHandler handler;
3030
private static Context lambdaContext;
3131

3232
@BeforeClass
3333
public static void setUp() {
34-
handler = new Struts2LambdaHandler();
34+
handler = new StrutsLambdaHandler();
3535
lambdaContext = new MockLambdaContext();
3636
}
3737

0 commit comments

Comments
 (0)