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.
  • 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

    Modifier and Type
    Method
    Description
    Gets the optional API key for service access.
    long
    Gets the next JSON-RPC 2.0 request ID from the atomic counter.
    boolean
    Returns true if the connector is to a local service instance.
    boolean
    Returns false 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).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 be null.
      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 be null.
      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

      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()
      Returns true if the connector is to a local service instance.
      Returns:
      true if this is a local service connector.
    • isRemote

      public boolean isRemote()
      Returns false 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 be null.
      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.