RequestType - The type for the incoming Lambda eventResponseType - The type for Lambda's return valuepublic class JerseyLambdaContainerHandler<RequestType,ResponseType> extends AwsLambdaServletContainerHandler<RequestType,ResponseType,AwsProxyHttpServletRequest,AwsHttpServletResponse>
LambdaContainerHandler interface. Given a Jax-Rs application
starts Jersey's ApplicationHandler and proxies requests and responses using the RequestReader and
ResponseWriter objects. The reader and writer objects are inherited from the BaseLambdaContainerHandler
object.
public class LambdaHandler implements RequestHandler<AwsProxyRequest, AwsProxyResponse> {
private ResourceConfig jerseyApplication = new ResourceConfig().packages("your.app.package");
private JerseyLambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> container = JerseyLambdaContainerHandler.getAwsProxyHandler(jerseyApplication);
public AwsProxyResponse handleRequest(AwsProxyRequest awsProxyRequest, Context context) {
return container.proxy(awsProxyRequest, context);
}
}
LambdaContainerHandlerAwsLambdaServletContainerHandler.StartupHandlerservletContext, startupHandlerlambdaContext, SERVER_INFO| Constructor and Description |
|---|
JerseyLambdaContainerHandler(java.lang.Class<RequestType> requestTypeClass,
java.lang.Class<ResponseType> responseTypeClass,
RequestReader<RequestType,AwsProxyHttpServletRequest> requestReader,
ResponseWriter<AwsHttpServletResponse,ResponseType> responseWriter,
SecurityContextWriter<RequestType> securityContextWriter,
ExceptionHandler<ResponseType> exceptionHandler,
javax.ws.rs.core.Application jaxRsApplication)
Private constructor for a LambdaContainer.
|
| Modifier and Type | Method and Description |
|---|---|
static JerseyLambdaContainerHandler<AwsProxyRequest,AwsProxyResponse> |
getAwsProxyHandler(javax.ws.rs.core.Application jaxRsApplication)
Returns an initialized
JerseyLambdaContainerHandler that includes RequestReader and
ResponseWriter objects for the AwsProxyRequest and AwsProxyResponse
objects. |
protected AwsHttpServletResponse |
getContainerResponse(AwsProxyHttpServletRequest request,
java.util.concurrent.CountDownLatch latch) |
org.glassfish.jersey.internal.inject.InjectionManager |
getInjectionManager() |
protected void |
handleRequest(AwsProxyHttpServletRequest httpServletRequest,
AwsHttpServletResponse httpServletResponse,
com.amazonaws.services.lambda.runtime.Context lambdaContext) |
void |
initialize() |
doFilter, forward, getFilterChain, getServletContext, include, onStartup, setServletContextgetContainerConfig, getObjectMapper, proxy, proxyStream, setLogFormatter, stripBasePathpublic JerseyLambdaContainerHandler(java.lang.Class<RequestType> requestTypeClass, java.lang.Class<ResponseType> responseTypeClass, RequestReader<RequestType,AwsProxyHttpServletRequest> requestReader, ResponseWriter<AwsHttpServletResponse,ResponseType> responseWriter, SecurityContextWriter<RequestType> securityContextWriter, ExceptionHandler<ResponseType> exceptionHandler, javax.ws.rs.core.Application jaxRsApplication)
onStartup method.requestTypeClass - The class for the expected event typeresponseTypeClass - The class for the output typerequestReader - A request reader instanceresponseWriter - A response writer instancesecurityContextWriter - A security context writer objectexceptionHandler - An exception handlerjaxRsApplication - The JaxRs applicationpublic static JerseyLambdaContainerHandler<AwsProxyRequest,AwsProxyResponse> getAwsProxyHandler(javax.ws.rs.core.Application jaxRsApplication)
JerseyLambdaContainerHandler that includes RequestReader and
ResponseWriter objects for the AwsProxyRequest and AwsProxyResponse
objects.jaxRsApplication - A configured Jax-Rs application object. For Jersey apps this can be the default
ResourceConfig objectJerseyLambdaContainerHandler objectprotected AwsHttpServletResponse getContainerResponse(AwsProxyHttpServletRequest request, java.util.concurrent.CountDownLatch latch)
getContainerResponse in class LambdaContainerHandler<RequestType,ResponseType,AwsProxyHttpServletRequest,AwsHttpServletResponse>protected void handleRequest(AwsProxyHttpServletRequest httpServletRequest, AwsHttpServletResponse httpServletResponse, com.amazonaws.services.lambda.runtime.Context lambdaContext) throws java.lang.Exception
handleRequest in class LambdaContainerHandler<RequestType,ResponseType,AwsProxyHttpServletRequest,AwsHttpServletResponse>java.lang.Exceptionpublic void initialize()
initialize in class LambdaContainerHandler<RequestType,ResponseType,AwsProxyHttpServletRequest,AwsHttpServletResponse>public org.glassfish.jersey.internal.inject.InjectionManager getInjectionManager()
Copyright © 2019. All Rights Reserved.