public class WebHttpHandlerBuilder
extends java.lang.Object
HttpHandler
that adapts to a target WebHandler
along with a chain of WebFilter
s and a set of
WebExceptionHandler
s.
Example usage:
WebFilter filter = ... ; WebHandler webHandler = ... ; WebExceptionHandler exceptionHandler = ...; HttpHandler httpHandler = WebHttpHandlerBuilder.webHandler(webHandler) .filters(filter) .exceptionHandlers(exceptionHandler) .build();
Modifier and Type | Class and Description |
---|---|
private static class |
WebHttpHandlerBuilder.AutowiredExceptionHandlersContainer |
private static class |
WebHttpHandlerBuilder.AutowiredFiltersContainer |
Modifier and Type | Field and Description |
---|---|
private java.util.List<WebExceptionHandler> |
exceptionHandlers |
private java.util.List<WebFilter> |
filters |
private WebSessionManager |
sessionManager |
private WebHandler |
targetHandler |
static java.lang.String |
WEB_HANDLER_BEAN_NAME
Well-known name for the target WebHandler in the bean factory.
|
static java.lang.String |
WEB_SESSION_MANAGER_BEAN_NAME
Well-known name for the WebSessionManager in the bean factory.
|
Modifier | Constructor and Description |
---|---|
private |
WebHttpHandlerBuilder(WebHandler targetHandler)
Private constructor.
|
Modifier and Type | Method and Description |
---|---|
static WebHttpHandlerBuilder |
applicationContext(ApplicationContext context)
Factory method to create a new builder instance by detecting beans in an
ApplicationContext . |
HttpHandler |
build()
Build the
HttpHandler . |
WebHttpHandlerBuilder |
exceptionHandlers(java.util.List<WebExceptionHandler> exceptionHandlers)
Add the given exception handler to apply at the end of request processing.
|
WebHttpHandlerBuilder |
exceptionHandlers(WebExceptionHandler... exceptionHandlers)
Add the given exception handler to apply at the end of request processing.
|
WebHttpHandlerBuilder |
filters(java.util.Collection<? extends WebFilter> filters)
Add the given filters to use for processing requests.
|
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 java.lang.String WEB_HANDLER_BEAN_NAME
public static final java.lang.String WEB_SESSION_MANAGER_BEAN_NAME
private final WebHandler targetHandler
private final java.util.List<WebFilter> filters
private final java.util.List<WebExceptionHandler> exceptionHandlers
private WebSessionManager sessionManager
private WebHttpHandlerBuilder(WebHandler targetHandler)
webHandler(WebHandler)
.public static WebHttpHandlerBuilder webHandler(WebHandler webHandler)
webHandler
- the target handler for the requestpublic static WebHttpHandlerBuilder applicationContext(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 filters(java.util.Collection<? extends WebFilter> filters)
filters
- the filters to addpublic WebHttpHandlerBuilder exceptionHandlers(WebExceptionHandler... exceptionHandlers)
exceptionHandlers
- the exception handlerspublic WebHttpHandlerBuilder exceptionHandlers(java.util.List<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
.