Skip to content

Commit 11e1280

Browse files
committed
Fixes to struts2 implementation and archetype
1 parent 31a53c3 commit 11e1280

File tree

7 files changed

+22
-39
lines changed

7 files changed

+22
-39
lines changed

aws-serverless-java-container-struts2/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<properties>
1919
<struts2.version>2.5.18</struts2.version>
20-
<jackson.version>2.9.5</jackson.version>
20+
<jackson.version>2.9.7</jackson.version>
2121
</properties>
2222

2323
<dependencies>

aws-serverless-java-container-struts2/src/main/java/com/amazonaws/serverless/proxy/struts2/Struts2LambdaHandler.java

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,8 @@ public class Struts2LambdaHandler implements RequestStreamHandler {
2727
.getAwsProxyHandler();
2828

2929
@Override
30-
public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context) {
31-
32-
try {
33-
AwsProxyRequest request = LambdaContainerHandler.getObjectMapper()
34-
.readValue(inputStream, AwsProxyRequest.class);
35-
36-
AwsProxyResponse response = handler.proxy(request, context);
37-
LambdaContainerHandler.getObjectMapper().writeValue(outputStream, response);
38-
39-
// just in case it wasn't closed by the mapper
40-
outputStream.close();
41-
} catch (IOException e) {
42-
log.error("An unexpected exception happened while handling request", e);
43-
}
30+
public void handleRequest(InputStream inputStream, OutputStream outputStream, Context context)
31+
throws IOException {
32+
handler.proxyStream(inputStream, outputStream, context);
4433
}
4534
}

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

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,14 @@
99
<version>${version}</version>
1010
<packaging>jar</packaging>
1111

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

15-
<parent>
16-
<groupId>org.springframework.boot</groupId>
17-
<artifactId>spring-boot-starter-parent</artifactId>
18-
<version>1.5.10.RELEASE</version>
19-
</parent>
20-
2115
<properties>
2216
<maven.compiler.source>1.8</maven.compiler.source>
2317
<maven.compiler.target>1.8</maven.compiler.target>
2418
<struts2.version>2.5.17</struts2.version>
25-
<jackson.version>2.9.5</jackson.version>
19+
<jackson.version>2.9.7</jackson.version>
2620
<junit.version>4.12</junit.version>
2721
<log4j.version>2.8.2</log4j.version>
2822
</properties>
@@ -31,7 +25,7 @@
3125
<dependency>
3226
<groupId>com.amazonaws.serverless</groupId>
3327
<artifactId>aws-serverless-java-container-struts2</artifactId>
34-
<version>1.2.0</version>
28+
<version>1.2</version>
3529
</dependency>
3630

3731
<dependency>
@@ -82,17 +76,17 @@
8276
<dependency>
8377
<groupId>com.fasterxml.jackson.core</groupId>
8478
<artifactId>jackson-core</artifactId>
85-
<version>2.9.4</version>
79+
<version>${jackson.version}</version>
8680
</dependency>
8781
<dependency>
8882
<groupId>com.fasterxml.jackson.core</groupId>
8983
<artifactId>jackson-annotations</artifactId>
90-
<version>2.9.4</version>
84+
<version>${jackson.version}</version>
9185
</dependency>
9286
<dependency>
9387
<groupId>com.fasterxml.jackson.core</groupId>
9488
<artifactId>jackson-databind</artifactId>
95-
<version>2.9.4</version>
89+
<version>${jackson.version}</version>
9690
</dependency>
9791

9892
<dependency>

aws-serverless-struts2-archetype/src/main/resources/archetype-resources/sam.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
AWSTemplateFormatVersion: '2010-09-09'
2424
Transform: AWS::Serverless-2016-10-31
2525
Description: AWS Serverless Apache Struts2 API - ${groupId}::${artifactId}
26+
Globals:
27+
Api:
28+
EndpointConfiguration: REGIONAL
29+
2630
Resources:
2731
${resourceName}Function:
2832
Type: AWS::Serverless::Function

aws-serverless-struts2-archetype/src/main/resources/archetype-resources/src/main/java/actions/PingController.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package ${groupId}.controller;
1+
package ${groupId}.actions;
22

33

44
import com.opensymphony.xwork2.ModelDriven;
@@ -32,13 +32,9 @@ public HttpHeaders index() {
3232

3333
// POST /ping
3434
public HttpHeaders create() {
35-
if (model.getName() == null || model.getBreed() == null) {
36-
return null;
37-
}
38-
3935
this.model = UUID.randomUUID().toString();
4036
return new DefaultHttpHeaders("success")
41-
.setLocationId(model.getId());
37+
.setLocationId(model);
4238

4339
}
4440

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<!-- Define the package name where *Controller classes will be resolved in this case e.g. actions.PingController could also be com.your.company.actions.PingController -->
1717
<constant name="struts.convention.package.locators" value="actions"/>
1818
<constant name="struts.convention.action.mapAllMatches" value="true"/>
19-
<constant name="struts.convention.default.parent.package" value="pets"/>
19+
<constant name="struts.convention.default.parent.package" value="ping"/>
2020
<constant name="struts.action.extension" value=",,xml,json,action"/>
2121
<constant name="struts.rest.defaultExtension" value="json"/>
2222

@@ -39,7 +39,7 @@
3939
<!-- Set encoding to UTF-8, default is ISO-8859-1 -->
4040
<constant name="struts.i18n.encoding" value="UTF-8"/>
4141

42-
<package name="pets" extends="struts-lambda-support" namespace="/">
42+
<package name="ping" extends="struts-lambda-support" namespace="/">
4343
</package>
4444

4545
</struts>

samples/struts/pet-store/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<maven.compiler.source>1.8</maven.compiler.source>
2828
<maven.compiler.target>1.8</maven.compiler.target>
2929
<struts2.version>2.5.17</struts2.version>
30-
<jackson.version>2.9.5</jackson.version>
30+
<jackson.version>2.9.7</jackson.version>
3131
<junit.version>4.12</junit.version>
3232
<log4j.version>2.8.2</log4j.version>
3333
</properties>
@@ -87,17 +87,17 @@
8787
<dependency>
8888
<groupId>com.fasterxml.jackson.core</groupId>
8989
<artifactId>jackson-core</artifactId>
90-
<version>2.9.4</version>
90+
<version>${jackson.version}</version>
9191
</dependency>
9292
<dependency>
9393
<groupId>com.fasterxml.jackson.core</groupId>
9494
<artifactId>jackson-annotations</artifactId>
95-
<version>2.9.4</version>
95+
<version>${jackson.version}</version>
9696
</dependency>
9797
<dependency>
9898
<groupId>com.fasterxml.jackson.core</groupId>
9999
<artifactId>jackson-databind</artifactId>
100-
<version>2.9.4</version>
100+
<version>${jackson.version}</version>
101101
</dependency>
102102

103103
<dependency>

0 commit comments

Comments
 (0)