org.springframework.beans.factory.SmartInitializingSingleton Java Examples
The following examples show how to use
org.springframework.beans.factory.SmartInitializingSingleton.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AsyncRestTemplateCircuitBreakerAutoConfiguration.java From spring-cloud-formula with Apache License 2.0 | 6 votes |
@Bean public SmartInitializingSingleton loadBalancedAsyncRestTemplateInitializer2( final List<AsyncRestTemplateCustomizer> customizers) { return new SmartInitializingSingleton() { @Override public void afterSingletonsInstantiated() { logger.info("init AsyncRestTemplateCircuitBreaker start"); for (AsyncRestTemplate restTemplate : AsyncRestTemplateCircuitBreakerAutoConfiguration.this .restTemplates) { AsyncRestTemplateCircuitInterceptor interceptor = new AsyncRestTemplateCircuitInterceptor(circuitBreakerCore); logger.info("add AsyncRestTemplateCircuitInterceptor first"); List<AsyncClientHttpRequestInterceptor> interceptors = restTemplate.getInterceptors(); interceptors.add(0, interceptor); restTemplate.setInterceptors(interceptors); } logger.info("init AsyncRestTemplateCircuitBreaker end"); } }; }
Example #2
Source File: RestTemplateCircuitBreakerAutoConfiguration.java From spring-cloud-formula with Apache License 2.0 | 6 votes |
@Bean public SmartInitializingSingleton loadBalancedRestTemplateInitializer2( final ObjectProvider<List<RestTemplateCustomizer>> restTemplateCustomizers) { return () -> { logger.info("RestTemplateResilienceAutoConfiguration init2"); for (RestTemplate restTemplate : RestTemplateCircuitBreakerAutoConfiguration.this.restTemplates) { List<ClientHttpRequestInterceptor> interceptors = restTemplate.getInterceptors(); logger.info("RestTemplate init2 start,interceptor size:" + interceptors.size()); //for (ClientHttpRequestInterceptor interceptor : interceptors) { //logger.info("RestTemplate init2 interceptor ing:"+interceptor.getClass().getCanonicalName()); //} //logger.info("RestTemplate init2 Customizer end"); ClientHttpRequestInterceptor interceptor1 = new RestTemplateCircuitBreakerInterceptor (circuitBreakerCore); interceptors.add(0, interceptor1); restTemplate.setInterceptors(interceptors); logger.info("RestTemplate init2 end,add CircuitBreaker interceptor"); } }; }
Example #3
Source File: AsyncRestTemplateRateLimiterConfiguration.java From spring-cloud-formula with Apache License 2.0 | 6 votes |
@Bean public SmartInitializingSingleton loadBalancedAsyncRestTemplateInitializer2( final List<AsyncRestTemplateCustomizer> customizers) { return new SmartInitializingSingleton() { @Override public void afterSingletonsInstantiated() { logger.info("Init AsyncRestTemplateRateLimiterConfiguration"); for (AsyncRestTemplate restTemplate : AsyncRestTemplateRateLimiterConfiguration.this.restTemplates) { List<AsyncClientHttpRequestInterceptor> interceptors = restTemplate.getInterceptors(); logger.debug("AsyncRestTemplate init start, interceptor size:" + interceptors.size()); AsyncClientHttpRequestInterceptor interceptor = new AsyncRestTemplateRateLimiterInterceptor(serviceName); interceptors.add(0, interceptor); logger.debug("AsyncRestTemplate init end, Add AsyncRestTemplateRateLimiterInterceptor"); restTemplate.setInterceptors(interceptors); } } }; }
Example #4
Source File: RestTemplateRateLimiterAutoConfiguration.java From spring-cloud-formula with Apache License 2.0 | 5 votes |
@Bean public SmartInitializingSingleton loadBalancedRestTemplateInitializer3( final ObjectProvider<List<RestTemplateCustomizer>> restTemplateCustomizers) { return () -> { logger.info("Init RestTemplateRateLimiterAutoConfiguration"); for (RestTemplate restTemplate : RestTemplateRateLimiterAutoConfiguration.this.restTemplates) { List<ClientHttpRequestInterceptor> interceptors = restTemplate.getInterceptors(); logger.debug("RestTemplate init start, interceptor size:" + interceptors.size()); ClientHttpRequestInterceptor interceptor = new RestTemplateRateLimiterInterceptor(serviceName); interceptors.add(0, interceptor); restTemplate.setInterceptors(interceptors); logger.debug("RestTemplate init end, add RestTemplateRateLimiterInterceptor"); } }; }
Example #5
Source File: RestTemplateAutoConfiguration.java From summerframework with Apache License 2.0 | 5 votes |
@Bean public SmartInitializingSingleton metricsAsyncRestTemplateInitializer( final ObjectProvider<List<AsyncRestTemplate>> asyncRestTemplatesProvider, final RestTemplatePostProcessor customizer) { return () -> { final List<AsyncRestTemplate> asyncRestTemplates = asyncRestTemplatesProvider.getIfAvailable(); if (!CollectionUtils.isEmpty(asyncRestTemplates)) { asyncRestTemplates.forEach(customizer::customize); } }; }
Example #6
Source File: RestTemplateAutoConfiguration.java From summerframework with Apache License 2.0 | 5 votes |
@Bean public SmartInitializingSingleton metricsRestTemplateInitializer( final ObjectProvider<List<RestTemplate>> restTemplatesProvider, final RestTemplatePostProcessor customizer) { return () -> { final List<RestTemplate> restTemplates = restTemplatesProvider.getIfAvailable(); if (!CollectionUtils.isEmpty(restTemplates)) { restTemplates.forEach(customizer::customize); } }; }
Example #7
Source File: LoadBalancerAutoConfiguration.java From spring-cloud-commons with Apache License 2.0 | 5 votes |
@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); } } }); }
Example #8
Source File: AsyncLoadBalancerAutoConfiguration.java From spring-cloud-commons with Apache License 2.0 | 5 votes |
@Bean public SmartInitializingSingleton loadBalancedAsyncRestTemplateInitializer( final List<AsyncRestTemplateCustomizer> customizers) { return () -> { for (AsyncRestTemplate restTemplate : AsyncRestTemplateCustomizerConfig.this.restTemplates) { for (AsyncRestTemplateCustomizer customizer : customizers) { customizer.customize(restTemplate); } } }; }