Top Description Inners Fields Constructors Methods
org.springframework.web.reactive.config

public Class WebFluxConfigurationSupport

extends Object
implements ApplicationContextAware
Class Inheritance
All Implemented Interfaces
org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.Aware
Known Direct Subclasses
org.springframework.web.reactive.config.DelegatingWebFluxConfiguration
Imports
java.util.List, .Map, java.util.function.Predicate, reactor.core.publisher.Mono, org.springframework.beans.factory.BeanInitializationException, org.springframework.beans.factory.annotation.Qualifier, org.springframework.context.ApplicationContext, .ApplicationContextAware, org.springframework.context.annotation.Bean, org.springframework.core.ReactiveAdapterRegistry, org.springframework.core.annotation.Order, org.springframework.core.convert.converter.Converter, org.springframework.core.io.DefaultResourceLoader, .ResourceLoader, org.springframework.format.Formatter, .FormatterRegistry, org.springframework.format.support.DefaultFormattingConversionService, .FormattingConversionService, org.springframework.http.codec.ServerCodecConfigurer, org.springframework.lang.Nullable, org.springframework.util.Assert, .ClassUtils, org.springframework.validation.Errors, .MessageCodesResolver, .Validator, org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean, org.springframework.web.bind.WebDataBinder, org.springframework.web.bind.support.ConfigurableWebBindingInitializer, org.springframework.web.cors.CorsConfiguration, org.springframework.web.reactive.DispatcherHandler, .HandlerMapping, org.springframework.web.reactive.accept.RequestedContentTypeResolver, .RequestedContentTypeResolverBuilder, org.springframework.web.reactive.function.server.support.HandlerFunctionAdapter, .RouterFunctionMapping, .ServerResponseResultHandler, org.springframework.web.reactive.handler.AbstractHandlerMapping, .WebFluxResponseStatusExceptionHandler, org.springframework.web.reactive.resource.ResourceUrlProvider, org.springframework.web.reactive.result.SimpleHandlerAdapter, org.springframework.web.reactive.result.method.annotation.ArgumentResolverConfigurer, .RequestMappingHandlerAdapter, .RequestMappingHandlerMapping, .ResponseBodyResultHandler, .ResponseEntityResultHandler, org.springframework.web.reactive.result.view.ViewResolutionResultHandler, .ViewResolver, org.springframework.web.reactive.socket.WebSocketHandler, org.springframework.web.reactive.socket.server.WebSocketService, org.springframework.web.reactive.socket.server.support.HandshakeWebSocketService, .WebSocketHandlerAdapter, org.springframework.web.server.ServerWebExchange, .WebExceptionHandler, org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver, .LocaleContextResolver

The main class for Spring WebFlux configuration.

Import directly or extend and override protected methods to customize.

Authors
Rossen Stoyanchev, Brian Clozel
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
private ApplicationContext
private BlockingExecutionConfigurer
private Map<String, CorsConfiguration>
private static final boolean
private PathMatchConfigurer
private ViewResolverRegistry

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
addCorsMappings(CorsRegistry registry)

Override this method to configure cross-origin requests processing.

protected void
addFormatters(FormatterRegistry registry)

Override this method to add custom Converter and/or Formatter delegates to the common FormattingConversionService.

protected void
addResourceHandlers(ResourceHandlerRegistry registry)

Override this method to add resource handlers for serving static resources.

private void
protected void
configureArgumentResolvers(ArgumentResolverConfigurer configurer)

Configure resolvers for custom controller method arguments.

protected void
configureBlockingExecution(BlockingExecutionConfigurer configurer)

Override this method to configure blocking execution.

protected void
configureContentTypeResolver(RequestedContentTypeResolverBuilder builder)

Override to configure how the requested content type is resolved.

protected void
configureHttpMessageCodecs(ServerCodecConfigurer configurer)

Override to configure the HTTP message readers and writers to use.

public void
configurePathMatching(PathMatchConfigurer configurer)

Override to configure path matching options.

protected void
configureViewResolvers(ViewResolverRegistry registry)

Configure view resolution for supporting template engines.

protected LocaleContextResolver
createLocaleContextResolver()

Override to plug a subclass of LocaleContextResolver.

protected RequestMappingHandlerAdapter
protected RequestMappingHandlerMapping
protected RouterFunctionMapping
createRouterFunctionMapping()

Override to plug a subclass of RouterFunctionMapping.

