You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2010/09/29 12:02:48 UTC

svn commit: r1002551 - in /tuscany/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime: JSONPInvoker.java JSONPServlet.java

Author: slaws
Date: Wed Sep 29 10:02:48 2010
New Revision: 1002551

URL: http://svn.apache.org/viewvc?rev=1002551&view=rev
Log:
Remove commented out cruft

Modified:
    tuscany/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java
    tuscany/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java

Modified: tuscany/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java?rev=1002551&r1=1002550&r2=1002551&view=diff
==============================================================================
--- tuscany/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java (original)
+++ tuscany/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java Wed Sep 29 10:02:48 2010
@@ -66,12 +66,10 @@ public class JSONPInvoker implements Inv
 
     public Message doInvoke(Message msg) throws JsonGenerationException, JsonMappingException, IOException, EncoderException {
         String uri = binding.getURI() + "/" + operation.getName();
-        //String[] jsonArgs = objectsToJSON((Object[])msg.getBody());
         String[] jsonArgs = objectsToJSONStrings((Object[])msg.getBody());
 
         String responseJSON = invokeHTTPRequest(uri, jsonArgs);
 
-        //Object response = jsonToObjects(responseJSON)[0];
         msg.setBody(responseJSON);
 
         return msg;
@@ -142,18 +140,6 @@ public class JSONPInvoker implements Inv
          
          return responseJSON.toString();
     }
-
-/* Not required now JSON conversion is delegated to databinding   
-    protected String[] objectsToJSON(Object[] msgArgs) throws JsonGenerationException, JsonMappingException, IOException {
-        String[] jsonArgs = new String[msgArgs.length];
-        for (int i=0; i<msgArgs.length; i++) {
-            ByteArrayOutputStream os = new ByteArrayOutputStream();
-            mapper.writeValue(os , msgArgs[i]);
-            jsonArgs[i] = os.toString();
-        }
-        return jsonArgs;
-    }
-*/
     
     protected String[] objectsToJSONStrings(Object[] msgArgs) throws JsonGenerationException, JsonMappingException, IOException {
         String[] jsonArgs = new String[msgArgs.length];
@@ -162,13 +148,5 @@ public class JSONPInvoker implements Inv
         }
         return jsonArgs;
     }    
-
-/* Not required now JSON conversion is delegated to databinding    
-    protected Object[] jsonToObjects(String jsonRequest) throws JsonParseException, JsonMappingException, IOException {
-        Class<?> c = new Object[0].getClass();
-        Object[] args = (Object[])mapper.readValue("[" + jsonRequest +"]", c);
-        return args;
-    }
-*/
     
 }

Modified: tuscany/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java?rev=1002551&r1=1002550&r2=1002551&view=diff
==============================================================================
--- tuscany/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java (original)
+++ tuscany/sca-java-1.x/trunk/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java Wed Sep 29 10:02:48 2010
@@ -69,51 +69,12 @@ public class JSONPServlet extends Generi
 
     @Override
     public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
-        //String jsonRequest = getJSONRequest(servletRequest);
-        //Object[] args = jsonToObjects(jsonRequest);
         Object[] args = getJSONRequestStringArray(servletRequest);
         Object response = invokeService(args);        
-        //String jsonResponse = getJSONResponse(servletRequest, response);
         String jsonResponse = getJSONResponseAsString(servletRequest, response);
         servletResponse.getOutputStream().println(jsonResponse);
     }
-
-    /**
-     * Turn the request into JSON 
-     */
-/* Not required now JSON conversion is delegated to databinding       
-    protected String getJSONRequest(ServletRequest servletRequest) throws IOException, JsonParseException, JsonMappingException {
-        
-        List<DataType> types = operation.getInputType().getLogical();
-        int typesIndex = 0;
-        
-        String jsonRequest = "";
-        for (String name : getOrderedParameterNames(servletRequest)) {
-            if (!name.startsWith("_") && !"callback".equals(name)) {
-                if (jsonRequest.length() > 1) {
-                    jsonRequest += ", ";
-                }
-
-                // automatically quote string parammeters so clients work in the usual javascript way
-                if (typesIndex < types.size() && String.class.equals(types.get(typesIndex).getGenericType())) {
-                    String x = servletRequest.getParameter(name);
-                    // TODO: do this more properly
-                    if (!x.startsWith("\"")) {
-                        jsonRequest += "\"" + x + "\"";
-                    } else {
-                        jsonRequest += x;
-                    }
-                } else {
-                    jsonRequest += servletRequest.getParameter(name);
-                }
-                
-            }
-        }
-
-        return "[" + jsonRequest + "]";
-    }
-*/
-    
+   
     /**
      * Turn the request into a string array of JSON structures. The Databinding
      * layer will then convert each of the individual parameters into the appropriate
@@ -176,24 +137,6 @@ public class JSONPServlet extends Generi
 
         return sortedNames;
     }
-
-    /**
-     * Turn the response object into JSON 
-     */
-/* Not required now JSON conversion is delegated to databinding   
-    protected String getJSONResponse(ServletRequest servletRequest, Object response) throws IOException, JsonParseException {
-        ByteArrayOutputStream os = new ByteArrayOutputStream();
-        mapper.writeValue(os , response);
-        String jsonResponse = os.toString();
-
-        String callback = servletRequest.getParameter("callback");
-        if (callback != null && callback.length() > 1) {
-            jsonResponse = callback + "(" + jsonResponse + ");";
-        }
-
-        return jsonResponse;
-    }
-*/
     
     /**
      * The databinding layer will have converterted the return type into a JSON string so simply 
@@ -209,18 +152,7 @@ public class JSONPServlet extends Generi
 
         return jsonResponse;
     }    
-
-    /**
-     * Turn the request JSON into objects 
-     */
-/* Not required now JSON conversion is delegated to databinding       
-    protected Object[] jsonToObjects(String jsonRequest) throws IOException, JsonParseException, JsonMappingException {
-        Class<?> c = new Object[0].getClass();
-        Object[] args = (Object[])mapper.readValue(jsonRequest, c);
-        return args;
-    }
-*/
-    
+   
 
     /**
      * Send the request down the wire to invoke the service