當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。