public final ApplicationContext
protected final BlockingExecutionConfigurer
protected ConfigurableWebBindingInitializer
getConfigurableWebBindingInitializer(FormattingConversionService webFluxConversionService, Validator webFluxValidator)

Return the ConfigurableWebBindingInitializer to use for initializing all WebDataBinder instances.

protected final Map<String, CorsConfiguration>
getCorsConfigurations()

Callback for building the global CORS configuration.

protected MessageCodesResolver
getMessageCodesResolver()

Override this method to provide a custom MessageCodesResolver.

protected final PathMatchConfigurer
getPathMatchConfigurer()

Callback for building the PathMatchConfigurer.

protected Validator
getValidator()

Override this method to provide a custom Validator.

protected final ViewResolverRegistry
getViewResolverRegistry()

Callback for building the ViewResolverRegistry.

protected WebSocketService
public HandlerFunctionAdapter
private WebSocketService
public LocaleContextResolver
public RequestMappingHandlerAdapter
requestMappingHandlerAdapter(ReactiveAdapterRegistry reactiveAdapterRegistry, ServerCodecConfigurer serverCodecConfigurer, FormattingConversionService conversionService, Validator validator)

public RequestMappingHandlerMapping
public HandlerMapping
resourceHandlerMapping(ResourceUrlProvider resourceUrlProvider)

Return a handler mapping ordered at Integer.MAX_VALUE-1 with mapped resource handlers.

public ResourceUrlProvider
public ResponseBodyResultHandler
responseBodyResultHandler(ReactiveAdapterRegistry reactiveAdapterRegistry, ServerCodecConfigurer serverCodecConfigurer, RequestedContentTypeResolver contentTypeResolver)

public ResponseEntityResultHandler
responseEntityResultHandler(ReactiveAdapterRegistry reactiveAdapterRegistry, ServerCodecConfigurer serverCodecConfigurer, RequestedContentTypeResolver contentTypeResolver)

public WebExceptionHandler
public RouterFunctionMapping
public ServerCodecConfigurer
serverCodecConfigurer()

Return the configurer for HTTP message readers and writers.

public ServerResponseResultHandler
public void
setApplicationContext(ApplicationContext
the ApplicationContext object to be used by this object
applicationContext
)

Implements org.springframework.context.ApplicationContextAware.setApplicationContext.

Set the ApplicationContext that this object runs in. Normally this call will be used to initialize the object.

public SimpleHandlerAdapter
public ViewResolutionResultHandler
public ReactiveAdapterRegistry
webFluxAdapterRegistry()

Return a ReactiveAdapterRegistry to adapting reactive types.

public RequestedContentTypeResolver
public FormattingConversionService
webFluxConversionService()

Return a FormattingConversionService for use with annotated controllers.

public Validator
webFluxValidator()

Return a global Validator instance for example for validating @RequestBody method arguments.

public WebSocketHandlerAdapter
public DispatcherHandler
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

applicationContextback to summary
private ApplicationContext applicationContext
Annotations
@Nullable
blockingExecutionConfigurerback to summary
private BlockingExecutionConfigurer blockingExecutionConfigurer
Annotations
@Nullable
corsConfigurationsback to summary
private Map<String, CorsConfiguration> corsConfigurations
Annotations
@Nullable
jakartaValidatorPresentback to summary
private static final boolean jakartaValidatorPresent
pathMatchConfigurerback to summary
private PathMatchConfigurer pathMatchConfigurer
Annotations
@Nullable
viewResolverRegistryback to summary
private ViewResolverRegistry viewResolverRegistry
Annotations
@Nullable

Constructor Detail

WebFluxConfigurationSupportback to summary
public WebFluxConfigurationSupport()

Method Detail

addCorsMappingsback to summary
protected void addCorsMappings(CorsRegistry registry)

Override this method to configure cross-origin requests processing.

See Also
CorsRegistry
addFormattersback to summary
protected void addFormatters(FormatterRegistry registry)

Override this method to add custom Converter and/or Formatter delegates to the common FormattingConversionService.

See Also
webFluxConversionService()
addResourceHandlersback to summary
protected void addResourceHandlers(ResourceHandlerRegistry registry)

Override this method to add resource handlers for serving static resources.

See Also
ResourceHandlerRegistry
configureAbstractHandlerMappingback to summary
private void configureAbstractHandlerMapping(AbstractHandlerMapping mapping, PathMatchConfigurer configurer)
Annotations
@SuppressWarnings:deprecation
configureArgumentResolversback to summary
protected void configureArgumentResolvers(ArgumentResolverConfigurer configurer)

