Java 类org.springframework.beans.factory.SmartInitializingSingleton 实例源码

项目:spring-cloud-function    文件:ReactorAutoConfiguration.java   
@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);
            }
        }

    };
}
项目:spring-cloud-commons    文件:ReactiveLoadBalancerAutoConfiguration.java   
@Bean
public SmartInitializingSingleton loadBalancedWebClientInitializer(
        final List<WebClientCustomizer> customizers) {
    return () -> {
        for (WebClient.Builder webClientBuilder : getBuilders()) {
            for (WebClientCustomizer customizer : customizers) {
                customizer.customize(webClientBuilder);
            }
        }
    };
}
项目:spring-cloud-commons    文件:LoadBalancerAutoConfiguration.java   
@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);
               }
           }
       });
}
项目:spring-cloud-commons    文件:AsyncLoadBalancerAutoConfiguration.java   
@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);
                }
            }
        }
    };
}