本文整理汇总了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));
}
};
}