Configure resolvers for custom controller method arguments.

configureBlockingExecutionback to summary
protected void configureBlockingExecution(BlockingExecutionConfigurer configurer)

Override this method to configure blocking execution.

Since
6.1
configureContentTypeResolverback to summary
protected void configureContentTypeResolver(RequestedContentTypeResolverBuilder builder)

Override to configure how the requested content type is resolved.

configureHttpMessageCodecsback to summary
protected void configureHttpMessageCodecs(ServerCodecConfigurer configurer)

Override to configure the HTTP message readers and writers to use.

configurePathMatchingback to summary
public void configurePathMatching(PathMatchConfigurer configurer)

Override to configure path matching options.

configureViewResolversback to summary
protected void configureViewResolvers(ViewResolverRegistry registry)

Configure view resolution for supporting template engines.

See Also
ViewResolverRegistry
createLocaleContextResolverback to summary
protected LocaleContextResolver createLocaleContextResolver()

Override to plug a subclass of LocaleContextResolver.

createRequestMappingHandlerAdapterback to summary
protected RequestMappingHandlerAdapter createRequestMappingHandlerAdapter()

Override to plug a subclass of RequestMappingHandlerAdapter.

createRequestMappingHandlerMappingback to summary
protected RequestMappingHandlerMapping createRequestMappingHandlerMapping()

Override to plug a subclass of RequestMappingHandlerMapping.

createRouterFunctionMappingback to summary
protected RouterFunctionMapping createRouterFunctionMapping()

Override to plug a subclass of RouterFunctionMapping.

getApplicationContextback to summary
public final ApplicationContext getApplicationContext()
Annotations
@Nullable
getBlockingExecutionConfigurerback to summary
protected final BlockingExecutionConfigurer getBlockingExecutionConfigurer()

Callback to build and cache the BlockingExecutionConfigurer. This method is final, but subclasses can override configureBlockingExecution.

Since
6.1
getConfigurableWebBindingInitializerback to summary
protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer(FormattingConversionService webFluxConversionService, Validator webFluxValidator)

Return the ConfigurableWebBindingInitializer to use for initializing all WebDataBinder instances.

getCorsConfigurationsback to summary
protected final Map<String, CorsConfiguration> getCorsConfigurations()

Callback for building the global CORS configuration. This method is final. Use addCorsMappings(CorsRegistry) to customize the CORS config.

getMessageCodesResolverback to summary
protected MessageCodesResolver getMessageCodesResolver()

Override this method to provide a custom MessageCodesResolver.

Annotations
@Nullable
getPathMatchConfigurerback to summary
protected final PathMatchConfigurer getPathMatchConfigurer()

Callback for building the PathMatchConfigurer. This method is final, use configurePathMatching to customize path matching.

getValidatorback to summary
protected Validator getValidator()

Override this method to provide a custom Validator.

Annotations
@Nullable
getViewResolverRegistryback to summary
protected final ViewResolverRegistry getViewResolverRegistry()

Callback for building the ViewResolverRegistry. This method is final, use configureViewResolvers to customize view resolvers.

getWebSocketServiceback to summary
protected WebSocketService getWebSocketService()
Annotations
@Nullable
handlerFunctionAdapterback to summary
public HandlerFunctionAdapter handlerFunctionAdapter()
Annotations
@Bean
initWebSocketServiceback to summary
private WebSocketService initWebSocketService()
localeContextResolverback to summary
public LocaleContextResolver localeContextResolver()
Annotations
@Bean
requestMappingHandlerAdapterback to summary
public RequestMappingHandlerAdapter requestMappingHandlerAdapter(ReactiveAdapterRegistry reactiveAdapterRegistry, ServerCodecConfigurer serverCodecConfigurer, FormattingConversionService conversionService, Validator validator)
Annotations
@Bean
requestMappingHandlerMappingback to summary
public RequestMappingHandlerMapping requestMappingHandlerMapping(RequestedContentTypeResolver contentTypeResolver)
Annotations
@Bean
resourceHandlerMappingback to summary
public HandlerMapping resourceHandlerMapping(ResourceUrlProvider resourceUrlProvider)

Return a handler mapping ordered at Integer.MAX_VALUE-1 with mapped resource handlers. To configure resource handling, override addResourceHandlers.

