RequestType - The expected request object. This is the model class that the event JSON is de-serialized toResponseType - The expected Lambda function response object. Responses from the container will be written to this model objectContainerRequestType - The request type for the wrapped Java containerContainerResponseType - The response or response writer type for the wrapped Java containerpublic abstract class LambdaContainerHandler<RequestType,ResponseType,ContainerRequestType,ContainerResponseType>
extends java.lang.Object
LambdaContainerHandler.| Modifier and Type | Field and Description |
|---|---|
protected com.amazonaws.services.lambda.runtime.Context |
lambdaContext |
static java.lang.String |
SERVER_INFO |
| Modifier | Constructor and Description |
|---|---|
protected |
LambdaContainerHandler(java.lang.Class<RequestType> requestClass,
java.lang.Class<ResponseType> responseClass,
RequestReader<RequestType,ContainerRequestType> requestReader,
ResponseWriter<ContainerResponseType,ResponseType> responseWriter,
SecurityContextWriter<RequestType> securityContextWriter,
ExceptionHandler<ResponseType> exceptionHandler) |
| Modifier and Type | Method and Description |
|---|---|
static ContainerConfig |
getContainerConfig()
Returns the current container configuration object.
|
protected abstract ContainerResponseType |
getContainerResponse(ContainerRequestType request,
java.util.concurrent.CountDownLatch latch) |
static com.fasterxml.jackson.databind.ObjectMapper |
getObjectMapper() |
protected abstract void |
handleRequest(ContainerRequestType containerRequest,
ContainerResponseType containerResponse,
com.amazonaws.services.lambda.runtime.Context lambdaContext) |
abstract void |
initialize() |
ResponseType |
proxy(RequestType request,
com.amazonaws.services.lambda.runtime.Context context)
Proxies requests to the underlying container given the incoming Lambda request.
|
void |
proxyStream(java.io.InputStream input,
java.io.OutputStream output,
com.amazonaws.services.lambda.runtime.Context context)
Handles Lambda
RequestStreamHandler method. |
void |
setLogFormatter(LogFormatter<ContainerRequestType,ContainerResponseType> formatter)
Sets the formatter used to log request data in CloudWatch.
|
void |
stripBasePath(java.lang.String basePath)
Configures the library to strip a base path from incoming requests before passing them on to the wrapped
framework.
|
public static final java.lang.String SERVER_INFO
protected com.amazonaws.services.lambda.runtime.Context lambdaContext
protected LambdaContainerHandler(java.lang.Class<RequestType> requestClass, java.lang.Class<ResponseType> responseClass, RequestReader<RequestType,ContainerRequestType> requestReader, ResponseWriter<ContainerResponseType,ResponseType> responseWriter, SecurityContextWriter<RequestType> securityContextWriter, ExceptionHandler<ResponseType> exceptionHandler)
protected abstract ContainerResponseType getContainerResponse(ContainerRequestType request, java.util.concurrent.CountDownLatch latch)
protected abstract void handleRequest(ContainerRequestType containerRequest, ContainerResponseType containerResponse, com.amazonaws.services.lambda.runtime.Context lambdaContext) throws java.lang.Exception
java.lang.Exceptionpublic abstract void initialize()
throws ContainerInitializationException
ContainerInitializationExceptionpublic static com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
public void stripBasePath(java.lang.String basePath)
basePath - The base path to be stripped from the requestpublic void setLogFormatter(LogFormatter<ContainerRequestType,ContainerResponseType> formatter)
ApacheCombinedServletLogFormatter.formatter - The log formatter objectpublic ResponseType proxy(RequestType request, com.amazonaws.services.lambda.runtime.Context context)
request - The incoming Lambda requestcontext - The execution context for the Lambda functionpublic void proxyStream(java.io.InputStream input,
java.io.OutputStream output,
com.amazonaws.services.lambda.runtime.Context context)
throws java.io.IOException
RequestStreamHandler method. The method uses an ObjectMapper
to transform the incoming input stream into the given RequestType and then calls the
proxy(Object, Context) method to handle the request. The output from the proxy method is
written on the given output stream.input - Lambda's incoming input streamoutput - Lambda's response output streamcontext - Lambda's context objectjava.io.IOException - If an error occurs during the stream processingpublic static ContainerConfig getContainerConfig()
Copyright © 2018. All Rights Reserved.