Package org.apache.dubbo.rpc
Class AppResponse
java.lang.Object
org.apache.dubbo.rpc.AppResponse
- All Implemented Interfaces:
Serializable,Result
AsyncRpcResult is introduced in 3.0.0 to replace RpcResult, and RpcResult is replaced with AppResponse:
- AsyncRpcResult is the object that is actually passed in the call chain
- AppResponse only simply represents the business result
The relationship between them can be described as follow, an abstraction of the definition of AsyncRpcResult:
invalid input: '{@code
Public class AsyncRpcResult implements CompletionStage<AppResponse> {
......
}
</pre>
AsyncRpcResult 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.
@serial Do not change the class name and properties.'- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAppResponse(Object result) AppResponse(Throwable exception) AppResponse(Invocation invocation) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttachments(Map<String, String> map) Add the specified map to existing attachments in this instance.voidaddObjectAttachments(Map<String, Object> map) Add the specified map to existing attachments in this instance.voidclear()get()getAttachment(String key) get attachment by key.getAttachment(String key, String defaultValue) get attachment by key with default value.Deprecated.getAttribute(String key) Get exception.get attachment by key.getObjectAttachment(String key, Object defaultValue) get attachment by key with default value.get attachments.getValue()Get invoke result.booleanHas exception.recreate()Recreate.voidsetAttachment(String key, Object value) voidsetAttachment(String key, String value) voidsetAttachments(Map<String, String> map) Append all items from the map into the attachment, if map is empty then nothing happensvoidsetAttribute(String key, Object value) voidvoidsetObjectAttachment(String key, Object value) voidsetObjectAttachments(Map<String, Object> map) Replace the existing attachments with the specified param.void<U> CompletableFuture<U> toString()Add a callback which can be triggered when the RPC call finishes.
-
Constructor Details
-
AppResponse
public AppResponse() -
AppResponse
-
AppResponse
-
AppResponse
-
-
Method Details
-
recreate
Description copied from interface:ResultRecreate.if (hasException()) { throw getException(); } else { return getValue(); } -
getValue
Description copied from interface:ResultGet invoke result. -
setValue
-
getException
Description copied from interface:ResultGet exception.- Specified by:
getExceptionin interfaceResult- Returns:
- exception. if no exception return null.
-
setException
- Specified by:
setExceptionin interfaceResult
-
hasException
public boolean hasException()Description copied from interface:ResultHas exception.- Specified by:
hasExceptionin interfaceResult- Returns:
- has exception.
-
getAttachments
Deprecated.Description copied from interface:Resultget attachments.- Specified by:
getAttachmentsin interfaceResult- Returns:
- attachments.
-
getObjectAttachments
Description copied from interface:Resultget attachments.- Specified by:
getObjectAttachmentsin interfaceResult- Returns:
- attachments.
-
setAttachments
Append all items from the map into the attachment, if map is empty then nothing happens- Specified by:
setAttachmentsin interfaceResult- Parameters:
map- contains all key-value pairs to append
-
setObjectAttachments
Description copied from interface:ResultReplace the existing attachments with the specified param.- Specified by:
setObjectAttachmentsin interfaceResult- Parameters:
map-
-
addAttachments
Description copied from interface:ResultAdd the specified map to existing attachments in this instance.- Specified by:
addAttachmentsin interfaceResult- Parameters:
map-
-
addObjectAttachments
Description copied from interface:ResultAdd the specified map to existing attachments in this instance.- Specified by:
addObjectAttachmentsin interfaceResult- Parameters:
map-
-
getAttachment
Description copied from interface:Resultget attachment by key.- Specified by:
getAttachmentin interfaceResult- Returns:
- attachment value.
-
getObjectAttachment
Description copied from interface:Resultget attachment by key.- Specified by:
getObjectAttachmentin interfaceResult- Returns:
- attachment value.
-
getAttachment
Description copied from interface:Resultget attachment by key with default value.- Specified by:
getAttachmentin interfaceResult- Returns:
- attachment value.
-
getObjectAttachment
Description copied from interface:Resultget attachment by key with default value.- Specified by:
getObjectAttachmentin interfaceResult- Returns:
- attachment value.
-
setAttachment
- Specified by:
setAttachmentin interfaceResult
-
setAttachment
- Specified by:
setAttachmentin interfaceResult
-
setObjectAttachment
- Specified by:
setObjectAttachmentin interfaceResult
-
getAttribute
-
setAttribute
-
whenCompleteWithContext
Description copied from interface:ResultAdd a callback which can be triggered when the RPC call finishes.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)- Specified by:
whenCompleteWithContextin interfaceResult- Parameters:
fn-- Returns:
-
thenApply
-
get
- Specified by:
getin interfaceResult- Throws:
InterruptedExceptionExecutionException
-
get
public Result get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
getin interfaceResult- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
clear
public void clear() -
toString
-