Package org.apache.tuscany.sca.binding.jsonrpc.protocol

Examples of org.apache.tuscany.sca.binding.jsonrpc.protocol.JsonRpcResponse


        try {
            if (root.isArray()) {
                ArrayNode input = (ArrayNode)root;
                JsonRpc20BatchRequest batchReq = new JsonRpc20BatchRequest(input);
                for (int i = 0; i < batchReq.getRequests().size(); i++) {
                    JsonRpcResponse result = batchReq.getBatchResponse().getResponses().get(i);
                    if (result == null) {
                        result = invoke(batchReq.getRequests().get(i));
                        batchReq.getBatchResponse().getResponses().set(i, result);
                    }
                }
                ArrayNode responses = batchReq.getBatchResponse().toJSONArray();
                JacksonHelper.MAPPER.writeValue(response.getWriter(), responses);
            } else {
                if (root.has("jsonrpc")) {
                    JsonRpc20Request jsonReq = new JsonRpc20Request((ObjectNode)root);
                    JsonRpcResponse jsonResult = invoke(jsonReq);
                    if (jsonResult != null) {
                        jsonResult.write(response.getWriter());
                    }
                } else {
                    JsonRpc10Request jsonReq = new JsonRpc10Request((ObjectNode)root);
                    JsonRpc10Response jsonResult = invoke(jsonReq);
                    if (jsonResult != null) {
                        jsonResult.write(response.getWriter());
                    }
                }
            }
        } catch (Throwable e) {
            throw new ServletException(e);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.binding.jsonrpc.protocol.JsonRpcResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.