RequestType - The type for the incoming Lambda eventResponseType - The type for Lambda's return valuepublic class JerseyLambdaContainerHandler<RequestType,ResponseType> extends LambdaContainerHandler<RequestType,ResponseType,org.glassfish.jersey.server.ContainerRequest,com.amazonaws.serverless.proxy.jersey.JerseyResponseWriter> implements org.glassfish.jersey.server.spi.Container
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);
}
}
LambdaContainerHandler| Constructor and Description |
|---|
JerseyLambdaContainerHandler(RequestReader<RequestType,org.glassfish.jersey.server.ContainerRequest> requestReader,
ResponseWriter<com.amazonaws.serverless.proxy.jersey.JerseyResponseWriter,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 |
|---|---|
org.glassfish.jersey.server.ApplicationHandler |
getApplicationHandler()
The instantiated
ApplicationHandler object used by this container |
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. |
org.glassfish.jersey.server.ResourceConfig |
getConfiguration()
Gets the configuration currently set in the internal
ApplicationHandler |
protected com.amazonaws.serverless.proxy.jersey.JerseyResponseWriter |
getContainerResponse(java.util.concurrent.CountDownLatch latch) |
protected void |
handleRequest(org.glassfish.jersey.server.ContainerRequest containerRequest,
com.amazonaws.serverless.proxy.jersey.JerseyResponseWriter jerseyResponseWriter,
com.amazonaws.services.lambda.runtime.Context lambdaContext) |
void |
reload()
Shuts down and restarts the application handler in the current container.
|
void |
reload(org.glassfish.jersey.server.ResourceConfig resourceConfig)
Restarts the application handler and configures a different
Application object. |
proxypublic JerseyLambdaContainerHandler(RequestReader<RequestType,org.glassfish.jersey.server.ContainerRequest> requestReader, ResponseWriter<com.amazonaws.serverless.proxy.jersey.JerseyResponseWriter,ResponseType> responseWriter, SecurityContextWriter<RequestType> securityContextWriter, ExceptionHandler<ResponseType> exceptionHandler, javax.ws.rs.core.Application jaxRsApplication)
onStartup method.jaxRsApplication - A Jersey application instance.public 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 objectpublic org.glassfish.jersey.server.ResourceConfig getConfiguration()
ApplicationHandlergetConfiguration in interface org.glassfish.jersey.server.spi.Containerpublic org.glassfish.jersey.server.ApplicationHandler getApplicationHandler()
ApplicationHandler object used by this containergetApplicationHandler in interface org.glassfish.jersey.server.spi.Containerpublic void reload()
ApplicationHandler
object is re-initialized with the Application object initially set in the LambdaContainer.getInstance()
call.reload in interface org.glassfish.jersey.server.spi.Containerpublic void reload(org.glassfish.jersey.server.ResourceConfig resourceConfig)
Application object. The new application
resets the one currently configured in the container.reload in interface org.glassfish.jersey.server.spi.ContainerresourceConfig - An initialized Applicationprotected com.amazonaws.serverless.proxy.jersey.JerseyResponseWriter getContainerResponse(java.util.concurrent.CountDownLatch latch)
getContainerResponse in class LambdaContainerHandler<RequestType,ResponseType,org.glassfish.jersey.server.ContainerRequest,com.amazonaws.serverless.proxy.jersey.JerseyResponseWriter>protected void handleRequest(org.glassfish.jersey.server.ContainerRequest containerRequest,
com.amazonaws.serverless.proxy.jersey.JerseyResponseWriter jerseyResponseWriter,
com.amazonaws.services.lambda.runtime.Context lambdaContext)
handleRequest in class LambdaContainerHandler<RequestType,ResponseType,org.glassfish.jersey.server.ContainerRequest,com.amazonaws.serverless.proxy.jersey.JerseyResponseWriter>Copyright © 2017. All Rights Reserved.