public final class WebHttpHandlerBuilder
extends java.lang.Object
One is to assemble a processing chain that consists of a target WebHandler
,
then decorated with a set of WebFilters
, then further decorated with
a set of WebExceptionHandlers
.
The second purpose is to adapt the resulting processing chain to an HttpHandler
:
the lowest-level reactive HTTP handling abstraction which can then be used with any of the
supported runtimes. The adaptation is done with the help of HttpWebHandlerAdapter
.
The processing chain can be assembled manually via builder methods, or detected from
a Spring ApplicationContext
via applicationContext
, or a mix of both.
HttpWebHandlerAdapter
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
FORWARDED_HEADER_TRANSFORMER_BEAN_NAME
Well-known name for the ForwardedHeaderTransformer in the bean factory.
|
static java.lang.String |
LOCALE_CONTEXT_RESOLVER_BEAN_NAME
Well-known name for the LocaleContextResolver in the bean factory.
|
static java.lang.String |
SERVER_CODEC_CONFIGURER_BEAN_NAME
Well-known name for the ServerCodecConfigurer in the bean factory.
|
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 and Type | Method and Description |
---|---|
static WebHttpHandlerBuilder |
applicationContext(ApplicationContext context)
Static factory method to create a new builder instance by detecting beans
in an
ApplicationContext . |
HttpHandler |
build()
Build the
HttpHandler . |
WebHttpHandlerBuilder |
clone()
Clone this
WebHttpHandlerBuilder . |
WebHttpHandlerBuilder |
codecConfigurer(ServerCodecConfigurer codecConfigurer)
Configure the
ServerCodecConfigurer to set on the WebServerExchange . |
WebHttpHandlerBuilder |
exceptionHandler(WebExceptionHandler... handlers)
Add the given exception handler(s).
|
WebHttpHandlerBuilder |
exceptionHandlers(java.util.function.Consumer<java.util.List<WebExceptionHandler>> consumer)
Manipulate the "live" list of currently configured exception handlers.
|
WebHttpHandlerBuilder |
filter(WebFilter... filters)
Add the given filter(s).
|
WebHttpHandlerBuilder |
filters(java.util.function.Consumer<java.util.List<WebFilter>> consumer)
Manipulate the "live" list of currently configured filters.
|
WebHttpHandlerBuilder |
forwardedHeaderTransformer(ForwardedHeaderTransformer transformer)
Configure the
ForwardedHeaderTransformer for extracting and/or
removing forwarded headers. |
boolean |
hasCodecConfigurer()
Whether a
ServerCodecConfigurer is configured or not, either detected from an
ApplicationContext or explicitly configured via codecConfigurer . |
boolean |
hasForwardedHeaderTransformer()
Whether a
ForwardedHeaderTransformer is configured or not, either
detected from an ApplicationContext or explicitly configured via
forwardedHeaderTransformer(ForwardedHeaderTransformer) . |
boolean |
hasLocaleContextResolver()
Whether a
LocaleContextResolver is configured or not, either detected from an
ApplicationContext or explicitly configured via localeContextResolver . |
boolean |
hasSessionManager()
Whether a
WebSessionManager is configured or not, either detected from an
ApplicationContext or explicitly configured via sessionManager . |
WebHttpHandlerBuilder |
localeContextResolver(LocaleContextResolver localeContextResolver)
Configure the
LocaleContextResolver to set on the
WebServerExchange . |
WebHttpHandlerBuilder |
sessionManager(WebSessionManager manager)
Configure the
WebSessionManager to set on the
WebServerExchange . |
static WebHttpHandlerBuilder |
webHandler(WebHandler webHandler)
Static 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
public static final java.lang.String SERVER_CODEC_CONFIGURER_BEAN_NAME
public static final java.lang.String LOCALE_CONTEXT_RESOLVER_BEAN_NAME
public static final java.lang.String FORWARDED_HEADER_TRANSFORMER_BEAN_NAME
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
.
ServerCodecConfigurer
[0..1] -- looked up by the name
SERVER_CODEC_CONFIGURER_BEAN_NAME
.
LocaleContextResolver
[0..1] -- looked up by the name
LOCALE_CONTEXT_RESOLVER_BEAN_NAME
.
context
- the application context to use for the lookuppublic WebHttpHandlerBuilder filter(WebFilter... filters)
filters
- the filter(s) to add that'spublic WebHttpHandlerBuilder filters(java.util.function.Consumer<java.util.List<WebFilter>> consumer)
consumer
- the consumer to usepublic WebHttpHandlerBuilder exceptionHandler(WebExceptionHandler... handlers)
handlers
- the exception handler(s)public WebHttpHandlerBuilder exceptionHandlers(java.util.function.Consumer<java.util.List<WebExceptionHandler>> consumer)
consumer
- the consumer to usepublic WebHttpHandlerBuilder sessionManager(WebSessionManager manager)
WebSessionManager
to set on the
WebServerExchange
.
By default DefaultWebSessionManager
is used.
manager
- the session managerHttpWebHandlerAdapter.setSessionManager(WebSessionManager)
public boolean hasSessionManager()
WebSessionManager
is configured or not, either detected from an
ApplicationContext
or explicitly configured via sessionManager
.public WebHttpHandlerBuilder codecConfigurer(ServerCodecConfigurer codecConfigurer)
ServerCodecConfigurer
to set on the WebServerExchange
.codecConfigurer
- the codec configurerpublic boolean hasCodecConfigurer()
ServerCodecConfigurer
is configured or not, either detected from an
ApplicationContext
or explicitly configured via codecConfigurer
.public WebHttpHandlerBuilder localeContextResolver(LocaleContextResolver localeContextResolver)
LocaleContextResolver
to set on the
WebServerExchange
.localeContextResolver
- the locale context resolverpublic boolean hasLocaleContextResolver()
LocaleContextResolver
is configured or not, either detected from an
ApplicationContext
or explicitly configured via localeContextResolver
.public WebHttpHandlerBuilder forwardedHeaderTransformer(ForwardedHeaderTransformer transformer)
ForwardedHeaderTransformer
for extracting and/or
removing forwarded headers.transformer
- the transformerpublic boolean hasForwardedHeaderTransformer()
ForwardedHeaderTransformer
is configured or not, either
detected from an ApplicationContext
or explicitly configured via
forwardedHeaderTransformer(ForwardedHeaderTransformer)
.public HttpHandler build()
HttpHandler
.public WebHttpHandlerBuilder clone()
WebHttpHandlerBuilder
.clone
in class java.lang.Object