Annotations
@Bean
resourceUrlProviderback to summary
public ResourceUrlProvider resourceUrlProvider()
Annotations
@Bean
responseBodyResultHandlerback to summary
public ResponseBodyResultHandler responseBodyResultHandler(ReactiveAdapterRegistry reactiveAdapterRegistry, ServerCodecConfigurer serverCodecConfigurer, RequestedContentTypeResolver contentTypeResolver)
Annotations
@Bean
responseEntityResultHandlerback to summary
public ResponseEntityResultHandler responseEntityResultHandler(ReactiveAdapterRegistry reactiveAdapterRegistry, ServerCodecConfigurer serverCodecConfigurer, RequestedContentTypeResolver contentTypeResolver)
Annotations
@Bean
responseStatusExceptionHandlerback to summary
public WebExceptionHandler responseStatusExceptionHandler()
Annotations
@Bean
@Order:0
routerFunctionMappingback to summary
public RouterFunctionMapping routerFunctionMapping(ServerCodecConfigurer serverCodecConfigurer)
Annotations
@Bean
serverCodecConfigurerback to summary
public ServerCodecConfigurer serverCodecConfigurer()

Return the configurer for HTTP message readers and writers.

Use configureHttpMessageCodecs(ServerCodecConfigurer) to configure the readers and writers.

Annotations
@Bean
serverResponseResultHandlerback to summary
public ServerResponseResultHandler serverResponseResultHandler(ServerCodecConfigurer serverCodecConfigurer)
Annotations
@Bean
setApplicationContextback to summary
public void setApplicationContext(ApplicationContext applicationContext)

Implements org.springframework.context.ApplicationContextAware.setApplicationContext.

Doc from org.springframework.context.ApplicationContextAware.setApplicationContext.

Set the ApplicationContext that this object runs in. Normally this call will be used to initialize the object.

Invoked after population of normal bean properties but before an init callback such as org.springframework.beans.factory.InitializingBean#afterPropertiesSet() or a custom init-method. Invoked after ResourceLoaderAware#setResourceLoader, ApplicationEventPublisherAware#setApplicationEventPublisher and MessageSourceAware, if applicable.

Parameters
applicationContext:ApplicationContext

the ApplicationContext object to be used by this object

Annotations
@Override
simpleHandlerAdapterback to summary
public SimpleHandlerAdapter simpleHandlerAdapter()
Annotations
@Bean
viewResolutionResultHandlerback to summary
public ViewResolutionResultHandler viewResolutionResultHandler(ReactiveAdapterRegistry reactiveAdapterRegistry, RequestedContentTypeResolver contentTypeResolver)
Annotations
@Bean
webFluxAdapterRegistryback to summary
public ReactiveAdapterRegistry webFluxAdapterRegistry()

Return a ReactiveAdapterRegistry to adapting reactive types.

Annotations
@Bean
webFluxContentTypeResolverback to summary
public RequestedContentTypeResolver webFluxContentTypeResolver()
Annotations
@Bean
webFluxConversionServiceback to summary
public FormattingConversionService webFluxConversionService()

Return a FormattingConversionService for use with annotated controllers.

See addFormatters as an alternative to overriding this method.

Annotations
@Bean
webFluxValidatorback to summary
public Validator webFluxValidator()

Return a global Validator instance for example for validating @RequestBody method arguments.

Delegates to getValidator() first. If that returns null checks the classpath for the presence of a JSR-303 implementations before creating a OptionalValidatorFactoryBean. If a JSR-303 implementation is not available, a "no-op" Validator is returned.

Annotations
@Bean
webFluxWebSocketHandlerAdapterback to summary
public WebSocketHandlerAdapter webFluxWebSocketHandlerAdapter()
Annotations
@Bean
webHandlerback to summary
public DispatcherHandler webHandler()
Annotations
@Bean
org.springframework.web.reactive.config back to summary

private final Class WebFluxConfigurationSupport.EmptyHandlerMapping

extends AbstractHandlerMapping
Class Inheritance

Field Summary

Inherited from org.springframework.web.reactive.handler.AbstractHandlerMapping:
mappingsLogger

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Mono<Object>
getHandlerInternal(ServerWebExchange
current exchange
exchange
)

Implements abstract org.springframework.web.reactive.handler.AbstractHandlerMapping.getHandlerInternal.

Look up a handler for the given request, returning an empty Mono if no specific one is found.

Inherited from org.springframework.web.reactive.handler.AbstractHandlerMapping:
formatMappingNamegetCorsConfigurationgetCorsProcessorgetHandlergetOrdergetPathPatternParserhasCorsConfigurationSourcesetBeanNamesetCorsConfigurationssetCorsConfigurationSourcesetCorsProcessorsetOrdersetUseCaseSensitiveMatchsetUseTrailingSlashMatch

