类 WebHttpHandlerBuilder
- java.lang.Object
- org.springframework.web.server.adapter.WebHttpHandlerBuilder
public final class WebHttpHandlerBuilder extends Object
This builder has two purposes:One is to assemble a processing chain that consists of a target
WebHandler, then decorated with a set ofWebFilters, then further decorated with a set ofWebExceptionHandlers.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 ofHttpWebHandlerAdapter.The processing chain can be assembled manually via builder methods, or detected from a Spring
ApplicationContextviaapplicationContext, or a mix of both.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev, Sebastien Deleuze
- 另请参阅:
HttpWebHandlerAdapter
字段概要
字段 修饰符和类型 字段 说明 static StringFORWARDED_HEADER_TRANSFORMER_BEAN_NAMEWell-known name for the ForwardedHeaderTransformer in the bean factory.static StringLOCALE_CONTEXT_RESOLVER_BEAN_NAMEWell-known name for the LocaleContextResolver in the bean factory.static StringSERVER_CODEC_CONFIGURER_BEAN_NAMEWell-known name for the ServerCodecConfigurer in the bean factory.static StringWEB_HANDLER_BEAN_NAMEWell-known name for the target WebHandler in the bean factory.static StringWEB_SESSION_MANAGER_BEAN_NAMEWell-known name for the WebSessionManager in the bean factory.
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 static WebHttpHandlerBuilderapplicationContext(ApplicationContext context)Static factory method to create a new builder instance by detecting beans in anApplicationContext.HttpHandlerbuild()Build theHttpHandler.WebHttpHandlerBuilderclone()Clone thisWebHttpHandlerBuilder.WebHttpHandlerBuildercodecConfigurer(ServerCodecConfigurer codecConfigurer)Configure theServerCodecConfigurerto set on theWebServerExchange.WebHttpHandlerBuilderexceptionHandler(WebExceptionHandler... handlers)Add the given exception handler(s).WebHttpHandlerBuilderexceptionHandlers(Consumer<List<WebExceptionHandler>> consumer)Manipulate the "live" list of currently configured exception handlers.WebHttpHandlerBuilderfilter(WebFilter... filters)Add the given filter(s).WebHttpHandlerBuilderfilters(Consumer<List<WebFilter>> consumer)Manipulate the "live" list of currently configured filters.WebHttpHandlerBuilderforwardedHeaderTransformer(ForwardedHeaderTransformer transformer)Configure theForwardedHeaderTransformerfor extracting and/or removing forwarded headers.booleanhasCodecConfigurer()Whether aServerCodecConfigureris configured or not, either detected from anApplicationContextor explicitly configured viacodecConfigurer.booleanhasForwardedHeaderTransformer()Whether aForwardedHeaderTransformeris configured or not, either detected from anApplicationContextor explicitly configured viaforwardedHeaderTransformer(ForwardedHeaderTransformer).booleanhasLocaleContextResolver()Whether aLocaleContextResolveris configured or not, either detected from anApplicationContextor explicitly configured vialocaleContextResolver.booleanhasSessionManager()Whether aWebSessionManageris configured or not, either detected from anApplicationContextor explicitly configured viasessionManager.WebHttpHandlerBuilderlocaleContextResolver(LocaleContextResolver localeContextResolver)Configure theLocaleContextResolverto set on theWebServerExchange.WebHttpHandlerBuildersessionManager(WebSessionManager manager)Configure theWebSessionManagerto set on theWebServerExchange.static WebHttpHandlerBuilderwebHandler(WebHandler webHandler)Static factory method to create a new builder instance.
字段详细资料
WEB_HANDLER_BEAN_NAME
public static final String WEB_HANDLER_BEAN_NAME
Well-known name for the target WebHandler in the bean factory.- 另请参阅:
- 常量字段值
WEB_SESSION_MANAGER_BEAN_NAME
public static final String WEB_SESSION_MANAGER_BEAN_NAME
Well-known name for the WebSessionManager in the bean factory.- 另请参阅:
- 常量字段值
SERVER_CODEC_CONFIGURER_BEAN_NAME
public static final String SERVER_CODEC_CONFIGURER_BEAN_NAME
Well-known name for the ServerCodecConfigurer in the bean factory.- 另请参阅:
- 常量字段值
LOCALE_CONTEXT_RESOLVER_BEAN_NAME
public static final String LOCALE_CONTEXT_RESOLVER_BEAN_NAME
Well-known name for the LocaleContextResolver in the bean factory.- 另请参阅:
- 常量字段值
FORWARDED_HEADER_TRANSFORMER_BEAN_NAME
public static final String FORWARDED_HEADER_TRANSFORMER_BEAN_NAME
Well-known name for the ForwardedHeaderTransformer in the bean factory.- 另请参阅:
- 常量字段值
方法详细资料
webHandler
public static WebHttpHandlerBuilder webHandler(WebHandler webHandler)
Static factory method to create a new builder instance.- 参数:
webHandler- the target handler for the request- 返回:
- the prepared builder
applicationContext
public static WebHttpHandlerBuilder applicationContext(ApplicationContext context)
Static factory method to create a new builder instance by detecting beans in anApplicationContext. The following are detected:WebHandler[1] -- looked up by the nameWEB_HANDLER_BEAN_NAME.WebFilter[0..N] -- detected by type and ordered, seeAnnotationAwareOrderComparator.WebExceptionHandler[0..N] -- detected by type and ordered.WebSessionManager[0..1] -- looked up by the nameWEB_SESSION_MANAGER_BEAN_NAME.ServerCodecConfigurer[0..1] -- looked up by the nameSERVER_CODEC_CONFIGURER_BEAN_NAME.LocaleContextResolver[0..1] -- looked up by the nameLOCALE_CONTEXT_RESOLVER_BEAN_NAME.
- 参数:
context- the application context to use for the lookup- 返回:
- the prepared builder
filter
public WebHttpHandlerBuilder filter(WebFilter... filters)
Add the given filter(s).- 参数:
filters- the filter(s) to add that's
filters
public WebHttpHandlerBuilder filters(Consumer<List<WebFilter>> consumer)
Manipulate the "live" list of currently configured filters.- 参数:
consumer- the consumer to use
exceptionHandler
public WebHttpHandlerBuilder exceptionHandler(WebExceptionHandler... handlers)
Add the given exception handler(s).- 参数:
handlers- the exception handler(s)
exceptionHandlers
public WebHttpHandlerBuilder exceptionHandlers(Consumer<List<WebExceptionHandler>> consumer)
Manipulate the "live" list of currently configured exception handlers.- 参数:
consumer- the consumer to use
sessionManager
public WebHttpHandlerBuilder sessionManager(WebSessionManager manager)
Configure theWebSessionManagerto set on theWebServerExchange.By default
DefaultWebSessionManageris used.- 参数:
manager- the session manager- 另请参阅:
HttpWebHandlerAdapter.setSessionManager(WebSessionManager)
hasSessionManager
public boolean hasSessionManager()
Whether aWebSessionManageris configured or not, either detected from anApplicationContextor explicitly configured viasessionManager.- 从以下版本开始:
- 5.0.9
codecConfigurer
public WebHttpHandlerBuilder codecConfigurer(ServerCodecConfigurer codecConfigurer)
Configure theServerCodecConfigurerto set on theWebServerExchange.- 参数:
codecConfigurer- the codec configurer
hasCodecConfigurer
public boolean hasCodecConfigurer()
Whether aServerCodecConfigureris configured or not, either detected from anApplicationContextor explicitly configured viacodecConfigurer.- 从以下版本开始:
- 5.0.9
localeContextResolver
public WebHttpHandlerBuilder localeContextResolver(LocaleContextResolver localeContextResolver)
Configure theLocaleContextResolverto set on theWebServerExchange.- 参数:
localeContextResolver- the locale context resolver
hasLocaleContextResolver
public boolean hasLocaleContextResolver()
Whether aLocaleContextResolveris configured or not, either detected from anApplicationContextor explicitly configured vialocaleContextResolver.- 从以下版本开始:
- 5.0.9
forwardedHeaderTransformer
public WebHttpHandlerBuilder forwardedHeaderTransformer(ForwardedHeaderTransformer transformer)
Configure theForwardedHeaderTransformerfor extracting and/or removing forwarded headers.- 参数:
transformer- the transformer- 从以下版本开始:
- 5.1
hasForwardedHeaderTransformer
public boolean hasForwardedHeaderTransformer()
Whether aForwardedHeaderTransformeris configured or not, either detected from anApplicationContextor explicitly configured viaforwardedHeaderTransformer(ForwardedHeaderTransformer).- 从以下版本开始:
- 5.1
build
public HttpHandler build()
Build theHttpHandler.
clone
public WebHttpHandlerBuilder clone()
Clone thisWebHttpHandlerBuilder.