Java Code Examples for org.springframework.http.client.support.InterceptingHttpAccessor

The following examples show how to use org.springframework.http.client.support.InterceptingHttpAccessor. These examples are extracted from open source projects. 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
@Bean
public InitializingBean clientsCorrelationInitializer(final RequestCorrelationProperties properties) {

    return new InitializingBean() {
        @Override
        public void afterPropertiesSet() throws Exception {

            if(clients != null) {
                for(InterceptingHttpAccessor client : clients) {
                    final List<ClientHttpRequestInterceptor> interceptors = new ArrayList<>(client.getInterceptors());
                    interceptors.add(new ClientHttpRequestCorrelationInterceptor(properties));
                    client.setInterceptors(interceptors);
                }
            }
        }
    };
}
 
Example 2
public RestTemplatePostProcessingConfiguration(Tracer tracer,
                                               List<RestTemplateSpanDecorator> spanDecorators,
                                               Set<InterceptingHttpAccessor> restTemplates) {
    this.tracer = tracer;
    this.spanDecorators = spanDecorators;
    this.restTemplates = restTemplates;
}
 
Example 3
private void registerTracingInterceptor(InterceptingHttpAccessor restTemplate) {
    List<ClientHttpRequestInterceptor> interceptors = restTemplate.getInterceptors();

    for (ClientHttpRequestInterceptor interceptor : interceptors) {
        if (interceptor instanceof TracingRestTemplateInterceptor) {
            return;
        }
    }

    log.debug("Adding " + TracingRestTemplateInterceptor.class.getSimpleName() + " to " + restTemplate);
    interceptors = new ArrayList<>(interceptors);
    interceptors.add(new TracingRestTemplateInterceptor(tracer, spanDecorators));
    restTemplate.setInterceptors(interceptors);
}
 
Example 4
@PostConstruct
public void init() {
    for (InterceptingHttpAccessor restTemplate : restTemplates) {
        registerTracingInterceptor(restTemplate);
    }
}