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 AwsLambdaServletContainerHandler<RequestType,ResponseType,ContainerRequestType extends javax.servlet.http.HttpServletRequest,ContainerResponseType extends javax.servlet.http.HttpServletResponse> extends LambdaContainerHandler<RequestType,ResponseType,ContainerRequestType,ContainerResponseType>
LambdaContainerHandler object that adds protected variables for the
ServletContext and FilterChainManager. This object should be extended by the framework-specific
implementations that want to support the servlet 3.1 specs.
Because Lambda only allows one event per container at a time, this object also acts as the RequestDispatcher| Modifier and Type | Class and Description |
|---|---|
static interface |
AwsLambdaServletContainerHandler.StartupHandler |
| Modifier and Type | Field and Description |
|---|---|
protected javax.servlet.ServletContext |
servletContext |
protected AwsLambdaServletContainerHandler.StartupHandler |
startupHandler |
lambdaContext, SERVER_INFO| Modifier | Constructor and Description |
|---|---|
protected |
AwsLambdaServletContainerHandler(java.lang.Class<RequestType> requestTypeClass,
java.lang.Class<ResponseType> responseTypeClass,
RequestReader<RequestType,ContainerRequestType> requestReader,
ResponseWriter<ContainerResponseType,ResponseType> responseWriter,
SecurityContextWriter<RequestType> securityContextWriter,
ExceptionHandler<ResponseType> exceptionHandler) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
doFilter(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.Servlet servlet)
Applies the filter chain in the request lifecycle
|
protected javax.servlet.FilterChain |
getFilterChain(javax.servlet.http.HttpServletRequest req,
javax.servlet.Servlet servlet) |
javax.servlet.ServletContext |
getServletContext()
Returns the current ServletContext.
|
void |
onStartup(AwsLambdaServletContainerHandler.StartupHandler h)
You can use the
onStartup to intercept the ServletContext as the Spring application is
initialized and inject custom values. |
protected void |
setServletContext(javax.servlet.ServletContext context)
Sets the ServletContext in the handler and initialized a new
FilterChainManager |
getContainerConfig, getContainerResponse, getInitializationWrapper, getObjectMapper, handleRequest, initialize, proxy, proxyStream, setInitializationWrapper, setLogFormatter, stripBasePathprotected AwsLambdaServletContainerHandler.StartupHandler startupHandler
protected javax.servlet.ServletContext servletContext
protected AwsLambdaServletContainerHandler(java.lang.Class<RequestType> requestTypeClass, java.lang.Class<ResponseType> responseTypeClass, RequestReader<RequestType,ContainerRequestType> requestReader, ResponseWriter<ContainerResponseType,ResponseType> responseWriter, SecurityContextWriter<RequestType> securityContextWriter, ExceptionHandler<ResponseType> exceptionHandler)
public void onStartup(AwsLambdaServletContainerHandler.StartupHandler h)
onStartup to intercept the ServletContext as the Spring application is
initialized and inject custom values. The StartupHandler is called after the onStartup method
of the LambdaSpringApplicationinitializer implementation. For example, you can use this method to
add custom filters to the servlet context:
handler = SpringLambdaContainerHandler.getAwsProxyHandler(EchoSpringAppConfig.class);
handler.onStartup(c -> {
// the "c" parameter to this function is the initialized servlet context
c.addFilter("CustomHeaderFilter", CustomHeaderFilter.class);
});
h - A lambda expression that implements the StartupHandler functional interfacepublic javax.servlet.ServletContext getServletContext()
protected void setServletContext(javax.servlet.ServletContext context)
FilterChainManagercontext - An initialized ServletContextprotected javax.servlet.FilterChain getFilterChain(javax.servlet.http.HttpServletRequest req,
javax.servlet.Servlet servlet)
protected void doFilter(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
javax.servlet.Servlet servlet)
throws java.io.IOException,
javax.servlet.ServletException
request - The Request object. This must be an implementation of HttpServletRequestresponse - The response object. This must be an implementation of HttpServletResponseservlet - Servlet at the end of the chain (optional).java.io.IOExceptionjavax.servlet.ServletExceptionCopyright © 2019. All Rights Reserved.