Created
February 12, 2018 09:18
-
-
Save jigewxy/cfff64f337078819e10938a833252205 to your computer and use it in GitHub Desktop.
lambda function with pre-defined interface (RequestHandler <Request, Response> )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.amazonaws.services.lambda.runtime.RequestHandler; | |
import com.amazonaws.services.lambda.runtime.Context; | |
public class EchoHello implements RequestHandler <Request, Response> { | |
public Response handleRequest(Request request, Context context) { | |
String greetingString = String.format("Hello %s %s.", request.firstName, request.lastName); | |
return new Response(greetingString); | |
} | |
} | |
class Request { | |
String firstName; | |
String lastName; | |
public String getFirstName() { | |
return firstName; | |
} | |
public void setFirstName(String firstName) { | |
this.firstName = firstName; | |
} | |
public String getLastName() { | |
return lastName; | |
} | |
public void setLastName(String lastName) { | |
this.lastName = lastName; | |
} | |
public Request(String firstName, String lastName) { | |
this.firstName = firstName; | |
this.lastName = lastName; | |
} | |
public Request() { | |
} | |
} | |
class Response { | |
String greetings; | |
public String getGreetings() { | |
return greetings; | |
} | |
public void setGreetings(String greetings) { | |
this.greetings = greetings; | |
} | |
public Response(String greetings) { | |
this.greetings = greetings; | |
} | |
public Response() { | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>requestHandler</groupId> | |
<artifactId>lambdaPojo</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<dependencies> | |
<dependency> | |
<groupId>com.amazonaws</groupId> | |
<artifactId>aws-lambda-java-core</artifactId> | |
<version>1.2.0</version> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-shade-plugin</artifactId> | |
<version>2.3</version> | |
<configuration> | |
<createDependencyReducedPom>false</createDependencyReducedPom> | |
</configuration> | |
<executions> | |
<execution> | |
<phase>package</phase> | |
<goals> | |
<goal>shade</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment