public class AppResponse extends Object implements Result
AsyncRpcResult is introduced in 3.0.0 to replace RpcResult, and RpcResult is replaced with AppResponse:
The relationship between them can be described as follow, an abstraction of the definition of AsyncRpcResult:
Public class AsyncRpcResult implements CompletionStageAsyncRpcResult is a future representing an unfinished RPC call, while AppResponse is the actual return type of this call. In theory, AppResponse doesn't have to implement the {@link Result} interface, this is done mainly for compatibility purpose.{ ...... }
| 构造器和说明 |
|---|
AppResponse() |
AppResponse(Invocation invocation) |
AppResponse(Object result) |
AppResponse(Throwable exception) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addAttachments(Map<String,String> map)
Add the specified map to existing attachments in this instance.
|
void |
addObjectAttachments(Map<String,Object> map)
Add the specified map to existing attachments in this instance.
|
void |
clear() |
Result |
get() |
Result |
get(long timeout,
TimeUnit unit) |
String |
getAttachment(String key)
get attachment by key.
|
String |
getAttachment(String key,
String defaultValue)
get attachment by key with default value.
|
Map<String,String> |
getAttachments()
已过时。
|
Object |
getAttribute(String key) |
Throwable |
getException()
Get exception.
|
Object |
getObjectAttachment(String key)
get attachment by key.
|
Object |
getObjectAttachment(String key,
Object defaultValue)
get attachment by key with default value.
|
Map<String,Object> |
getObjectAttachments()
get attachments.
|
Object |
getValue()
Get invoke result.
|
boolean |
hasException()
Has exception.
|
Object |
recreate()
Recreate.
|
void |
setAttachment(String key,
Object value) |
void |
setAttachment(String key,
String value) |
void |
setAttachments(Map<String,String> map)
Append all items from the map into the attachment, if map is empty then nothing happens
|
void |
setAttribute(String key,
Object value) |
void |
setException(Throwable e) |
void |
setObjectAttachment(String key,
Object value) |
void |
setObjectAttachments(Map<String,Object> map)
Replace the existing attachments with the specified param.
|
void |
setValue(Object value) |
<U> CompletableFuture<U> |
thenApply(Function<Result,? extends U> fn) |
String |
toString() |
Result |
whenCompleteWithContext(BiConsumer<Result,Throwable> fn)
Add a callback which can be triggered when the RPC call finishes.
|
public AppResponse()
public AppResponse(Invocation invocation)
public AppResponse(Object result)
public AppResponse(Throwable exception)
public Object recreate() throws Throwable
Result
if (hasException()) {
throw getException();
} else {
return getValue();
}
public Throwable getException()
ResultgetException 在接口中 Resultpublic void setException(Throwable e)
setException 在接口中 Resultpublic boolean hasException()
ResulthasException 在接口中 Result@Deprecated public Map<String,String> getAttachments()
ResultgetAttachments 在接口中 Resultpublic Map<String,Object> getObjectAttachments()
ResultgetObjectAttachments 在接口中 Resultpublic void setAttachments(Map<String,String> map)
setAttachments 在接口中 Resultmap - contains all key-value pairs to appendpublic void setObjectAttachments(Map<String,Object> map)
ResultsetObjectAttachments 在接口中 Resultpublic void addAttachments(Map<String,String> map)
ResultaddAttachments 在接口中 Resultpublic void addObjectAttachments(Map<String,Object> map)
ResultaddObjectAttachments 在接口中 Resultpublic String getAttachment(String key)
ResultgetAttachment 在接口中 Resultpublic Object getObjectAttachment(String key)
ResultgetObjectAttachment 在接口中 Resultpublic String getAttachment(String key, String defaultValue)
ResultgetAttachment 在接口中 Resultpublic Object getObjectAttachment(String key, Object defaultValue)
ResultgetObjectAttachment 在接口中 Resultpublic void setAttachment(String key, String value)
setAttachment 在接口中 Resultpublic void setAttachment(String key, Object value)
setAttachment 在接口中 Resultpublic void setObjectAttachment(String key, Object value)
setObjectAttachment 在接口中 Resultpublic Result whenCompleteWithContext(BiConsumer<Result,Throwable> fn)
Result
Just as the method name implies, this method will guarantee the callback being triggered under the same context as when the call was started,
see implementation in Result.whenCompleteWithContext(BiConsumer)
whenCompleteWithContext 在接口中 Resultpublic <U> CompletableFuture<U> thenApply(Function<Result,? extends U> fn)
public Result get() throws InterruptedException, ExecutionException
get 在接口中 ResultInterruptedExceptionExecutionExceptionpublic Result get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get 在接口中 ResultInterruptedExceptionExecutionExceptionTimeoutExceptionpublic void clear()
Copyright © 2011–2021 The Apache Software Foundation. All rights reserved.