本文整理匯總了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();
}
}
示例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));
}
示例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));
}
};
}