当前位置: 首页>>代码示例>>Java>>正文


Java AsyncRequestCallback类代码示例

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


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

示例1: doExecute

import org.springframework.web.client.AsyncRequestCallback; //导入依赖的package包/类
@Override
protected <T> ListenableFuture<T> doExecute(URI url, HttpMethod method,
		AsyncRequestCallback requestCallback, ResponseExtractor<T> responseExtractor)
		throws RestClientException {
	try {
		return super.doExecute(url, method, requestCallback, responseExtractor);
	} finally {
		finish();
	}
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:11,代码来源:TraceAsyncRestTemplate.java

示例2: execute

import org.springframework.web.client.AsyncRequestCallback; //导入依赖的package包/类
public <T> CompletableFuture<T> execute(String url, HttpMethod method,
		AsyncRequestCallback requestCallback,
		ResponseExtractor<T> responseExtractor, Object... urlVariables)
		throws RestClientException {
	return toCompletableFuture(template.execute(url, method,
			requestCallback, responseExtractor, urlVariables));
}
 
开发者ID:aol,项目名称:micro-server,代码行数:8,代码来源:NIORestClient.java

示例3: doExecute

import org.springframework.web.client.AsyncRequestCallback; //导入依赖的package包/类
@Override
protected <T> ListenableFuture<T> doExecute(URI url, HttpMethod method,
		AsyncRequestCallback requestCallback, ResponseExtractor<T> responseExtractor)
		throws RestClientException {
	final ListenableFuture<T> future = super.doExecute(url, method, requestCallback, responseExtractor);
	final Span span = this.tracer.getCurrentSpan();
	future.addCallback(new TraceListenableFutureCallback<>(this.tracer, span,
			this.errorParser));
	// potential race can happen here
	if (span != null && span.equals(this.tracer.getCurrentSpan())) {
		Span parent = this.tracer.detach(span);
		if (parent != null) {
			this.tracer.continueSpan(parent);
		}
	}
	return new ListenableFuture<T>() {

		@Override public boolean cancel(boolean mayInterruptIfRunning) {
			return future.cancel(mayInterruptIfRunning);
		}

		@Override public boolean isCancelled() {
			return future.isCancelled();
		}

		@Override public boolean isDone() {
			return future.isDone();
		}

		@Override public T get() throws InterruptedException, ExecutionException {
			return future.get();
		}

		@Override public T get(long timeout, TimeUnit unit)
				throws InterruptedException, ExecutionException, TimeoutException {
			return future.get(timeout, unit);
		}

		@Override
		public void addCallback(ListenableFutureCallback<? super T> callback) {
			future.addCallback(new TraceListenableFutureCallbackWrapper<>(TraceAsyncRestTemplate.this.tracer, span, callback));
		}

		@Override public void addCallback(SuccessCallback<? super T> successCallback,
				FailureCallback failureCallback) {
			future.addCallback(
					new TraceSuccessCallback<>(TraceAsyncRestTemplate.this.tracer, span, successCallback),
					new TraceFailureCallback(TraceAsyncRestTemplate.this.tracer, span, failureCallback));
		}
	};
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-sleuth,代码行数:52,代码来源:TraceAsyncRestTemplate.java


注:本文中的org.springframework.web.client.AsyncRequestCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。