public class RpcContext extends Object
Note: RpcContext is a temporary state holder. States in RpcContext changes every time when request is sent or received. For example: A invokes B, then B invokes C. On service B, RpcContext saves invocation info from A to B before B starts invoking C, and saves invocation info from B to C after B invokes C.
ContextFilter| 限定符和类型 | 方法和说明 |
|---|---|
<T> CompletableFuture<T> |
asyncCall(Callable<T> callable)
Async invocation.
|
void |
asyncCall(Runnable runnable)
one way async call, send request only, and result is not required
|
boolean |
canRemove() |
void |
clearAfterEachInvoke(boolean remove) |
void |
clearAttachments() |
Map<String,Object> |
get()
get values.
|
Object |
get(String key)
get value.
|
Object[] |
getArguments()
get arguments.
|
AsyncContext |
getAsyncContext() |
String |
getAttachment(String key)
also see
getObjectAttachment(String). |
Map<String,String> |
getAttachments()
已过时。
|
<T> CompletableFuture<T> |
getCompletableFuture()
get CompletableFuture.
|
URL |
getConsumerUrl() |
static RpcContext |
getContext()
get context.
|
<T> Future<T> |
getFuture()
get future.
|
String |
getGroup() |
String |
getInterfaceName() |
Invocation |
getInvocation()
已过时。
Replace to getMethodName(), getParameterTypes(), getArguments()
|
Invoker<?> |
getInvoker()
已过时。
Replace to getUrl()
|
List<Invoker<?>> |
getInvokers()
已过时。
Replace to getUrls()
|
InetSocketAddress |
getLocalAddress()
get local address.
|
String |
getLocalAddressString() |
String |
getLocalHost()
get local host.
|
String |
getLocalHostName()
get local host name.
|
int |
getLocalPort()
get local port.
|
String |
getMethodName()
get method name.
|
Object |
getObjectAttachment(String key)
get attachment.
|
Map<String,Object> |
getObjectAttachments()
get attachments.
|
Class<?>[] |
getParameterTypes()
get parameter types.
|
String |
getProtocol() |
String |
getProtocolServiceKey() |
InetSocketAddress |
getRemoteAddress()
get remote address.
|
String |
getRemoteAddressString()
get remote address string.
|
String |
getRemoteApplicationName() |
String |
getRemoteHost()
get remote host.
|
String |
getRemoteHostName()
get remote host name.
|
int |
getRemotePort()
get remote port.
|
Object |
getRequest()
Get the request object of the underlying RPC protocol, e.g.
|
<T> T |
getRequest(Class<T> clazz)
Get the request object of the underlying RPC protocol, e.g.
|
Object |
getResponse()
Get the response object of the underlying RPC protocol, e.g.
|
<T> T |
getResponse(Class<T> clazz)
Get the response object of the underlying RPC protocol, e.g.
|
static RpcContext |
getServerContext()
get server side context.
|
String |
getServiceKey() |
URL |
getUrl() |
List<URL> |
getUrls() |
String |
getVersion() |
boolean |
isAsyncStarted() |
boolean |
isClientSide()
已过时。
Replace to isConsumerSide()
|
boolean |
isConsumerSide()
is consumer side.
|
boolean |
isProviderSide()
is provider side.
|
boolean |
isServerSide()
已过时。
Replace to isProviderSide()
|
RpcContext |
remove(String key)
remove value.
|
RpcContext |
removeAttachment(String key)
remove attachment.
|
static void |
removeContext()
remove context.
|
static void |
removeContext(boolean checkCanRemove)
customized for internal use.
|
static void |
removeServerContext()
remove server side context.
|
static void |
restoreContext(RpcContext oldContext) |
static void |
restoreServerContext(RpcContext oldServerContext) |
RpcContext |
set(String key,
Object value)
set value.
|
void |
setArguments(Object[] arguments) |
RpcContext |
setAttachment(String key,
Object value) |
RpcContext |
setAttachment(String key,
String value)
set attachment.
|
RpcContext |
setAttachments(Map<String,String> attachment)
set attachments
|
void |
setConsumerUrl(URL consumerUrl) |
void |
setFuture(CompletableFuture<?> future)
set future.
|
RpcContext |
setInvocation(Invocation invocation) |
RpcContext |
setInvoker(Invoker<?> invoker) |
RpcContext |
setInvokers(List<Invoker<?>> invokers) |
RpcContext |
setLocalAddress(InetSocketAddress address)
set local address.
|
RpcContext |
setLocalAddress(String host,
int port)
set local address.
|
void |
setMethodName(String methodName) |
RpcContext |
setObjectAttachment(String key,
Object value) |
RpcContext |
setObjectAttachments(Map<String,Object> attachment)
set attachments
|
void |
setParameterTypes(Class<?>[] parameterTypes) |
RpcContext |
setRemoteAddress(InetSocketAddress address)
set remote address.
|
RpcContext |
setRemoteAddress(String host,
int port)
set remote address.
|
RpcContext |
setRemoteApplicationName(String remoteApplicationName) |
void |
setRequest(Object request) |
void |
setResponse(Object response) |
static void |
setRpcContext(URL url) |
void |
setUrl(URL url) |
void |
setUrls(List<URL> urls) |
static AsyncContext |
startAsync() |
boolean |
stopAsync() |
public static RpcContext getServerContext()
public static void restoreServerContext(RpcContext oldServerContext)
public static void removeServerContext()
ContextFilterpublic static RpcContext getContext()
public boolean canRemove()
public void clearAfterEachInvoke(boolean remove)
public static void restoreContext(RpcContext oldContext)
public static void removeContext()
ContextFilterpublic static void removeContext(boolean checkCanRemove)
checkCanRemove - if need check before removepublic Object getRequest()
public void setRequest(Object request)
public <T> T getRequest(Class<T> clazz)
public Object getResponse()
public void setResponse(Object response)
public <T> T getResponse(Class<T> clazz)
public boolean isProviderSide()
public boolean isConsumerSide()
public <T> CompletableFuture<T> getCompletableFuture()
T - public <T> Future<T> getFuture()
T - public void setFuture(CompletableFuture<?> future)
future - public URL getUrl()
public void setUrl(URL url)
public String getMethodName()
public void setMethodName(String methodName)
public Class<?>[] getParameterTypes()
public void setParameterTypes(Class<?>[] parameterTypes)
public Object[] getArguments()
public void setArguments(Object[] arguments)
public RpcContext setLocalAddress(String host, int port)
host - port - public InetSocketAddress getLocalAddress()
public RpcContext setLocalAddress(InetSocketAddress address)
address - public String getLocalAddressString()
public String getLocalHostName()
public RpcContext setRemoteAddress(String host, int port)
host - port - public InetSocketAddress getRemoteAddress()
public RpcContext setRemoteAddress(InetSocketAddress address)
address - public String getRemoteApplicationName()
public RpcContext setRemoteApplicationName(String remoteApplicationName)
public String getRemoteAddressString()
public String getRemoteHostName()
public String getLocalHost()
public int getLocalPort()
public String getRemoteHost()
public int getRemotePort()
public String getAttachment(String key)
getObjectAttachment(String).key - public Object getObjectAttachment(String key)
key - public RpcContext setAttachment(String key, String value)
key - value - public RpcContext setAttachment(String key, Object value)
public RpcContext setObjectAttachment(String key, Object value)
public RpcContext removeAttachment(String key)
key - @Deprecated public Map<String,String> getAttachments()
getObjectAttachments()}public Map<String,Object> getObjectAttachments()
public RpcContext setAttachments(Map<String,String> attachment)
attachment - public RpcContext setObjectAttachments(Map<String,Object> attachment)
attachment - public void clearAttachments()
public RpcContext set(String key, Object value)
key - value - public RpcContext remove(String key)
key - @Deprecated public boolean isServerSide()
@Deprecated public boolean isClientSide()
@Deprecated public List<Invoker<?>> getInvokers()
public RpcContext setInvokers(List<Invoker<?>> invokers)
@Deprecated public Invoker<?> getInvoker()
public RpcContext setInvoker(Invoker<?> invoker)
@Deprecated public Invocation getInvocation()
public RpcContext setInvocation(Invocation invocation)
public <T> CompletableFuture<T> asyncCall(Callable<T> callable)
Future.get() is not called.callable - future.get()public void asyncCall(Runnable runnable)
runnable - public static AsyncContext startAsync() throws IllegalStateException
IllegalStateExceptionpublic boolean isAsyncStarted()
public boolean stopAsync()
public AsyncContext getAsyncContext()
public String getGroup()
public String getVersion()
public String getInterfaceName()
public String getProtocol()
public String getServiceKey()
public String getProtocolServiceKey()
public URL getConsumerUrl()
public void setConsumerUrl(URL consumerUrl)
public static void setRpcContext(URL url)
Copyright © 2011–2021 The Apache Software Foundation. All rights reserved.