Package com.nimbusds.common.jsonrpc2
Class JSONRPC2ServiceConnector
java.lang.Object
com.nimbusds.common.jsonrpc2.JSONRPC2ServiceConnector
JSON-RPC 2.0 service connector.
Supports:
- Local connections via a
com.thetransactioncompany.jsonrpc2.server.RequestHandler
interface. - Network (HTTP) connections.
-
Constructor Summary
ConstructorDescriptionJSONRPC2ServiceConnector
(com.thetransactioncompany.jsonrpc2.server.RequestHandler jsonrpc2Service, String apiKey) Creates a new local JSON-RPC 2.0 service connector.JSONRPC2ServiceConnector
(URL url, boolean trustSelfSignedCerts, String apiKey, int connectTimeout, int readTimeout) Creates a new remote (HTTP) JSON-RPC 2.0 service connector. -
Method Summary
Modifier and TypeMethodDescriptionGets the optional API key for service access.long
Gets the next JSON-RPC 2.0 request ID from the atomic counter.boolean
isLocal()
Returnstrue
if the connector is to a local service instance.boolean
isRemote()
Returnsfalse
if the connector is to a remote (HTTP) service instance.com.thetransactioncompany.jsonrpc2.JSONRPC2Response
send
(com.thetransactioncompany.jsonrpc2.JSONRPC2Request request) Sends the specified JSON-RPC 2.0 request to the service (local or remote).
-
Constructor Details
-
JSONRPC2ServiceConnector
public JSONRPC2ServiceConnector(com.thetransactioncompany.jsonrpc2.server.RequestHandler jsonrpc2Service, String apiKey) Creates a new local JSON-RPC 2.0 service connector.- Parameters:
jsonrpc2Service
- The JSON-RPC 2.0 service accessible through a local request handler interface. Must not benull
.apiKey
- Optional API key for service access,null
if not required.
-
JSONRPC2ServiceConnector
public JSONRPC2ServiceConnector(URL url, boolean trustSelfSignedCerts, String apiKey, int connectTimeout, int readTimeout) Creates a new remote (HTTP) JSON-RPC 2.0 service connector.- Parameters:
url
- The JSON-RPC 2.0 service HTTP(S) URL. Must not benull
.trustSelfSignedCerts
- Determines the trust of self-signed X.509 certificates presented by the service (for HTTPS connections).apiKey
- Optional API key for service access,null
if not required.connectTimeout
- Connect timeout for HTTP requests, in milliseconds. Zero disables the option.readTimeout
- Read timeout for HTTP requests, in milliseconds. Zero disables the option.
-
-
Method Details
-
getAPIKey
Gets the optional API key for service access.- Returns:
- The API key for service access,
null
if not provided.
-
getNextRequestID
Gets the next JSON-RPC 2.0 request ID from the atomic counter.- Returns:
- The next request ID.
-
isLocal
Returnstrue
if the connector is to a local service instance.- Returns:
true
if this is a local service connector.
-
isRemote
Returnsfalse
if the connector is to a remote (HTTP) service instance.- Returns:
true
if this is a remote (HTTP) service connector.
-
send
public com.thetransactioncompany.jsonrpc2.JSONRPC2Response send(com.thetransactioncompany.jsonrpc2.JSONRPC2Request request) throws com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException Sends the specified JSON-RPC 2.0 request to the service (local or remote).- Parameters:
request
- The JSON-RPC 2.0 request to send. Must not benull
.- Returns:
- The received JSON-RPC 2.0 response.
- Throws:
com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException
- If the request call failed due to a service connection or other exception.
-