类 AppResponse
- java.lang.Object
-
- org.apache.dubbo.rpc.AppResponse
-
- 所有已实现的接口:
Serializable,Result
- 直接已知子类:
DecodeableRpcResult
public class AppResponse extends Object implements Result
AsyncRpcResultis introduced in 3.0.0 to replace RpcResult, and RpcResult is replaced withAppResponse:- 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:
{@code 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(Object result)AppResponse(Throwable exception)AppResponse(Invocation invocation)
-
方法概要
所有方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 voidaddAttachments(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()Resultget()Resultget(long timeout, TimeUnit unit)StringgetAttachment(String key)get attachment by key.StringgetAttachment(String key, String defaultValue)get attachment by key with default value.Map<String,String>getAttachments()已过时。ObjectgetAttribute(String key)ThrowablegetException()Get exception.ObjectgetObjectAttachment(String key)get attachment by key.ObjectgetObjectAttachment(String key, Object defaultValue)get attachment by key with default value.Map<String,Object>getObjectAttachments()get attachments.ObjectgetValue()Get invoke result.booleanhasException()Has exception.Objectrecreate()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)voidsetException(Throwable e)voidsetObjectAttachment(String key, Object value)voidsetObjectAttachments(Map<String,Object> map)Replace the existing attachments with the specified param.voidsetValue(Object value)<U> CompletableFuture<U>thenApply(Function<Result,? extends U> fn)StringtoString()ResultwhenCompleteWithContext(BiConsumer<Result,Throwable> fn)Add a callback which can be triggered when the RPC call finishes.
-
-
-
构造器详细资料
-
AppResponse
public AppResponse()
-
AppResponse
public AppResponse(Invocation invocation)
-
AppResponse
public AppResponse(Object result)
-
AppResponse
public AppResponse(Throwable exception)
-
-
方法详细资料
-
recreate
public Object recreate() throws Throwable
从接口复制的说明:ResultRecreate.if (hasException()) { throw getException(); } else { return getValue(); }
-
getException
public Throwable getException()
从接口复制的说明:ResultGet exception.- 指定者:
getException在接口中Result- 返回:
- exception. if no exception return null.
-
setException
public void setException(Throwable e)
- 指定者:
setException在接口中Result
-
hasException
public boolean hasException()
从接口复制的说明:ResultHas exception.- 指定者:
hasException在接口中Result- 返回:
- has exception.
-
getAttachments
@Deprecated public Map<String,String> getAttachments()
已过时。从接口复制的说明:Resultget attachments.- 指定者:
getAttachments在接口中Result- 返回:
- attachments.
-
getObjectAttachments
public Map<String,Object> getObjectAttachments()
从接口复制的说明:Resultget attachments.- 指定者:
getObjectAttachments在接口中Result- 返回:
- attachments.
-
setAttachments
public void setAttachments(Map<String,String> map)
Append all items from the map into the attachment, if map is empty then nothing happens- 指定者:
setAttachments在接口中Result- 参数:
map- contains all key-value pairs to append
-
setObjectAttachments
public void setObjectAttachments(Map<String,Object> map)
从接口复制的说明:ResultReplace the existing attachments with the specified param.- 指定者:
setObjectAttachments在接口中Result
-
addAttachments
public void addAttachments(Map<String,String> map)
从接口复制的说明:ResultAdd the specified map to existing attachments in this instance.- 指定者:
addAttachments在接口中Result
-
addObjectAttachments
public void addObjectAttachments(Map<String,Object> map)
从接口复制的说明:ResultAdd the specified map to existing attachments in this instance.- 指定者:
addObjectAttachments在接口中Result
-
getAttachment
public String getAttachment(String key)
从接口复制的说明:Resultget attachment by key.- 指定者:
getAttachment在接口中Result- 返回:
- attachment value.
-
getObjectAttachment
public Object getObjectAttachment(String key)
从接口复制的说明:Resultget attachment by key.- 指定者:
getObjectAttachment在接口中Result- 返回:
- attachment value.
-
getAttachment
public String getAttachment(String key, String defaultValue)
从接口复制的说明:Resultget attachment by key with default value.- 指定者:
getAttachment在接口中Result- 返回:
- attachment value.
-
getObjectAttachment
public Object getObjectAttachment(String key, Object defaultValue)
从接口复制的说明:Resultget attachment by key with default value.- 指定者:
getObjectAttachment在接口中Result- 返回:
- attachment value.
-
setAttachment
public void setAttachment(String key, String value)
- 指定者:
setAttachment在接口中Result
-
setAttachment
public void setAttachment(String key, Object value)
- 指定者:
setAttachment在接口中Result
-
setObjectAttachment
public void setObjectAttachment(String key, Object value)
- 指定者:
setObjectAttachment在接口中Result
-
whenCompleteWithContext
public Result whenCompleteWithContext(BiConsumer<Result,Throwable> fn)
从接口复制的说明: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)- 指定者:
whenCompleteWithContext在接口中Result- 返回:
-
thenApply
public <U> CompletableFuture<U> thenApply(Function<Result,? extends U> fn)
-
get
public Result get() throws InterruptedException, ExecutionException
- 指定者:
get在接口中Result- 抛出:
InterruptedExceptionExecutionException
-
get
public Result get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
- 指定者:
get在接口中Result- 抛出:
InterruptedExceptionExecutionExceptionTimeoutException
-
clear
public void clear()
-
-