#838 - Improved registration of BeanPostProcessor implementations.
The BeanPostProcessor implementations in (WebMVC|WebFlux)HateoasConfiguration are now declared as static methods and their dependencies use ObjectProvider wrapper types to prevent the need to prematurely initialize the entire configuration class which triggered the creation of a lot of downstream dependencies which were then reported as ineligible for post processing themselves.
This commit is contained in:
@@ -54,7 +54,8 @@ class WebFluxHateoasConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
HypermediaWebClientBeanPostProcessor webClientBeanPostProcessor(WebClientConfigurer configurer) {
|
||||
static HypermediaWebClientBeanPostProcessor webClientBeanPostProcessor(
|
||||
ObjectProvider<WebClientConfigurer> configurer) {
|
||||
return new HypermediaWebClientBeanPostProcessor(configurer);
|
||||
}
|
||||
|
||||
@@ -85,7 +86,7 @@ class WebFluxHateoasConfiguration {
|
||||
@RequiredArgsConstructor
|
||||
static class HypermediaWebClientBeanPostProcessor implements BeanPostProcessor {
|
||||
|
||||
private final WebClientConfigurer configurer;
|
||||
private final ObjectProvider<WebClientConfigurer> configurer;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
@@ -95,7 +96,7 @@ class WebFluxHateoasConfiguration {
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
|
||||
if (bean instanceof WebClient) {
|
||||
return this.configurer.registerHypermediaTypes((WebClient) bean);
|
||||
return this.configurer.getObject().registerHypermediaTypes((WebClient) bean);
|
||||
}
|
||||
|
||||
return bean;
|
||||
|
||||
@@ -52,7 +52,8 @@ class WebMvcHateoasConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
HypermediaRestTemplateBeanPostProcessor restTemplateBeanPostProcessor(HypermediaWebMvcConfigurer configurer) {
|
||||
static HypermediaRestTemplateBeanPostProcessor restTemplateBeanPostProcessor(
|
||||
ObjectProvider<HypermediaWebMvcConfigurer> configurer) {
|
||||
return new HypermediaRestTemplateBeanPostProcessor(configurer);
|
||||
}
|
||||
|
||||
@@ -100,7 +101,7 @@ class WebMvcHateoasConfiguration {
|
||||
@RequiredArgsConstructor
|
||||
static class HypermediaRestTemplateBeanPostProcessor implements BeanPostProcessor {
|
||||
|
||||
private final HypermediaWebMvcConfigurer configurer;
|
||||
private final ObjectProvider<HypermediaWebMvcConfigurer> configurer;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
@@ -113,7 +114,7 @@ class WebMvcHateoasConfiguration {
|
||||
return bean;
|
||||
}
|
||||
|
||||
configurer.extendMessageConverters(((RestTemplate) bean).getMessageConverters());
|
||||
configurer.getObject().extendMessageConverters(((RestTemplate) bean).getMessageConverters());
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user