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| Modifier and Type | Method and Description |
|---|---|
<T> Future<T> |
asyncCall(Callable<T> callable)
Async invocation.
|
void |
asyncCall(Runnable runnable)
one way async call, send request only, and result is not required
|
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()
Deprecated.
Replace to getMethodName(), getParameterTypes(), getArguments()
|
Invoker<?> |
getInvoker()
Deprecated.
Replace to getUrl()
|
List<Invoker<?>> |
getInvokers()
Deprecated.
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.
|
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.
|
URL |
getUrl() |
List<URL> |
getUrls() |
boolean |
isClientSide()
Deprecated.
Replace to isConsumerSide()
|
boolean |
isConsumerSide()
is consumer side.
|
boolean |
isProviderSide()
is provider side.
|
boolean |
isServerSide()
Deprecated.
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 |
setRequest(Object request) |
void |
setResponse(Object response) |
void |
setUrl(URL url) |
void |
setUrls(List<URL> urls) |
public static RpcContext getContext()
public static void removeContext()
ContextFilterpublic Object getRequest()
public <T> T getRequest(Class<T> clazz)
public void setRequest(Object request)
public Object getResponse()
public <T> T getResponse(Class<T> clazz)
public void setResponse(Object response)
public 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 String getAttachment(String key)
key - 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)
Future.get() is not called.callable - future.get()public void asyncCall(Runnable runnable)
runnable - Copyright © 2011–2018 The Apache Software Foundation. All rights reserved.