public class HttpResponseFuture<V> extends AbstractResponseFuture<V>
| 限定符和类型 | 字段和说明 |
|---|---|
protected SofaRequest |
request
sofa请求
|
protected SofaResponse |
response
sofa响应
|
CANCELLATION_CAUSE, cause, doneTime, genTime, result, sentTime, timeout| 构造器和说明 |
|---|
HttpResponseFuture(SofaRequest request,
int timeout)
构造函数
|
| 限定符和类型 | 方法和说明 |
|---|---|
ResponseFuture |
addListener(SofaResponseCallback sofaResponseCallback)
增加单个响应监听器
|
ResponseFuture |
addListeners(List<SofaResponseCallback> list)
增加多个响应监听器
|
protected TimeoutException |
clientTimeoutException() |
protected V |
getNow()
解析结果,拿到返回值
|
protected SofaResponse |
getNowResponse() |
SofaResponse |
getSofaResponse(int timeout,
TimeUnit unit)
Waits if necessary for at most the given time for the computation
to complete, and then retrieves its result, if available.
|
void |
notifyListeners()
notify all listener.
|
protected void |
releaseIfNeed(Object result)
异步的情况下,如果返回,将释放内容
|
await, cancel, get, get, getElapsedTime, isCancelled, isDone, setDoneTime, setFailure, setSentTime, setSuccess, setSuccess0protected final SofaRequest request
protected SofaResponse response
public HttpResponseFuture(SofaRequest request, int timeout)
protected TimeoutException clientTimeoutException()
protected V getNow() throws ExecutionException
AbstractResponseFuturegetNow 在类中 AbstractResponseFuture<V>ExecutionException - 执行异常protected void releaseIfNeed(Object result)
AbstractResponseFuturereleaseIfNeed 在类中 AbstractResponseFuture<V>result - 返回值public ResponseFuture addListeners(List<SofaResponseCallback> list)
ResponseFuturelist - 多个响应监听器public ResponseFuture addListener(SofaResponseCallback sofaResponseCallback)
ResponseFuturesofaResponseCallback - 多个响应监听器public void notifyListeners()
AbstractResponseFuturenotifyListeners 在类中 AbstractResponseFuture<V>public SofaResponse getSofaResponse(int timeout, TimeUnit unit) throws CancellationException, TimeoutException, InterruptedException, ExecutionException
timeout - the maximum time to waitunit - the time unit of the timeout argumentCancellationException - if the computation was cancelledExecutionException - if the computation threw an
exceptionInterruptedException - if the current thread was interrupted
while waitingTimeoutException - if the wait timed outprotected SofaResponse getNowResponse() throws ExecutionException, CancellationException
Copyright © 2008–2018 The Ant Financial. All rights reserved.