Class ServletLambdaContainerHandlerBuilder<RequestType,ResponseType,ContainerRequestType extends javax.servlet.http.HttpServletRequest,HandlerType extends AwsLambdaServletContainerHandler<RequestType,ResponseType,ContainerRequestType,AwsHttpServletResponse>,Builder extends ServletLambdaContainerHandlerBuilder<RequestType,ResponseType,ContainerRequestType,HandlerType,Builder>>
java.lang.Object
com.amazonaws.serverless.proxy.internal.servlet.ServletLambdaContainerHandlerBuilder<RequestType,ResponseType,ContainerRequestType,HandlerType,Builder>
- Type Parameters:
RequestType- The event object classResponseType- The output object classContainerRequestType- The container request type. For proxy implementations, this isAwsProxyHttpServletRequest. The response type is hardcoded toAwsHttpServletResponsesince it is a generic servlet response implementation.HandlerType- The type of the handler we are buildingBuilder- The builder object itself. This is used to allow implementations to re-use the setter method from this abstract class through "curiously recurring generic patterns"
public abstract class ServletLambdaContainerHandlerBuilder<RequestType,ResponseType,ContainerRequestType extends javax.servlet.http.HttpServletRequest,HandlerType extends AwsLambdaServletContainerHandler<RequestType,ResponseType,ContainerRequestType,AwsHttpServletResponse>,Builder extends ServletLambdaContainerHandlerBuilder<RequestType,ResponseType,ContainerRequestType,HandlerType,Builder>>
extends Object
Base builder class for
AwsLambdaServletContainerHandler. Implmentations can extend this class to have setters
for the basic parameters.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ExceptionHandler<ResponseType>protected InitializationWrapperprotected RequestReader<RequestType,ContainerRequestType>protected Class<RequestType>protected Class<ResponseType>protected ResponseWriter<AwsHttpServletResponse,ResponseType>protected SecurityContextWriter<RequestType> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionUses a newAsyncInitializationWrapperwith the no-parameter constructor that takes the actual JVM start timeasyncInit(long actualStartTime)Deprecated.abstract HandlerTypebuild()abstract HandlerTypeSets all of the required fields in the builder to the default settings for a Servlet-compatible framework that wants to support HTTP API's v2 proxy eventSets all of the required fields in the builder to the default settings for a Servlet-compatible framework that wants to support AWS proxy event and output types.exceptionHandler(ExceptionHandler<ResponseType> exceptionHandler)initializationWrapper(InitializationWrapper initializationWrapper)Sets the initialization wrapper to be used by thebuildAndInitialize()method to start the framework implementationsrequestReader(RequestReader<RequestType,ContainerRequestType> requestReader)requestTypeClass(Class<RequestType> requestType)responseTypeClass(Class<ResponseType> responseType)responseWriter(ResponseWriter<AwsHttpServletResponse,ResponseType> responseWriter)securityContextWriter(SecurityContextWriter<RequestType> securityContextWriter)protected abstract Builderself()Implementations should implement this method to return their type.protected voidvalidate()Validates that all of the required fields are populated.
-
Field Details
-
initializationWrapper
-
requestReader
protected RequestReader<RequestType,ContainerRequestType extends javax.servlet.http.HttpServletRequest> requestReader -
responseWriter
-
securityContextWriter
-
exceptionHandler
-
requestTypeClass
-
responseTypeClass
-
-
Constructor Details
-
ServletLambdaContainerHandlerBuilder
public ServletLambdaContainerHandlerBuilder()
-
-
Method Details
-
validate
Validates that all of the required fields are populated.- Throws:
ContainerInitializationException- If values have not been set on the builder. The message in the exception contains a standard error messageMISSING_FIELD_ERRORpopulated with the list of missing fields.
-
defaultProxy
Sets all of the required fields in the builder to the default settings for a Servlet-compatible framework that wants to support AWS proxy event and output types.- Returns:
- A populated builder
-
defaultHttpApiV2Proxy
Sets all of the required fields in the builder to the default settings for a Servlet-compatible framework that wants to support HTTP API's v2 proxy event- Returns:
- A populated builder
-
initializationWrapper
Sets the initialization wrapper to be used by thebuildAndInitialize()method to start the framework implementations- Parameters:
initializationWrapper- An implementation ofInitializationWrapper. In most cases, this will be set toInitializationWrapper. TheasyncInit(long)method sets this toAsyncInitializationWrapper.- Returns:
- This builder object
-
requestReader
-
responseWriter
-
securityContextWriter
-
exceptionHandler
-
requestTypeClass
-
responseTypeClass
-
asyncInit
Deprecated.As of release 1.5 this method is deprecated in favor of the parameters-less oneasyncInit().Uses an async initializer with the given start time to calculate the 10 seconds timeout.- Parameters:
actualStartTime- An epoch in milliseconds that should be used to calculate the 10 seconds timeout since the start of the application- Returns:
- A builder configured to use the async initializer
-
asyncInit
Uses a newAsyncInitializationWrapperwith the no-parameter constructor that takes the actual JVM start time- Returns:
- A builder configured to use an async initializer
-
self
Implementations should implement this method to return their type. All of the builder methods in this abstract class use this method to return the correct builder type.- Returns:
- The current builder.
-
build
- Throws:
ContainerInitializationException
-
buildAndInitialize
- Throws:
ContainerInitializationException
-
asyncInit().