public class JsonRpcClient extends RpcClient implements InvocationHandler
JsonRpcClient
class.
JSON-RPC services are self-describing - each service is able
to list its supported procedures, and each procedure
describes its parameters and types. An instance of
JsonRpcClient retrieves its service description using the
standard system.describe
procedure when it is
constructed, and uses the information to coerce parameter
types appropriately. A JSON service description is parsed
into instances of ServiceDescription
. Client
code can access the service description by reading the
serviceDescription
field of
JsonRpcClient
instances.
JsonRpcClient
delegates JSON parsing and generating to
a JsonRpcMapper
.
call(String, Object[])
,
JsonRpcMapper
,
JacksonJsonRpcMapper
RpcClient.Response
DEFAULT_REPLY_HANDLER, NO_TIMEOUT
Constructor and Description |
---|
JsonRpcClient(Channel channel,
String exchange,
String routingKey) |
JsonRpcClient(Channel channel,
String exchange,
String routingKey,
int timeout)
Construct a new JsonRpcClient, passing the parameters through
to RpcClient's constructor.
|
JsonRpcClient(Channel channel,
String exchange,
String routingKey,
int timeout,
JsonRpcMapper mapper)
Construct a new JsonRpcClient, passing the parameters through
to RpcClient's constructor.
|
JsonRpcClient(RpcClientParams rpcClientParams,
JsonRpcMapper mapper)
|
Modifier and Type | Method and Description |
---|---|
Object |
call(String[] args)
Deprecated.
This method will be removed in the next major version
|
Object |
call(String method,
Object[] params)
Public API - builds, encodes and sends a JSON-RPC request, and
waits for the response.
|
static Object |
coerce(String val,
String type)
Deprecated.
This method will be removed in the next major version
|
<T> T |
createProxy(Class<T> klass)
Public API - gets a dynamic proxy for a particular interface class.
|
ServiceDescription |
getServiceDescription()
Public API - gets the service description record that this
service loaded from the server itself at construction time.
|
Object |
invoke(Object proxy,
Method method,
Object[] args)
Public API - implements InvocationHandler.invoke.
|
checkConsumer, close, doCall, doCall, getChannel, getConsumer, getContinuationMap, getCorrelationId, getExchange, getRoutingKey, incrementingCorrelationIdSupplier, incrementingCorrelationIdSupplier, mapCall, mapCall, primitiveCall, primitiveCall, primitiveCall, publish, responseCall, responseCall, setupConsumer, stringCall
public JsonRpcClient(RpcClientParams rpcClientParams, JsonRpcMapper mapper) throws IOException, JsonRpcException, TimeoutException
JsonRpcClient
, passing the RpcClientParams
through RpcClient
's constructor.
The service description record is retrieved from the server during construction.
rpcClientParams
- mapper
- IOException
JsonRpcException
TimeoutException
public JsonRpcClient(Channel channel, String exchange, String routingKey, int timeout, JsonRpcMapper mapper) throws IOException, JsonRpcException, TimeoutException
TimeoutException
- if a response is not received within the timeout specified, if anyIOException
JsonRpcException
public JsonRpcClient(Channel channel, String exchange, String routingKey, int timeout) throws IOException, JsonRpcException, TimeoutException
TimeoutException
- if a response is not received within the timeout specified, if anyIOException
JsonRpcException
public JsonRpcClient(Channel channel, String exchange, String routingKey) throws IOException, JsonRpcException, TimeoutException
@Deprecated public static Object coerce(String val, String type) throws NumberFormatException
call(String[])
to ad-hoc convert
strings into the required data types for a call.
This method is deprecated because it uses homegrown JSON utilities
that don't deal correctly with complex types. The JacksonJsonRpcMapper
has been introduced to handle primitive and complex types, as well
as primitive wrappers correctly.NumberFormatException
public Object call(String method, Object[] params) throws IOException, JsonRpcException, TimeoutException
JsonRpcException
- if the reply object contained an exceptionTimeoutException
- if a response is not received within the timeout specified, if anyIOException
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
invoke
in interface InvocationHandler
Throwable
public <T> T createProxy(Class<T> klass) throws IllegalArgumentException
IllegalArgumentException
@Deprecated public Object call(String[] args) throws NumberFormatException, IOException, JsonRpcException, TimeoutException
call(String, Object[])
, but takes the
method name from the first entry in args
, and the
parameters from subsequent entries. All parameter values are
passed through coerce() to attempt to make them the types the
server is expecting.
This method is deprecated because it uses homegrown JSON utilities
that don't deal correctly with complex types. The JacksonJsonRpcMapper
has been introduced to handle primitive and complex types, as well
as primitive wrappers correctly.JsonRpcException
- if the reply object contained an exceptionNumberFormatException
- if a coercion failedTimeoutException
- if a response is not received within the timeout specified, if anyIOException
coerce(java.lang.String, java.lang.String)
public ServiceDescription getServiceDescription()
Copyright © 2022 VMware, Inc. or its affiliates.. All rights reserved.