You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by lr...@apache.org on 2010/10/05 20:03:40 UTC
svn commit: r1004743 -
/tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java
Author: lresende
Date: Tue Oct 5 18:03:40 2010
New Revision: 1004743
URL: http://svn.apache.org/viewvc?rev=1004743&view=rev
Log:
TUSCANY-3705 - Adding support for JSON-RPC Notifications when using JSON-RPC binding in reference
Modified:
tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java
Modified: tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java?rev=1004743&r1=1004742&r2=1004743&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java Tue Oct 5 18:03:40 2010
@@ -302,10 +302,11 @@ public class JSONRPCServiceServlet exten
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 exten
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