Constructor Detail

EmptyHandlerMappingback to summary
private EmptyHandlerMapping()

Method Detail

getHandlerInternalback to summary
public Mono<Object> getHandlerInternal(ServerWebExchange exchange)

Implements abstract org.springframework.web.reactive.handler.AbstractHandlerMapping.getHandlerInternal.

Doc from org.springframework.web.reactive.handler.AbstractHandlerMapping.getHandlerInternal.

Look up a handler for the given request, returning an empty Mono if no specific one is found. This method is called by getHandler.

On CORS pre-flight requests this method should return a match not for the pre-flight request but for the expected actual request based on the URL path, the HTTP methods from the "Access-Control-Request-Method" header, and the headers from the "Access-Control-Request-Headers" header.

Parameters
exchange:ServerWebExchange

current exchange

Returns:Mono<Object>

Mono for the matching handler, if any

Annotations
@Override
org.springframework.web.reactive.config back to summary

private final Class WebFluxConfigurationSupport.NoOpValidator

extends Object
implements Validator
Class Inheritance
  • java.lang.Object
  • org.springframework.web.reactive.config.WebFluxConfigurationSupport.NoOpValidator
All Implemented Interfaces
org.springframework.validation.Validator

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean
supports(Class<?>
the Class that this Validator is being asked if it can validate
clazz
)

Implements org.springframework.validation.Validator.supports.

Can this Validator validate instances of the supplied clazz?

public void
validate(Object
the object that is to be validated
target
,
Errors
contextual state about the validation process
errors
)

Implements org.springframework.validation.Validator.validate.

Validate the given target object which must be of a Class for which the supports(Class) method typically has returned (or would return) true.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

NoOpValidatorback to summary
private NoOpValidator()

Method Detail

supportsback to summary
public boolean supports(Class<?> clazz)

Implements org.springframework.validation.Validator.supports.

Doc from org.springframework.validation.Validator.supports.

Can this Validator validate instances of the supplied clazz?

This method is typically implemented like so:

return Foo.class.isAssignableFrom(clazz);
(Where Foo is the class (or superclass) of the actual object instance that is to be validated.)
Parameters
clazz:Class<?>

the Class that this Validator is being asked if it can validate

Returns:boolean

true if this Validator can indeed validate instances of the supplied clazz

Annotations
@Override
validateback to summary
public void validate(Object target, Errors errors)

Implements org.springframework.validation.Validator.validate.

Doc from org.springframework.validation.Validator.validate.

Validate the given target object which must be of a Class for which the supports(Class) method typically has returned (or would return) true.

The supplied errors instance can be used to report any resulting validation errors, typically as part of a larger binding process which this validator is meant to participate in. Binding errors have typically been pre-registered with the errors instance before this invocation already.

Parameters
target:Object

the object that is to be validated

errors:Errors

contextual state about the validation process

Annotations
@Override
org.springframework.web.reactive.config back to summary

private final Class WebFluxConfigurationSupport.NoUpgradeStrategyWebSocketService

extends Object
implements WebSocketService
Class Inheritance
  • java.lang.Object
  • org.springframework.web.reactive.config.WebFluxConfigurationSupport.NoUpgradeStrategyWebSocketService
All Implemented Interfaces
org.springframework.web.reactive.socket.server.WebSocketService

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Mono<Void>
handleRequest(ServerWebExchange
the current exchange
exchange
,
WebSocketHandler
handler for WebSocket session
webSocketHandler
)

Implements org.springframework.web.reactive.socket.server.WebSocketService.handleRequest.

Handle the request with the given WebSocketHandler.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

NoUpgradeStrategyWebSocketServiceback to summary
private NoUpgradeStrategyWebSocketService()

Method Detail

handleRequestback to summary
public Mono<Void> handleRequest(ServerWebExchange exchange, WebSocketHandler webSocketHandler)

Implements org.springframework.web.reactive.socket.server.WebSocketService.handleRequest.

Doc from org.springframework.web.reactive.socket.server.WebSocketService.handleRequest.

Handle the request with the given WebSocketHandler.

Parameters
exchange:ServerWebExchange

the current exchange

webSocketHandler:WebSocketHandler

handler for WebSocket session

Returns:Mono<Void>

a Mono<Void> that completes when application handling of the WebSocket session completes.

Annotations
@Override