public class WebFluxConfigurationSupport extends java.lang.Object implements ApplicationContextAware
Import directly or extend and override protected methods to customize.
Modifier and Type | Class and Description |
---|---|
private static class |
WebFluxConfigurationSupport.EmptyHandlerMapping |
private static class |
WebFluxConfigurationSupport.NoOpValidator |
Modifier and Type | Field and Description |
---|---|
private ApplicationContext |
applicationContext |
private java.util.Map<java.lang.String,CorsConfiguration> |
corsConfigurations |
private static boolean |
jackson2Present |
private static boolean |
jaxb2Present |
private java.util.List<HttpMessageReader<?>> |
messageReaders |
private java.util.List<HttpMessageWriter<?>> |
messageWriters |
private PathMatchConfigurer |
pathMatchConfigurer |
Constructor and Description |
---|
WebFluxConfigurationSupport() |
Modifier and Type | Method and Description |
---|---|
protected void |
addArgumentResolvers(java.util.List<HandlerMethodArgumentResolver> resolvers)
Provide custom argument resolvers without overriding the built-in ones.
|
protected void |
addCorsMappings(CorsRegistry registry)
Override this method to configure cross origin requests processing.
|
protected void |
addDefaultHttpMessageReaders(java.util.List<HttpMessageReader<?>> readers)
Adds default converters that sub-classes can call from
configureMessageReaders(List) for byte[] ,
ByteBuffer , String , Resource , JAXB2, and Jackson
(if present on the classpath). |
protected void |
addDefaultHttpMessageWriters(java.util.List<HttpMessageWriter<?>> writers)
Adds default converters that sub-classes can call from
configureMessageWriters(List) . |
protected void |
addFormatters(FormatterRegistry registry)
|
protected void |
addResourceHandlers(ResourceHandlerRegistry registry)
Override this method to add resource handlers for serving static resources.
|
protected void |
configureContentTypeResolver(RequestedContentTypeResolverBuilder builder)
Override to configure how the requested content type is resolved.
|
protected void |
configureMessageReaders(java.util.List<HttpMessageReader<?>> messageReaders)
Override to configure the message readers to use for decoding
controller method arguments.
|
protected void |
configureMessageWriters(java.util.List<HttpMessageWriter<?>> messageWriters)
Override to configure the message writers to use for encoding
return values.
|
void |
configurePathMatching(PathMatchConfigurer configurer)
Override to configure path matching options.
|
protected void |
configureViewResolvers(ViewResolverRegistry registry)
Configure view resolution for supporting template engines.
|
protected RequestMappingHandlerAdapter |
createRequestMappingHandlerAdapter()
Override to plug a sub-class of
RequestMappingHandlerAdapter . |
protected RequestMappingHandlerMapping |
createRequestMappingHandlerMapping()
Override to plug a sub-class of
RequestMappingHandlerMapping . |
protected void |
extendMessageReaders(java.util.List<HttpMessageReader<?>> messageReaders)
Override this to modify the list of message readers after it has been
configured, for example to add some in addition to the default ones.
|
protected void |
extendMessageWriters(java.util.List<HttpMessageWriter<?>> messageWriters)
Override this to modify the list of message writers after it has been
configured, for example to add some in addition to the default ones.
|
protected ApplicationContext |
getApplicationContext() |
protected ConfigurableWebBindingInitializer |
getConfigurableWebBindingInitializer()
Return the
ConfigurableWebBindingInitializer to use for
initializing all WebDataBinder instances. |
protected java.util.Map<java.lang.String,CorsConfiguration> |
getCorsConfigurations()
Callback for building the global CORS configuration.
|
protected java.util.Map<java.lang.String,MediaType> |
getDefaultMediaTypeMappings()
Override to configure media type mappings.
|
protected MessageCodesResolver |
getMessageCodesResolver()
Override this method to provide a custom
MessageCodesResolver . |
protected java.util.List<HttpMessageReader<?>> |
getMessageReaders()
Main method to access message readers to use for decoding
controller method arguments with.
|
protected java.util.List<HttpMessageWriter<?>> |
getMessageWriters()
Main method to access message writers to use for encoding return values.
|
protected PathMatchConfigurer |
getPathMatchConfigurer()
Callback for building the
PathMatchConfigurer . |
protected Validator |
getValidator()
Override this method to provide a custom
Validator . |
RequestMappingHandlerAdapter |
requestMappingHandlerAdapter() |
RequestMappingHandlerMapping |
requestMappingHandlerMapping() |
HandlerMapping |
resourceHandlerMapping()
Return a handler mapping ordered at Integer.MAX_VALUE-1 with mapped
resource handlers.
|
ResponseBodyResultHandler |
responseBodyResultHandler() |
ResponseEntityResultHandler |
responseEntityResultHandler() |
WebExceptionHandler |
responseStatusExceptionHandler() |
void |
setApplicationContext(ApplicationContext applicationContext)
Set the ApplicationContext that this object runs in.
|
SimpleHandlerAdapter |
simpleHandlerAdapter() |
ViewResolutionResultHandler |
viewResolutionResultHandler() |
ReactiveAdapterRegistry |
webFluxAdapterRegistry()
Return a
ReactiveAdapterRegistry to adapting reactive types. |
CompositeContentTypeResolver |
webFluxContentTypeResolver() |
FormattingConversionService |
webFluxConversionService() |
Validator |
webFluxValidator()
Return a global
Validator instance for example for validating
@RequestBody method arguments. |
DispatcherHandler |
webHandler() |
private static final boolean jackson2Present
private static final boolean jaxb2Present
private java.util.Map<java.lang.String,CorsConfiguration> corsConfigurations
private PathMatchConfigurer pathMatchConfigurer
private java.util.List<HttpMessageReader<?>> messageReaders
private java.util.List<HttpMessageWriter<?>> messageWriters
private ApplicationContext applicationContext
public void setApplicationContext(ApplicationContext applicationContext)
ApplicationContextAware
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.
setApplicationContext
in interface ApplicationContextAware
applicationContext
- the ApplicationContext object to be used by this objectBeanInitializationException
protected ApplicationContext getApplicationContext()
@Bean public DispatcherHandler webHandler()
@Bean @Order(value=0) public WebExceptionHandler responseStatusExceptionHandler()
@Bean public RequestMappingHandlerMapping requestMappingHandlerMapping()
protected RequestMappingHandlerMapping createRequestMappingHandlerMapping()
RequestMappingHandlerMapping
.@Bean public CompositeContentTypeResolver webFluxContentTypeResolver()
protected java.util.Map<java.lang.String,MediaType> getDefaultMediaTypeMappings()
protected void configureContentTypeResolver(RequestedContentTypeResolverBuilder builder)
protected final java.util.Map<java.lang.String,CorsConfiguration> getCorsConfigurations()
addCorsMappings(CorsRegistry)
to customize the CORS conifg.protected void addCorsMappings(CorsRegistry registry)
CorsRegistry
protected final PathMatchConfigurer getPathMatchConfigurer()
PathMatchConfigurer
. This method is
final, use configurePathMatching(org.springframework.web.reactive.config.PathMatchConfigurer)
to customize path matching.public void configurePathMatching(PathMatchConfigurer configurer)
@Bean public HandlerMapping resourceHandlerMapping()
addResourceHandlers(org.springframework.web.reactive.config.ResourceHandlerRegistry)
.protected void addResourceHandlers(ResourceHandlerRegistry registry)
ResourceHandlerRegistry
@Bean public RequestMappingHandlerAdapter requestMappingHandlerAdapter()
protected RequestMappingHandlerAdapter createRequestMappingHandlerAdapter()
RequestMappingHandlerAdapter
.protected void addArgumentResolvers(java.util.List<HandlerMethodArgumentResolver> resolvers)
protected final java.util.List<HttpMessageReader<?>> getMessageReaders()
Use configureMessageReaders(java.util.List<org.springframework.http.codec.HttpMessageReader<?>>)
to configure the list or
extendMessageReaders(java.util.List<org.springframework.http.codec.HttpMessageReader<?>>)
to add in addition to the default ones.
protected void configureMessageReaders(java.util.List<HttpMessageReader<?>> messageReaders)
If no message readres are specified, default will be added via
addDefaultHttpMessageReaders(java.util.List<org.springframework.http.codec.HttpMessageReader<?>>)
.
messageReaders
- a list to add message readers to, initially an emptyprotected final void addDefaultHttpMessageReaders(java.util.List<HttpMessageReader<?>> readers)
configureMessageReaders(List)
for byte[]
,
ByteBuffer
, String
, Resource
, JAXB2, and Jackson
(if present on the classpath).protected void extendMessageReaders(java.util.List<HttpMessageReader<?>> messageReaders)
protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer()
ConfigurableWebBindingInitializer
to use for
initializing all WebDataBinder
instances.@Bean public FormattingConversionService webFluxConversionService()
protected void addFormatters(FormatterRegistry registry)
@Bean public ReactiveAdapterRegistry webFluxAdapterRegistry()
ReactiveAdapterRegistry
to adapting reactive types.@Bean public Validator webFluxValidator()
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.
protected MessageCodesResolver getMessageCodesResolver()
MessageCodesResolver
.@Bean public SimpleHandlerAdapter simpleHandlerAdapter()
@Bean public ResponseEntityResultHandler responseEntityResultHandler()
@Bean public ResponseBodyResultHandler responseBodyResultHandler()
protected final java.util.List<HttpMessageWriter<?>> getMessageWriters()
Use configureMessageWriters(List)
to configure the list or
extendMessageWriters(List)
to add in addition to the default ones.
protected void configureMessageWriters(java.util.List<HttpMessageWriter<?>> messageWriters)
If no message readers are specified, default will be added via
addDefaultHttpMessageWriters(java.util.List<org.springframework.http.codec.HttpMessageWriter<?>>)
.
messageWriters
- a list to add message writers to, initially an emptyprotected final void addDefaultHttpMessageWriters(java.util.List<HttpMessageWriter<?>> writers)
configureMessageWriters(List)
.protected void extendMessageWriters(java.util.List<HttpMessageWriter<?>> messageWriters)
@Bean public ViewResolutionResultHandler viewResolutionResultHandler()
protected void configureViewResolvers(ViewResolverRegistry registry)
ViewResolverRegistry