-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathHelloPOJO.java
More file actions
49 lines (39 loc) · 1.65 KB
/
HelloPOJO.java
File metadata and controls
49 lines (39 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package lambda;
import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;
import saaf.Inspector;
import saaf.Response;
import java.util.HashMap;
/**
* uwt.lambda_test::handleRequest
*
* @author Wes Lloyd
* @author Robert Cordingly
*/
public class HelloPOJO implements RequestHandler<Request, HashMap<String, Object>> {
/**
* Lambda Function Handler
*
* @param request Request POJO with defined variables from Request.java
* @param context
* @return HashMap that Lambda will automatically convert into JSON.
*/
public HashMap<String, Object> handleRequest(Request request, Context context) {
//Collect inital data.
Inspector inspector = new Inspector();
inspector.inspectAll();
//****************START FUNCTION IMPLEMENTATION*************************
//Add custom key/value attribute to SAAF's output. (OPTIONAL)
inspector.addAttribute("message", "Hello " + request.getName()
+ "! This is an attributed added to the Inspector!");
//Create and populate a separate response object for function output. (OPTIONAL)
Response response = new Response();
response.setValue("Hello " + request.getNameALLCAPS()
+ "! This is from a response object!");
inspector.consumeResponse(response);
//****************END FUNCTION IMPLEMENTATION***************************
//Collect final information such as total runtime and cpu deltas.
inspector.inspectAllDeltas();
return inspector.finish();
}
}