org.springframework.web.reactive.config

## Class WebFluxConfigurationSupport

- java.lang.Object
- - org.springframework.web.reactive.config.WebFluxConfigurationSupport

- All Implemented Interfaces:
    Aware, ApplicationContextAware
  Direct Known Subclasses:
    DelegatingWebFluxConfiguration

      public class WebFluxConfigurationSupport
      extends Object
      implements ApplicationContextAware

  The main class for Spring WebFlux configuration.

  Import directly or extend and override protected methods to customize.

  Since:
    5.0
  Author:
    Rossen Stoyanchev, Brian Clozel

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `WebFluxConfigurationSupport()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method 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.
    `protected void` | `configureArgumentResolvers(ArgumentResolverConfigurer configurer)` Configure resolvers for custom controller method arguments.
    `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.
    `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` | `createRequestMappingHandlerAdapter()` Override to plug a subclass of `RequestMappingHandlerAdapter`.
    `protected RequestMappingHandlerMapping` | `createRequestMappingHandlerMapping()` Override to plug a subclass of `RequestMappingHandlerMapping`.
    `protected RouterFunctionMapping` | `createRouterFunctionMapping()` Override to plug a subclass of `RouterFunctionMapping`.
    `ApplicationContext` | `getApplicationContext()`
    `protected ConfigurableWebBindingInitializer` | `getConfigurableWebBindingInitializer(FormattingConversionService webFluxConversionService, Validator webFluxValidator)` Return the `ConfigurableWebBindingInitializer` to use for initializing all `WebDataBinder` instances.
    `protected Map<String,CorsConfiguration>` | `getCorsConfigurations()` Callback for building the global CORS configuration.
    `protected MessageCodesResolver` | `getMessageCodesResolver()` Override this method to provide a custom `MessageCodesResolver`.
    `protected PathMatchConfigurer` | `getPathMatchConfigurer()` Callback for building the `PathMatchConfigurer`.
    `protected Validator` | `getValidator()` Override this method to provide a custom `Validator`.
    `protected ViewResolverRegistry` | `getViewResolverRegistry()` Callback for building the `ViewResolverRegistry`.
    `protected WebSocketService` | `getWebSocketService()`
    `HandlerFunctionAdapter` | `handlerFunctionAdapter()`
    `LocaleContextResolver` | `localeContextResolver()`
    `RequestMappingHandlerAdapter` | `requestMappingHandlerAdapter(ReactiveAdapterRegistry reactiveAdapterRegistry, ServerCodecConfigurer serverCodecConfigurer, FormattingConversionService conversionService, Validator validator)`
    `RequestMappingHandlerMapping` | `requestMappingHandlerMapping(RequestedContentTypeResolver contentTypeResolver)`
    `HandlerMapping` | `resourceHandlerMapping(ResourceUrlProvider resourceUrlProvider)` Return a handler mapping ordered at Integer.MAX_VALUE-1 with mapped resource handlers.
    `ResourceUrlProvider` | `resourceUrlProvider()`
    `ResponseBodyResultHandler` | `responseBodyResultHandler(ReactiveAdapterRegistry reactiveAdapterRegistry, ServerCodecConfigurer serverCodecConfigurer, RequestedContentTypeResolver contentTypeResolver)`
    `ResponseEntityResultHandler` | `responseEntityResultHandler(ReactiveAdapterRegistry reactiveAdapterRegistry, ServerCodecConfigurer serverCodecConfigurer, RequestedContentTypeResolver contentTypeResolver)`
    `WebExceptionHandler` | `responseStatusExceptionHandler()`
    `RouterFunctionMapping` | `routerFunctionMapping(ServerCodecConfigurer serverCodecConfigurer)`
    `ServerCodecConfigurer` | `serverCodecConfigurer()` Return the configurer for HTTP message readers and writers.
    `ServerResponseResultHandler` | `serverResponseResultHandler(ServerCodecConfigurer serverCodecConfigurer)`
    `void` | `setApplicationContext(ApplicationContext applicationContext)` Set the ApplicationContext that this object runs in.
    `SimpleHandlerAdapter` | `simpleHandlerAdapter()`
    `ViewResolutionResultHandler` | `viewResolutionResultHandler(ReactiveAdapterRegistry reactiveAdapterRegistry, RequestedContentTypeResolver contentTypeResolver)`
    `ReactiveAdapterRegistry` | `webFluxAdapterRegistry()` Return a `ReactiveAdapterRegistry` to adapting reactive types.
    `RequestedContentTypeResolver` | `webFluxContentTypeResolver()`
    `FormattingConversionService` | `webFluxConversionService()` Return a `FormattingConversionService` for use with annotated controllers.
    `Validator` | `webFluxValidator()` Return a global `Validator` instance for example for validating `@RequestBody` method arguments.
    `WebSocketHandlerAdapter` | `webFluxWebSocketHandlerAdapter()`
    `DispatcherHandler` | `webHandler()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### WebFluxConfigurationSupport

          public WebFluxConfigurationSupport()

  - ### Method Detail

    - #### setApplicationContext

          public void setApplicationContext(@Nullable
                                            ApplicationContext applicationContext)

      Description copied from interface: `ApplicationContextAware`
      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 `InitializingBean.afterPropertiesSet()` or a custom init-method. Invoked after `ResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader)`, `ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)` and `MessageSourceAware`, if applicable.

      Specified by:
        `setApplicationContext` in interface `ApplicationContextAware`
      Parameters:
        `applicationContext` - the ApplicationContext object to be used by this object
      See Also:
        `BeanInitializationException`

    - #### getApplicationContext

          @Nullable
          public final ApplicationContext getApplicationContext()

    - #### webHandler

          @Bean
          public DispatcherHandler webHandler()

    - #### responseStatusExceptionHandler

          @Bean
           @Order(value=0)
          public WebExceptionHandler responseStatusExceptionHandler()

    - #### requestMappingHandlerMapping

          @Bean
          public RequestMappingHandlerMapping requestMappingHandlerMapping(@Qualifier(value="webFluxContentTypeResolver")
                                                                                 RequestedContentTypeResolver contentTypeResolver)

    - #### createRequestMappingHandlerMapping

          protected RequestMappingHandlerMapping createRequestMappingHandlerMapping()

      Override to plug a subclass of `RequestMappingHandlerMapping`.

    - #### webFluxContentTypeResolver

          @Bean
          public RequestedContentTypeResolver webFluxContentTypeResolver()

    - #### configureContentTypeResolver

          protected void configureContentTypeResolver(RequestedContentTypeResolverBuilder builder)

      Override to configure how the requested content type is resolved.

    - #### getCorsConfigurations

          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.

    - #### addCorsMappings

          protected void addCorsMappings(CorsRegistry registry)

      Override this method to configure cross-origin requests processing.
      See Also:
        `CorsRegistry`

    - #### getPathMatchConfigurer

          protected final PathMatchConfigurer getPathMatchConfigurer()

      Callback for building the `PathMatchConfigurer`. This method is final, use `configurePathMatching(org.springframework.web.reactive.config.PathMatchConfigurer)` to customize path matching.

    - #### configurePathMatching

          public void configurePathMatching(PathMatchConfigurer configurer)

      Override to configure path matching options.

    - #### routerFunctionMapping

          @Bean
          public RouterFunctionMapping routerFunctionMapping(ServerCodecConfigurer serverCodecConfigurer)

    - #### createRouterFunctionMapping

          protected RouterFunctionMapping createRouterFunctionMapping()

      Override to plug a subclass of `RouterFunctionMapping`.

    - #### resourceHandlerMapping

          @Bean
          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(org.springframework.web.reactive.config.ResourceHandlerRegistry)`.

    - #### resourceUrlProvider

          @Bean
          public ResourceUrlProvider resourceUrlProvider()

    - #### addResourceHandlers

          protected void addResourceHandlers(ResourceHandlerRegistry registry)

      Override this method to add resource handlers for serving static resources.
      See Also:
        `ResourceHandlerRegistry`

    - #### requestMappingHandlerAdapter

          @Bean
          public RequestMappingHandlerAdapter requestMappingHandlerAdapter(@Qualifier(value="webFluxAdapterRegistry")
                                                                                 ReactiveAdapterRegistry reactiveAdapterRegistry,
                                                                                 ServerCodecConfigurer serverCodecConfigurer,
                                                                                 @Qualifier(value="webFluxConversionService")
                                                                                 FormattingConversionService conversionService,
                                                                                 @Qualifier(value="webFluxValidator")
                                                                                 Validator validator)

    - #### createRequestMappingHandlerAdapter

          protected RequestMappingHandlerAdapter createRequestMappingHandlerAdapter()

      Override to plug a subclass of `RequestMappingHandlerAdapter`.

    - #### configureArgumentResolvers

          protected void configureArgumentResolvers(ArgumentResolverConfigurer configurer)

      Configure resolvers for custom controller method arguments.

    - #### serverCodecConfigurer

          @Bean
          public ServerCodecConfigurer serverCodecConfigurer()

      Return the configurer for HTTP message readers and writers.

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

    - #### createLocaleContextResolver

          protected LocaleContextResolver createLocaleContextResolver()

      Override to plug a subclass of `LocaleContextResolver`.

    - #### localeContextResolver

          @Bean
          public LocaleContextResolver localeContextResolver()

    - #### configureHttpMessageCodecs

          protected void configureHttpMessageCodecs(ServerCodecConfigurer configurer)

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

    - #### getConfigurableWebBindingInitializer

          protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer(FormattingConversionService webFluxConversionService,
                                                                                           Validator webFluxValidator)

      Return the `ConfigurableWebBindingInitializer` to use for initializing all `WebDataBinder` instances.

    - #### webFluxConversionService

          @Bean
          public FormattingConversionService webFluxConversionService()

      Return a `FormattingConversionService` for use with annotated controllers.

      See `addFormatters(org.springframework.format.FormatterRegistry)` as an alternative to overriding this method.

    - #### addFormatters

          protected void addFormatters(FormatterRegistry registry)

      Override this method to add custom `Converter` and/or `Formatter` delegates to the common `FormattingConversionService`.
      See Also:
        `webFluxConversionService()`

    - #### webFluxAdapterRegistry

          @Bean
          public ReactiveAdapterRegistry webFluxAdapterRegistry()

      Return a `ReactiveAdapterRegistry` to adapting reactive types.

    - #### webFluxValidator

          @Bean
          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.

    - #### getValidator

          @Nullable
          protected Validator getValidator()

      Override this method to provide a custom `Validator`.

    - #### getMessageCodesResolver

          @Nullable
          protected MessageCodesResolver getMessageCodesResolver()

      Override this method to provide a custom `MessageCodesResolver`.

    - #### handlerFunctionAdapter

          @Bean
          public HandlerFunctionAdapter handlerFunctionAdapter()

    - #### simpleHandlerAdapter

          @Bean
          public SimpleHandlerAdapter simpleHandlerAdapter()

    - #### webFluxWebSocketHandlerAdapter

          @Bean
          public WebSocketHandlerAdapter webFluxWebSocketHandlerAdapter()

    - #### getWebSocketService

          @Nullable
          protected WebSocketService getWebSocketService()

    - #### responseEntityResultHandler

          @Bean
          public ResponseEntityResultHandler responseEntityResultHandler(@Qualifier(value="webFluxAdapterRegistry")
                                                                               ReactiveAdapterRegistry reactiveAdapterRegistry,
                                                                               ServerCodecConfigurer serverCodecConfigurer,
                                                                               @Qualifier(value="webFluxContentTypeResolver")
                                                                               RequestedContentTypeResolver contentTypeResolver)

    - #### responseBodyResultHandler

          @Bean
          public ResponseBodyResultHandler responseBodyResultHandler(@Qualifier(value="webFluxAdapterRegistry")
                                                                           ReactiveAdapterRegistry reactiveAdapterRegistry,
                                                                           ServerCodecConfigurer serverCodecConfigurer,
                                                                           @Qualifier(value="webFluxContentTypeResolver")
                                                                           RequestedContentTypeResolver contentTypeResolver)

    - #### viewResolutionResultHandler

          @Bean
          public ViewResolutionResultHandler viewResolutionResultHandler(@Qualifier(value="webFluxAdapterRegistry")
                                                                               ReactiveAdapterRegistry reactiveAdapterRegistry,
                                                                               @Qualifier(value="webFluxContentTypeResolver")
                                                                               RequestedContentTypeResolver contentTypeResolver)

    - #### serverResponseResultHandler

          @Bean
          public ServerResponseResultHandler serverResponseResultHandler(ServerCodecConfigurer serverCodecConfigurer)

    - #### getViewResolverRegistry

          protected final ViewResolverRegistry getViewResolverRegistry()

      Callback for building the `ViewResolverRegistry`. This method is final, use `configureViewResolvers(org.springframework.web.reactive.config.ViewResolverRegistry)` to customize view resolvers.

    - #### configureViewResolvers

          protected void configureViewResolvers(ViewResolverRegistry registry)

      Configure view resolution for supporting template engines.
      See Also:
        `ViewResolverRegistry`