Java Code Examples for org.springframework.web.client.AsyncRestTemplate#getInterceptors()
The following examples show how to use
org.springframework.web.client.AsyncRestTemplate#getInterceptors() .
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: 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 3
Source File: TraceWebAsyncClientAutoConfiguration.java From spring-cloud-sleuth with Apache License 2.0 | 5 votes |
@PostConstruct public void init() { if (this.restTemplates != null) { for (AsyncRestTemplate restTemplate : this.restTemplates) { List<AsyncClientHttpRequestInterceptor> interceptors = new ArrayList<>( restTemplate.getInterceptors()); interceptors.add(this.clientInterceptor); restTemplate.setInterceptors(interceptors); } } }
Example 4
Source File: AsyncLoadBalancerAutoConfigurationTests.java From spring-cloud-commons with Apache License 2.0 | 5 votes |
private void assertLoadBalanced(AsyncRestTemplate restTemplate) { List<AsyncClientHttpRequestInterceptor> interceptors = restTemplate .getInterceptors(); then(interceptors).hasSize(1); AsyncClientHttpRequestInterceptor interceptor = interceptors.get(0); then(interceptor).isInstanceOf(AsyncLoadBalancerInterceptor.class); }