Class JsonRpcServer

    • Constructor Detail

      • JsonRpcServer

        public JsonRpcServer​(Channel channel,
                             Class<?> interfaceClass,
                             Object interfaceInstance)
                      throws IOException
        Construct a server that talks to the outside world using the given channel, and constructs a fresh temporary queue. Use getQueueName() to discover the created queue name.
        Parameters:
        channel - AMQP channel to use
        interfaceClass - Java interface that this server is exposing to the world
        interfaceInstance - Java instance (of interfaceClass) that is being exposed
        Throws:
        IOException - if something goes wrong during an AMQP operation
      • JsonRpcServer

        public JsonRpcServer​(Channel channel,
                             String queueName,
                             Class<?> interfaceClass,
                             Object interfaceInstance)
                      throws IOException
        Construct a server that talks to the outside world using the given channel and queue name. Our superclass, RpcServer, expects the queue to exist at the time of construction.
        Parameters:
        channel - AMQP channel to use
        queueName - AMQP queue name to listen for requests on
        interfaceClass - Java interface that this server is exposing to the world
        interfaceInstance - Java instance (of interfaceClass) that is being exposed
        Throws:
        IOException - if something goes wrong during an AMQP operation
    • Method Detail

      • doCall

        public String doCall​(String requestBody)
        Runs a single JSON-RPC request.
        Parameters:
        requestBody - the JSON-RPC request string (a JSON encoded value)
        Returns:
        a JSON-RPC response string (a JSON encoded value)
      • matchingMethod

        public Method matchingMethod​(String methodName,
                                     Object[] params)
        Retrieves the best matching method for the given method name and parameters.

        Subclasses may override this if they have specialised dispatching requirements, so long as they continue to honour their ServiceDescription.

      • getServiceDescription

        public ServiceDescription getServiceDescription()
        Public API - gets the service description record that this service built from interfaceClass at construction time.