• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java AsyncClientHttpRequestInterceptor类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.springframework.http.client.AsyncClientHttpRequestInterceptor的典型用法代码示例。如果您正苦于以下问题:Java AsyncClientHttpRequestInterceptor类的具体用法?Java AsyncClientHttpRequestInterceptor怎么用?Java AsyncClientHttpRequestInterceptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

AsyncClientHttpRequestInterceptor类属于org.springframework.http.client包,在下文中一共展示了AsyncClientHttpRequestInterceptor类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createNewRestTemplate

点赞 3

import org.springframework.http.client.AsyncClientHttpRequestInterceptor; //导入依赖的package包/类
private AsyncRestTemplate createNewRestTemplate(String addr) {
    // we use async client because usual client does not allow to interruption in some cases
    NettyRequestFactory factory = new NettyRequestFactory();
    if(AddressUtils.isHttps(addr)) {
        try {
            initSsl(addr, factory);
        } catch (Exception e) {
            log.error("", e);
        }
    }
    final AsyncRestTemplate restTemplate = new AsyncRestTemplate(factory);
    List<AsyncClientHttpRequestInterceptor> interceptors = new ArrayList<>();
    interceptors.add(new HttpAuthInterceptor(registryRepository));
    if(!StringUtils.isEmpty(agentPassword)) {
        interceptors.add(new BasicAuthAsyncInterceptor("admin", agentPassword));
    }
    restTemplate.setInterceptors(interceptors);
    return restTemplate;
}
 

开发者ID:codeabovelab,
项目名称:haven-platform,
代码行数:20,
代码来源:DockerServiceFactory.java

示例2: TracingAsyncRestTemplateTest

点赞 2

import org.springframework.http.client.AsyncClientHttpRequestInterceptor; //导入依赖的package包/类
public TracingAsyncRestTemplateTest() {
    final AsyncRestTemplate restTemplate = new AsyncRestTemplate();
    restTemplate.setInterceptors(Collections.<AsyncClientHttpRequestInterceptor>singletonList(
            new TracingAsyncRestTemplateInterceptor(mockTracer,
                    Collections.<RestTemplateSpanDecorator>singletonList(new RestTemplateSpanDecorator.StandardTags()))));

    client = new Client<AsyncRestTemplate>() {
        @Override
        public <T> ResponseEntity<T> getForEntity(String url, Class<T> clazz) {
            ListenableFuture<ResponseEntity<T>> forEntity = restTemplate.getForEntity(url, clazz);
            try {
                return forEntity.get();
            } catch (InterruptedException | ExecutionException e) {
                e.printStackTrace();
                Assert.fail();
            }
            return null;
        }

        @Override
        public AsyncRestTemplate template() {
            return restTemplate;
        }
    };

    mockServer = MockRestServiceServer.bindTo(client.template()).ignoreExpectOrder(true).build();
}
 

开发者ID:opentracing-contrib,
项目名称:java-spring-web,
代码行数:28,
代码来源:TracingAsyncRestTemplateTest.java

示例3: registerTracingInterceptor

点赞 2

import org.springframework.http.client.AsyncClientHttpRequestInterceptor; //导入依赖的package包/类
private void registerTracingInterceptor(AsyncRestTemplate restTemplate) {
    List<AsyncClientHttpRequestInterceptor> interceptors = restTemplate.getInterceptors();

    for (AsyncClientHttpRequestInterceptor interceptor: interceptors) {
        if (interceptor instanceof TracingAsyncRestTemplateInterceptor) {
            return;
        }
    }

    log.info("Adding " + TracingAsyncRestTemplateInterceptor.class.getSimpleName() + " to async rest template");
    interceptors = new ArrayList<>(interceptors);
    interceptors.add(new TracingAsyncRestTemplateInterceptor(tracer));
    restTemplate.setInterceptors(interceptors);
}
 

开发者ID:opentracing-contrib,
项目名称:java-spring-web,
代码行数:15,
代码来源:AsyncRestTemplateAutoConfiguration.java

示例4: asyncRestTemplateCustomizer

点赞 2

import org.springframework.http.client.AsyncClientHttpRequestInterceptor; //导入依赖的package包/类
@Bean
public AsyncRestTemplateCustomizer asyncRestTemplateCustomizer(
		final AsyncLoadBalancerInterceptor loadBalancerInterceptor) {
	return new AsyncRestTemplateCustomizer() {
		@Override
		public void customize(AsyncRestTemplate restTemplate) {
			List<AsyncClientHttpRequestInterceptor> list = new ArrayList<>(
					restTemplate.getInterceptors());
			list.add(loadBalancerInterceptor);
			restTemplate.setInterceptors(list);
		}
	};
}
 

开发者ID:spring-cloud,
项目名称:spring-cloud-commons,
代码行数:14,
代码来源:AsyncLoadBalancerAutoConfiguration.java

示例5: assertLoadBalanced

点赞 2

import org.springframework.http.client.AsyncClientHttpRequestInterceptor; //导入依赖的package包/类
private void assertLoadBalanced(AsyncRestTemplate restTemplate) {
	List<AsyncClientHttpRequestInterceptor> interceptors = restTemplate.getInterceptors();
	MatcherAssert.assertThat(interceptors, hasSize(1));
	AsyncClientHttpRequestInterceptor interceptor = interceptors.get(0);
	MatcherAssert.assertThat(interceptor, is(instanceOf(AsyncLoadBalancerInterceptor.class)));
}
 

开发者ID:spring-cloud,
项目名称:spring-cloud-commons,
代码行数:7,
代码来源:AsyncLoadBalancerAutoConfigurationTests.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)