public class RpcContext extends Object
注意:RpcContext是一个临时状态记录器,当接收到RPC请求,或发起RPC请求时,RpcContext的状态都会变化。 比如:A调B,B再调C,则B机器上,在B调C之前,RpcContext记录的是A调B的信息,在B调C之后,RpcContext记录的是B调C的信息。
ContextFilter| 限定符和类型 | 方法和说明 |
|---|---|
<T> Future<T> |
asyncCall(Callable<T> callable)
异步调用 ,需要返回值,即使步调用Future.get方法,也会处理调用超时问题.
|
void |
asyncCall(Runnable runable)
oneway调用,只发送请求,不接收返回结果.
|
void |
clearAttachments() |
Map<String,Object> |
get()
get values.
|
Object |
get(String key)
get value.
|
Object[] |
getArguments()
get arguments.
|
String |
getAttachment(String key)
get attachment.
|
Map<String,String> |
getAttachments()
get attachments.
|
static RpcContext |
getContext()
get context.
|
<T> Future<T> |
getFuture()
get future.
|
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.
|
Class<?>[] |
getParameterTypes()
get parameter types.
|
InetSocketAddress |
getRemoteAddress()
get remote address.
|
String |
getRemoteAddressString()
get remote address string.
|
String |
getRemoteHost()
get remote host.
|
String |
getRemoteHostName()
get remote host name.
|
int |
getRemotePort()
get remote port.
|
URL |
getUrl() |
List<URL> |
getUrls() |
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.
|
RpcContext |
set(String key,
Object value)
set value.
|
void |
setArguments(Object[] arguments) |
RpcContext |
setAttachment(String key,
String value)
set attachment.
|
RpcContext |
setAttachments(Map<String,String> attachment)
set attachments
|
void |
setFuture(Future<?> 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) |
void |
setParameterTypes(Class<?>[] parameterTypes) |
RpcContext |
setRemoteAddress(InetSocketAddress address)
set remote address.
|
RpcContext |
setRemoteAddress(String host,
int port)
set remote address.
|
void |
setUrl(URL url) |
void |
setUrls(List<URL> urls) |
public static RpcContext getContext()
public static void removeContext()
ContextFilterpublic boolean isProviderSide()
public boolean isConsumerSide()
public <T> Future<T> getFuture()
T - public void setFuture(Future<?> 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 getRemoteAddressString()
public String getRemoteHostName()
public String getLocalHost()
public int getLocalPort()
public String getRemoteHost()
public int getRemotePort()
public RpcContext setAttachment(String key, String value)
key - value - public RpcContext removeAttachment(String key)
key - public RpcContext setAttachments(Map<String,String> 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> Future<T> asyncCall(Callable<T> callable)
callable - public void asyncCall(Runnable runable)
callable - Copyright © 2012–2017 Alibaba. All rights reserved.