@Bean public SmartInitializingSingleton fluxRequestMappingHandlerAdapterProcessor( RequestMappingHandlerAdapter adapter, FluxHandlerMethodArgumentResolver resolver) { return new SmartInitializingSingleton() { @Override public void afterSingletonsInstantiated() { List<HandlerMethodArgumentResolver> resolvers = new ArrayList<>( adapter.getArgumentResolvers()); resolvers.add(0, resolver); adapter.setArgumentResolvers(resolvers); if (!ClassUtils.isPresent("org.springframework.core.ReactiveAdapter", null)) { List<HandlerMethodReturnValueHandler> handlers = new ArrayList<>( adapter.getReturnValueHandlers()); handlers.add(0, context.getBean(FluxReturnValueHandler.class)); adapter.setReturnValueHandlers(handlers); } } }; }
@Bean public SmartInitializingSingleton loadBalancedWebClientInitializer( final List<WebClientCustomizer> customizers) { return () -> { for (WebClient.Builder webClientBuilder : getBuilders()) { for (WebClientCustomizer customizer : customizers) { customizer.customize(webClientBuilder); } } }; }
@Bean public SmartInitializingSingleton loadBalancedRestTemplateInitializerDeprecated( final ObjectProvider<List<RestTemplateCustomizer>> restTemplateCustomizers) { return () -> restTemplateCustomizers.ifAvailable(customizers -> { for (RestTemplate restTemplate : LoadBalancerAutoConfiguration.this.restTemplates) { for (RestTemplateCustomizer customizer : customizers) { customizer.customize(restTemplate); } } }); }
@Bean public SmartInitializingSingleton loadBalancedAsyncRestTemplateInitializer( final List<AsyncRestTemplateCustomizer> customizers) { return new SmartInitializingSingleton() { @Override public void afterSingletonsInstantiated() { for (AsyncRestTemplate restTemplate : AsyncRestTemplateCustomizerConfig.this.restTemplates) { for (AsyncRestTemplateCustomizer customizer : customizers) { customizer.customize(restTemplate); } } } }; }