public class AppResponse extends AbstractResult implements Serializable
AsyncRpcResult is introduced in 3.0.0 to replace RpcResult, and RpcResult is replaced with AppResponse:
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 does'n have to implement the {@link Result} interface, this is done mainly for compatibility purpose.{ ...... }
CompletableFuture.AsynchronousCompletionTask| 构造器和说明 |
|---|
AppResponse() |
AppResponse(Object result) |
AppResponse(Throwable exception) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addAttachments(Map<String,String> map)
Add the specified map to existing attachments in this instance.
|
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()
get attachments.
|
Throwable |
getException()
Get exception.
|
Object |
getValue()
Get invoke result.
|
boolean |
hasException()
Has exception.
|
Object |
recreate()
Recreate.
|
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 |
setException(Throwable e) |
void |
setValue(Object value) |
Result |
thenApplyWithContext(Function<Result,Result> fn)
Add a callback which can be triggered when the RPC call finishes.
|
String |
toString() |
acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, cancel, complete, completedFuture, completeExceptionally, exceptionally, get, get, getNow, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, join, obtrudeException, obtrudeValue, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, runAsync, runAsync, supplyAsync, supplyAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, whenComplete, whenCompleteAsync, whenCompleteAsynccompletionFuture, getNowacceptEither, acceptEitherAsync, acceptEitherAsync, applyToEither, applyToEitherAsync, applyToEitherAsync, exceptionally, handle, handleAsync, handleAsync, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, whenComplete, whenCompleteAsync, whenCompleteAsyncpublic AppResponse()
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 在接口中 Resultpublic Map<String,String> getAttachments()
ResultgetAttachments 在接口中 Resultpublic void setAttachments(Map<String,String> map)
setAttachments 在接口中 Resultmap - contains all key-value pairs to appendpublic void addAttachments(Map<String,String> map)
ResultaddAttachments 在接口中 Resultpublic String getAttachment(String key)
ResultgetAttachment 在接口中 Resultpublic String getAttachment(String key, String defaultValue)
ResultgetAttachment 在接口中 Resultpublic void setAttachment(String key, String value)
setAttachment 在接口中 Resultpublic Result thenApplyWithContext(Function<Result,Result> 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 AsyncRpcResult.thenApplyWithContext(Function)
thenApplyWithContext 在接口中 Resultpublic String toString()
toString 在类中 CompletableFuture<Result>Copyright © 2011–2019 The Apache Software Foundation. All rights reserved.