summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-10-09 22:55:37 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-10-09 22:55:37 +0000
commit8c67595b5299dd0b4691ef0c93c01df3c818c74b (patch)
tree1b80129116dba29c05869595ca6683454b489abd
parent8020246860aa8ff999acf40f199a8522d4496d93 (diff)
Improve the bindings to avoid data copy
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@823730 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/sca/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java7
-rw-r--r--java/sca/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java8
-rw-r--r--java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingInvoker.java7
-rw-r--r--java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCClientInvoker.java8
-rw-r--r--java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java8
-rw-r--r--java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java14
6 files changed, 39 insertions, 13 deletions
diff --git a/java/sca/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java b/java/sca/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java
index 5fd380dab6..c7552f932e 100644
--- a/java/sca/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java
+++ b/java/sca/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java
@@ -40,6 +40,7 @@ import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.tuscany.sca.binding.atom.collection.NotFoundException;
import org.apache.tuscany.sca.data.collection.Entry;
import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
import org.oasisopen.sca.ServiceRuntimeException;
@@ -49,7 +50,7 @@ import org.oasisopen.sca.ServiceRuntimeException;
*
* @version $Rev$ $Date$
*/
-class AtomBindingInvoker implements Invoker {
+class AtomBindingInvoker implements Invoker, DataExchangeSemantics {
private static final Factory abderaFactory = Abdera.getNewFactory();
private static final Parser abderaParser = Abdera.getNewParser();
@@ -507,4 +508,8 @@ class AtomBindingInvoker implements Invoker {
}
}
+ public boolean allowsPassByReference() {
+ return true;
+ }
+
}
diff --git a/java/sca/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java b/java/sca/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java
index 0557bda04e..851f4b53c9 100644
--- a/java/sca/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java
+++ b/java/sca/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java
@@ -34,6 +34,7 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
import org.codehaus.jackson.JsonGenerationException;
@@ -41,7 +42,7 @@ import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.map.JsonMappingException;
import org.codehaus.jackson.map.ObjectMapper;
-public class JSONPInvoker implements Invoker {
+public class JSONPInvoker implements Invoker, DataExchangeSemantics {
protected Operation operation;
protected EndpointReference endpoint;
@@ -157,5 +158,8 @@ public class JSONPInvoker implements Invoker {
Object[] args = (Object[])mapper.readValue("[" + jsonRequest +"]", c);
return args;
}
-
+
+ public boolean allowsPassByReference() {
+ return true;
+ }
}
diff --git a/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingInvoker.java b/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingInvoker.java
index 9767f6f46b..12f69dffc7 100644
--- a/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingInvoker.java
+++ b/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingInvoker.java
@@ -25,6 +25,7 @@ import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding;
import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
import org.json.JSONArray;
@@ -35,7 +36,7 @@ import org.json.JSONObject;
*
* @version $Rev$ $Date$
*/
-public class JSONRPCBindingInvoker implements Invoker {
+public class JSONRPCBindingInvoker implements Invoker, DataExchangeSemantics {
private EndpointReference endpointReference;
private Operation operation;
private String uri;
@@ -139,4 +140,8 @@ public class JSONRPCBindingInvoker implements Invoker {
return jsonRequest;
}
+
+ public boolean allowsPassByReference() {
+ return true;
+ }
}
diff --git a/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCClientInvoker.java b/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCClientInvoker.java
index 962c269673..3290993d80 100644
--- a/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCClientInvoker.java
+++ b/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCClientInvoker.java
@@ -26,6 +26,7 @@ import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
import org.jabsorb.client.Client;
@@ -37,7 +38,7 @@ import org.jabsorb.client.TransportRegistry;
*
* @version $Rev$ $Date$
*/
-public class JSONRPCClientInvoker implements Invoker {
+public class JSONRPCClientInvoker implements Invoker, DataExchangeSemantics {
private EndpointReference endpointReference;
private Operation operation;
private Method method;
@@ -69,5 +70,8 @@ public class JSONRPCClientInvoker implements Invoker {
}
return msg;
}
-
+
+ public boolean allowsPassByReference() {
+ return true;
+ }
}
diff --git a/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java b/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java
index c8ad274316..26d6133472 100644
--- a/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java
+++ b/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java
@@ -20,6 +20,8 @@ package org.apache.tuscany.sca.databinding;
import java.io.IOException;
import java.lang.reflect.Constructor;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -228,7 +230,11 @@ public class DefaultDataBindingExtensionPoint implements DataBindingExtensionPoi
return false;
}
Class<?> componentType = physical.getComponentType();
- DataType logical = new DataTypeImpl(componentType, dataType.getLogical());
+ Type genericComponentType = componentType;
+ if(dataType.getGenericType() instanceof GenericArrayType) {
+ genericComponentType = ((GenericArrayType) dataType.getGenericType()).getGenericComponentType();
+ }
+ DataType logical = new DataTypeImpl(dataType.getDataBinding(), componentType, genericComponentType, dataType.getLogical());
introspectType(logical, operation);
dataType.setDataBinding("java:array");
dataType.setLogical(logical);
diff --git a/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java b/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java
index 1c90446702..195c04e9c2 100644
--- a/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java
+++ b/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java
@@ -476,12 +476,14 @@ public class MediatorImpl implements Mediator {
// If no databinding was specified, introspect the given arg to
// determine its databinding
if (dataBinding == null) {
- dataType = dataBindings.introspectType(data, operation);
- if (dataType != null) {
- String db = dataType.getDataBinding();
- dataBinding = dataBindings.getDataBinding(db);
- if (dataBinding == null && db != null) {
- return data;
+ if (!"java:array".equals(dataType.getDataBinding())) {
+ dataType = dataBindings.introspectType(data, operation);
+ if (dataType != null) {
+ String db = dataType.getDataBinding();
+ dataBinding = dataBindings.getDataBinding(db);
+ if (dataBinding == null && db != null) {
+ return data;
+ }
}
}
if (dataBinding == null) {