File tree Expand file tree Collapse file tree 6 files changed +182
-0
lines changed Expand file tree Collapse file tree 6 files changed +182
-0
lines changed Original file line number Diff line number Diff line change 1+ <project xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
2+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" >
3+ <modelVersion >4.0.0</modelVersion >
4+ <groupId >com.example</groupId >
5+ <artifactId >layer-java-function</artifactId >
6+ <packaging >jar</packaging >
7+ <version >1.0-SNAPSHOT</version >
8+ <name >layer-java-function</name >
9+
10+ <properties >
11+ <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
12+ <maven .compiler.source>21</maven .compiler.source>
13+ <maven .compiler.target>21</maven .compiler.target>
14+ </properties >
15+
16+ <dependencies >
17+ <dependency >
18+ <groupId >com.example</groupId >
19+ <artifactId >layer-java-layer</artifactId >
20+ <version >1.0-SNAPSHOT</version >
21+ <scope >provided</scope >
22+ </dependency >
23+ </dependencies >
24+
25+ <build >
26+ <plugins >
27+ <plugin >
28+ <groupId >org.apache.maven.plugins</groupId >
29+ <artifactId >maven-compiler-plugin</artifactId >
30+ <version >3.13.0</version >
31+ <configuration >
32+ <source >21</source >
33+ <target >21</target >
34+ <release >21</release >
35+ </configuration >
36+ </plugin >
37+ <!-- Use the maven-shade-plugin if you need additional dependencies for
38+ your function that aren't covered by the shared layer.
39+ <plugin>
40+ <groupId>org.apache.maven.plugins</groupId>
41+ <artifactId>maven-shade-plugin</artifactId>
42+ <version>3.5.2</version>
43+ <configuration>
44+ <createDependencyReducedPom>false</createDependencyReducedPom>
45+ </configuration>
46+ <executions>
47+ <execution>
48+ <phase>package</phase>
49+ <goals>
50+ <goal>shade</goal>
51+ </goals>
52+ </execution>
53+ </executions>
54+ </plugin>
55+ -->
56+ </plugins >
57+ </build >
58+
59+ </project >
Original file line number Diff line number Diff line change 1+ package example ;
2+
3+ import com .fasterxml .jackson .annotation .JsonCreator ;
4+ import com .fasterxml .jackson .annotation .JsonProperty ;
5+
6+ public class F1Car {
7+
8+ private String team ;
9+ private String driver ;
10+
11+ @ JsonCreator
12+ public F1Car (@ JsonProperty ("team" ) String team ,
13+ @ JsonProperty ("driver" ) String driver ) {
14+ this .team = team ;
15+ this .driver = driver ;
16+ }
17+
18+ public String getTeam () {
19+ return team ;
20+ }
21+
22+ public void setTeam (String team ) {
23+ this .team = team ;
24+ }
25+
26+ public String getDriver () {
27+ return driver ;
28+ }
29+
30+ public void setDriver (String driver ) {
31+ this .driver = driver ;
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ package example ;
2+
3+ import com .amazonaws .services .lambda .runtime .Context ;
4+ import com .fasterxml .jackson .databind .ObjectMapper ;
5+
6+ import java .io .IOException ;
7+ import java .util .Map ;
8+
9+ public class Handler {
10+
11+ public String handleRequest (Map <String , String > input , Context context ) throws IOException {
12+ // Parse the input JSON
13+ System .out .println (input );
14+ ObjectMapper objectMapper = new ObjectMapper ();
15+ F1Car f1Car = objectMapper .readValue (objectMapper .writeValueAsString (input ), F1Car .class );
16+
17+ StringBuilder finalString = new StringBuilder ();
18+ finalString .append (f1Car .getDriver ());
19+ finalString .append (" is a driver for team " );
20+ finalString .append (f1Car .getTeam ());
21+ return finalString .toString ();
22+ }
23+ }
Original file line number Diff line number Diff line change 1+ mvn clean install
Original file line number Diff line number Diff line change 1+ mkdir java
2+ mkdir java/lib
3+ cp -r target/layer-java-layer-1.0-SNAPSHOT.jar java/lib/
4+ zip -r layer_content.zip java
Original file line number Diff line number Diff line change 1+ <project xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
2+ xsi : schemaLocation =" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" >
3+ <modelVersion >4.0.0</modelVersion >
4+ <groupId >com.example</groupId >
5+ <artifactId >layer-java-layer</artifactId >
6+ <packaging >jar</packaging >
7+ <version >1.0-SNAPSHOT</version >
8+ <name >layer-java-layer</name >
9+
10+ <properties >
11+ <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
12+ <maven .compiler.source>21</maven .compiler.source>
13+ <maven .compiler.target>21</maven .compiler.target>
14+ </properties >
15+
16+ <dependencies >
17+ <dependency >
18+ <groupId >com.amazonaws</groupId >
19+ <artifactId >aws-lambda-java-core</artifactId >
20+ <version >1.2.3</version >
21+ </dependency >
22+
23+ <dependency >
24+ <groupId >com.fasterxml.jackson.core</groupId >
25+ <artifactId >jackson-databind</artifactId >
26+ <version >2.17.0</version >
27+ </dependency >
28+ </dependencies >
29+
30+ <build >
31+ <plugins >
32+ <plugin >
33+ <groupId >org.apache.maven.plugins</groupId >
34+ <artifactId >maven-compiler-plugin</artifactId >
35+ <version >3.13.0</version >
36+ <configuration >
37+ <source >21</source >
38+ <target >21</target >
39+ <release >21</release >
40+ </configuration >
41+ </plugin >
42+
43+ <plugin >
44+ <groupId >org.apache.maven.plugins</groupId >
45+ <artifactId >maven-shade-plugin</artifactId >
46+ <version >3.5.2</version >
47+ <configuration >
48+ <createDependencyReducedPom >false</createDependencyReducedPom >
49+ </configuration >
50+ <executions >
51+ <execution >
52+ <phase >package</phase >
53+ <goals >
54+ <goal >shade</goal >
55+ </goals >
56+ </execution >
57+ </executions >
58+ </plugin >
59+ </plugins >
60+ </build >
61+
62+ </project >
You can’t perform that action at this time.
0 commit comments