Skip to content

Commit 02d4e68

Browse files
committed
chore: update v2 (#1409)
1 parent 4eb0597 commit 02d4e68

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

examples/powertools-examples-core-utilities/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ We also provide an example showing the integration of SAM, Powertools, and Gradl
1515

1616
* [AWS SAM with a Gradle build](gradle/)
1717

18+
We also provide an example showing the integration of SAM, Powertools, and Gradle:
19+
20+
* [AWS SAM with a Gradle build](../powertools-examples-core-utilities/gradle/)
21+
1822
For each of the tools, the example application is the same, and consists of the following files:
1923

2024
- [App.java](sam/src/main/java/helloworld/App.java) - Code for the application's Lambda function.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2023 Amazon.com, Inc. or its affiliates.
3+
* Licensed under the Apache License, Version 2.0 (the
4+
* "License"); you may not use this file except in compliance
5+
* with the License. You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
* limitations under the License.
12+
*
13+
*/
14+
15+
package helloworld;
16+
17+
import com.amazonaws.services.lambda.runtime.Context;
18+
import com.amazonaws.services.lambda.runtime.RequestStreamHandler;
19+
import com.fasterxml.jackson.databind.ObjectMapper;
20+
import java.io.IOException;
21+
import java.io.InputStream;
22+
import java.io.OutputStream;
23+
import java.util.Map;
24+
import software.amazon.lambda.powertools.logging.Logging;
25+
import software.amazon.lambda.powertools.metrics.Metrics;
26+
27+
public class AppStream implements RequestStreamHandler {
28+
private static final ObjectMapper mapper = new ObjectMapper();
29+
30+
@Override
31+
@Logging(logEvent = true)
32+
@Metrics(namespace = "ServerlessAirline", service = "payment", captureColdStart = true)
33+
public void handleRequest(InputStream input, OutputStream output, Context context) throws IOException {
34+
Map map = mapper.readValue(input, Map.class);
35+
36+
System.out.println(map.size());
37+
}
38+
}

0 commit comments

Comments
 (0)