tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r667179 - in /incubator/tuscany/java/sca/modules: core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/ databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/
Date Thu, 12 Jun 2008 17:45:47 GMT
Author: rfeng
Date: Thu Jun 12 10:45:47 2008
New Revision: 667179

URL: http://svn.apache.org/viewvc?rev=667179&view=rev
Log:
Optimize the pass-by-value for immutable types and fix the byte[].copy (TUSCANY-2350)

Modified:
    incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/PassByValueInterceptor.java
    incubator/tuscany/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/SimpleJavaDataBinding.java

Modified: incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/PassByValueInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/PassByValueInterceptor.java?rev=667179&r1=667178&r2=667179&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/PassByValueInterceptor.java
(original)
+++ incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/PassByValueInterceptor.java
Thu Jun 12 10:45:47 2008
@@ -23,9 +23,13 @@
 import java.lang.reflect.Array;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.net.URI;
 import java.util.IdentityHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.UUID;
+
+import javax.xml.namespace.QName;
 
 import org.apache.tuscany.sca.databinding.DataBinding;
 import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
@@ -177,7 +181,18 @@
         if (data == null) {
             return null;
         }
-
+        Class<?> clazz = data.getClass();
+        if (String.class == clazz || clazz.isPrimitive()
+            || Number.class.isAssignableFrom(clazz)
+            || Boolean.class.isAssignableFrom(clazz)
+            || Character.class.isAssignableFrom(clazz)
+            || Byte.class.isAssignableFrom(clazz)
+            || URI.class == clazz
+            || UUID.class == clazz
+            || QName.class == clazz) {
+            // Immutable classes
+            return data;
+        }
         // If no databinding was specified, introspect the given arg to
         // determine its databinding
         if (dataBinding == null) {
@@ -201,7 +216,7 @@
 
             // If the input data is an array containing non Serializable elements
             // use JAXB
-            Class<?> clazz = data.getClass();
+            clazz = data.getClass();
             if (clazz.isArray()) {
                 if (Array.getLength(data) != 0) {
                     Object element = Array.get(data, 0);

Modified: incubator/tuscany/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/SimpleJavaDataBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/SimpleJavaDataBinding.java?rev=667179&r1=667178&r2=667179&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/SimpleJavaDataBinding.java
(original)
+++ incubator/tuscany/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/SimpleJavaDataBinding.java
Thu Jun 12 10:45:47 2008
@@ -44,6 +44,9 @@
 
     @Override
     public Object copy(Object arg, DataType dataType, Operation operation) {
+        if (arg instanceof byte[]) {
+            return ((byte[])arg).clone();
+        }
         return arg;
     }
 



Mime
View raw message