public class WebHttpHandlerBuilder extends Object
HttpHandler that adapts to a target WebHandler
along with a chain of WebFilters and a set of
WebExceptionHandlers.
Example usage:
WebFilter filter = ... ;
WebHandler webHandler = ... ;
WebExceptionHandler exceptionHandler = ...;
HttpHandler httpHandler = WebHttpHandlerBuilder.webHandler(webHandler)
.filters(filter)
.exceptionHandlers(exceptionHandler)
.build();
| Modifier and Type | Field and Description |
|---|---|
static String |
WEB_HANDLER_BEAN_NAME
Well-known name for the target WebHandler in the bean factory.
|
static String |
WEB_SESSION_MANAGER_BEAN_NAME
Well-known name for the WebSessionManager in the bean factory.
|
| Modifier and Type | Method and Description |
|---|---|
static WebHttpHandlerBuilder |
applicationContext(org.springframework.context.ApplicationContext context)
Factory method to create a new builder instance by detecting beans in an
ApplicationContext. |
HttpHandler |
build()
Build the
HttpHandler. |
WebHttpHandlerBuilder |
exceptionHandlers(WebExceptionHandler... exceptionHandlers)
Add the given exception handler to apply at the end of request processing.
|
WebHttpHandlerBuilder |
filters(WebFilter... filters)
Add the given filters to use for processing requests.
|
WebHttpHandlerBuilder |
sessionManager(WebSessionManager sessionManager)
Configure the
WebSessionManager to set on the
WebServerExchange. |
static WebHttpHandlerBuilder |
webHandler(WebHandler webHandler)
Factory method to create a new builder instance.
|
public static final String WEB_HANDLER_BEAN_NAME
public static final String WEB_SESSION_MANAGER_BEAN_NAME
public static WebHttpHandlerBuilder webHandler(WebHandler webHandler)
webHandler - the target handler for the requestpublic static WebHttpHandlerBuilder applicationContext(org.springframework.context.ApplicationContext context)
ApplicationContext. The following are detected:
WebHandler [1] -- looked up by the name
WEB_HANDLER_BEAN_NAME.
WebFilter [0..N] -- detected by type and ordered,
see AnnotationAwareOrderComparator.
WebExceptionHandler [0..N] -- detected by type and
ordered.
WebSessionManager [0..1] -- looked up by the name
WEB_SESSION_MANAGER_BEAN_NAME.
context - the application context to use for the lookuppublic WebHttpHandlerBuilder filters(WebFilter... filters)
filters - the filters to addpublic WebHttpHandlerBuilder exceptionHandlers(WebExceptionHandler... exceptionHandlers)
exceptionHandlers - the exception handlerspublic WebHttpHandlerBuilder sessionManager(WebSessionManager sessionManager)
WebSessionManager to set on the
WebServerExchange.
By default DefaultWebSessionManager is used.
sessionManager - the session managerHttpWebHandlerAdapter.setSessionManager(WebSessionManager)public HttpHandler build()
HttpHandler.