类 RpcContext
-
- com.alibaba.dubbo.rpc.RpcContext
-
public class RpcContext extends
Thread local context. (API, ThreadLocal, ThreadSafe)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
-
-
方法概要
所有方法 静态方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 void
runnable)
one way async call, send request only, and result is not required<T> <T>
<T> callable)
Async invocation.void
clearAttachments()
<,>
get()
get values.key)
get value.[]
getArguments()
get arguments.key)
get attachment.<,>
getAttachments()
get attachments.static RpcContext
getContext()
get context.<T> <T>
getFuture()
get future.Invocation
getInvocation()
已过时。Replace to getMethodName(), getParameterTypes(), getArguments()Invoker<?>
getInvoker()
已过时。Replace to getUrl()<Invoker<?>>
getInvokers()
已过时。Replace to getUrls()getLocalAddress()
get local address.getLocalAddressString()
getLocalHost()
get local host.getLocalHostName()
get local host name.int
getLocalPort()
get local port.getMethodName()
get method name.<?>[]
getParameterTypes()
get parameter types.getRemoteAddress()
get remote address.getRemoteAddressString()
get remote address string.getRemoteHost()
get remote host.getRemoteHostName()
get remote host name.int
getRemotePort()
get remote port.getRequest()
Get the request object of the underlying RPC protocol, e.g.<T> T
<T> clazz)
Get the request object of the underlying RPC protocol, e.g.getResponse()
Get the response object of the underlying RPC protocol, e.g.<T> T
<T> clazz)
Get the response object of the underlying RPC protocol, e.g.static RpcContext
getServerContext()
get server side context.URL
getUrl()
<URL>
getUrls()
boolean
isClientSide()
已过时。Replace to isConsumerSide()boolean
isConsumerSide()
is consumer side.boolean
isProviderSide()
is provider side.boolean
isServerSide()
已过时。Replace to isProviderSide()RpcContext
key)
remove value.RpcContext
key)
remove attachment.static void
removeContext()
remove context.static void
removeServerContext()
remove server side context.RpcContext
key, value)
set value.void
[] arguments)
RpcContext
key, value)
set attachment.RpcContext
<,> attachment)
set attachmentsvoid
<?> future)
set future.RpcContext
setInvocation(Invocation invocation)
RpcContext
setInvoker(Invoker<?> invoker)
RpcContext
<Invoker<?>> invokers)
RpcContext
host, int port)
set local address.RpcContext
address)
set local address.void
methodName)
void
<?>[] parameterTypes)
RpcContext
host, int port)
set remote address.RpcContext
address)
set remote address.void
request)
void
response)
void
setUrl(URL url)
void
<URL> urls)
-
-
-
方法详细资料
-
getServerContext
public static RpcContext getServerContext()
get server side context.- 返回:
- server context
-
removeServerContext
public static void removeServerContext()
remove server side context.- 另请参阅:
ContextFilter
-
getContext
public static RpcContext getContext()
get context.- 返回:
- context
-
removeContext
public static void removeContext()
remove context.- 另请参阅:
ContextFilter
-
getRequest
public getRequest()
Get the request object of the underlying RPC protocol, e.g. HttpServletRequest- 返回:
- null if the underlying protocol doesn't provide support for getting request
-
getRequest
public <T> T getRequest(<T> clazz)
Get the request object of the underlying RPC protocol, e.g. HttpServletRequest- 返回:
- null if the underlying protocol doesn't provide support for getting request or the request is not of the specified type
-
setRequest
public void setRequest( request)
-
getResponse
public getResponse()
Get the response object of the underlying RPC protocol, e.g. HttpServletResponse- 返回:
- null if the underlying protocol doesn't provide support for getting response
-
getResponse
public <T> T getResponse(<T> clazz)
Get the response object of the underlying RPC protocol, e.g. HttpServletResponse- 返回:
- null if the underlying protocol doesn't provide support for getting response or the response is not of the specified type
-
setResponse
public void setResponse( response)
-
isProviderSide
public boolean isProviderSide()
is provider side.- 返回:
- provider side.
-
isConsumerSide
public boolean isConsumerSide()
is consumer side.- 返回:
- consumer side.
-
getFuture
public <T> <T> getFuture()
get future.- 类型参数:
T
-- 返回:
- future
-
setFuture
public void setFuture(<?> future)
set future.- 参数:
future
-
-
getUrls
public <URL> getUrls()
-
setUrls
public void setUrls(<URL> urls)
-
getUrl
public URL getUrl()
-
setUrl
public void setUrl(URL url)
-
getMethodName
public getMethodName()
get method name.- 返回:
- method name.
-
setMethodName
public void setMethodName( methodName)
-
getParameterTypes
public <?>[] getParameterTypes()
get parameter types.
-
setParameterTypes
public void setParameterTypes(<?>[] parameterTypes)
-
getArguments
public [] getArguments()
get arguments.- 返回:
- arguments.
-
setArguments
public void setArguments([] arguments)
-
setLocalAddress
public host, int port)
set local address.- 参数:
host
-port
-- 返回:
- context
-
getLocalAddress
public getLocalAddress()
get local address.- 返回:
- local address
-
setLocalAddress
public address)
set local address.- 参数:
address
-- 返回:
- context
-
getLocalAddressString
public getLocalAddressString()
-
getLocalHostName
public getLocalHostName()
get local host name.- 返回:
- local host name
-
setRemoteAddress
public host, int port)
set remote address.- 参数:
host
-port
-- 返回:
- context
-
getRemoteAddress
public getRemoteAddress()
get remote address.- 返回:
- remote address
-
setRemoteAddress
public address)
set remote address.- 参数:
address
-- 返回:
- context
-
getRemoteAddressString
public getRemoteAddressString()
get remote address string.- 返回:
- remote address string.
-
getRemoteHostName
public getRemoteHostName()
get remote host name.- 返回:
- remote host name
-
getLocalHost
public getLocalHost()
get local host.- 返回:
- local host
-
getLocalPort
public int getLocalPort()
get local port.- 返回:
- port
-
getRemoteHost
public getRemoteHost()
get remote host.- 返回:
- remote host
-
getRemotePort
public int getRemotePort()
get remote port.- 返回:
- remote port
-
getAttachment
public getAttachment( key)
get attachment.- 参数:
key
-- 返回:
- attachment
-
setAttachment
public key, value)
set attachment.- 参数:
key
-value
-- 返回:
- context
-
removeAttachment
public key)
remove attachment.- 参数:
key
-- 返回:
- context
-
getAttachments
public <,> getAttachments()
get attachments.- 返回:
- attachments
-
setAttachments
public <,> attachment)
set attachments- 参数:
attachment
-- 返回:
- context
-
clearAttachments
public void clearAttachments()
-
get
public <,> get()
get values.- 返回:
- values
-
set
public key, value)
set value.- 参数:
key
-value
-- 返回:
- context
-
remove
public key)
remove value.- 参数:
key
-- 返回:
- value
-
get
public get( key)
get value.- 参数:
key
-- 返回:
- value
-
isServerSide
public boolean isServerSide()
已过时。Replace to isProviderSide()
-
isClientSide
public boolean isClientSide()
已过时。Replace to isConsumerSide()
-
getInvokers
public <Invoker<?>> getInvokers()
已过时。Replace to getUrls()
-
setInvokers
public <Invoker<?>> invokers)
-
getInvoker
public Invoker<?> getInvoker()
已过时。Replace to getUrl()
-
setInvoker
public RpcContext setInvoker(Invoker<?> invoker)
-
getInvocation
public Invocation getInvocation()
已过时。Replace to getMethodName(), getParameterTypes(), getArguments()
-
setInvocation
public RpcContext setInvocation(Invocation invocation)
-
asyncCall
public <T> <T> asyncCall(<T> callable)
Async invocation. Timeout will be handled even ifFuture.get()
is not called.- 参数:
callable
-- 返回:
- get the return result from
future.get()
-
asyncCall
public void asyncCall( runnable)
one way async call, send request only, and result is not required- 参数:
runnable
-
-
-