Package com.nimbusds.common.jsonrpc2
Class JSONRPC2ServiceConnector
- java.lang.Object
-
- com.nimbusds.common.jsonrpc2.JSONRPC2ServiceConnector
-
public class JSONRPC2ServiceConnector extends Object
JSON-RPC 2.0 service connector.Supports:
- Local connections via a
com.thetransactioncompany.jsonrpc2.server.RequestHandler
interface. - Network (HTTP) connections.
- Local connections via a
-
-
Constructor Summary
Constructors Constructor Description JSONRPC2ServiceConnector(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getAPIKey()
Gets the optional API key for service access.long
getNextRequestID()
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 Detail
-
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 Detail
-
getAPIKey
public String getAPIKey()
Gets the optional API key for service access.- Returns:
- The API key for service access,
null
if not provided.
-
getNextRequestID
public long getNextRequestID()
Gets the next JSON-RPC 2.0 request ID from the atomic counter.- Returns:
- The next request ID.
-
isLocal
public boolean isLocal()
Returnstrue
if the connector is to a local service instance.- Returns:
true
if this is a local service connector.
-
isRemote
public boolean 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.
-
-