summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2010-10-05 18:03:40 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2010-10-05 18:03:40 +0000
commit4ca27050351a4ac333738843fe39f6a286ed7dc6 (patch)
tree97f63d2f3d58b848bdb6777b764f64253552776d /sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java
parentf1066798d7017fb1b86d674ee14e927194918108 (diff)
TUSCANY-3705 - Adding support for JSON-RPC Notifications when using JSON-RPC binding in reference
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1004743 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java')
-rw-r--r--sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java39
1 files changed, 27 insertions, 12 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java
index c24d90e2d0..9c379bd4e9 100644
--- a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java
+++ b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java
@@ -302,10 +302,11 @@ public class JSONRPCServiceServlet extends JSONRPCServlet {
requestMessage.getHeaders().put("RequestMessage", request);
- if (jsonOperation.getWrapper().getDataBinding().equals(JSONDataBinding.NAME))
+ if (jsonOperation.getWrapper().getDataBinding().equals(JSONDataBinding.NAME)) {
requestMessage.setBody(new Object[]{jsonReq.toString()});
- else
+ } else {
requestMessage.setBody(args);
+ }
//result = wire.invoke(jsonOperation, args);
Message responseMessage = null;
@@ -327,16 +328,30 @@ public class JSONRPCServiceServlet extends JSONRPCServlet {
result = responseMessage.getBody();
return result.toString().getBytes("UTF-8");
} else {
- try {
- result = responseMessage.getBody();
- JSONObject jsonResponse = new JSONObject();
- jsonResponse.put("result", result);
- jsonResponse.putOpt("id", id);
- //get response to send to client
- return jsonResponse.toString().getBytes("UTF-8");
- } catch (Exception e) {
- throw new ServiceRuntimeException("Unable to create JSON response", e);
- }
+ if (jsonOperation.getOutputType() == null) {
+ // void operation (json-rpc notification)
+ try {
+ JSONObject jsonResponse = new JSONObject();
+ jsonResponse.put("result", "");
+ //get response to send to client
+ return jsonResponse.toString().getBytes("UTF-8");
+ } catch (Exception e) {
+ throw new ServiceRuntimeException("Unable to create JSON response", e);
+ }
+
+ } else {
+ // regular operation returning some value
+ try {
+ result = responseMessage.getBody();
+ JSONObject jsonResponse = new JSONObject();
+ jsonResponse.put("result", result);
+ jsonResponse.putOpt("id", id);
+ //get response to send to client
+ return jsonResponse.toString().getBytes("UTF-8");
+ } catch (Exception e) {
+ throw new ServiceRuntimeException("Unable to create JSON response", e);
+ }
+ }
}
} else {
//exception thrown while executing the invocation