From 45f532168598a09d523eb051fa78c6416f913b2a Mon Sep 17 00:00:00 2001 From: antelder Date: Thu, 11 Feb 2010 04:21:00 +0000 Subject: TUSCANY-2586: Fix pass-by-value copies as described in the JIRA with the SCA binding doing the necessary copies. Also update the copy code so that the new copy is in the correct class loader so that invocations across Nodes in the same JVM work git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@908835 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/databinding/jaxb/JAXBDataBinding.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java') diff --git a/sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java b/sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java index bd214cb02c..a23adc75bd 100644 --- a/sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java +++ b/sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java @@ -95,9 +95,14 @@ public class JAXBDataBinding extends BaseDataBinding { return true; } - @SuppressWarnings("unchecked") @Override public Object copy(Object arg, DataType dataType, Operation operation) { + return copy(arg, dataType, operation, dataType); + } + + @SuppressWarnings("unchecked") + @Override + public Object copy(Object arg, DataType dataType, Operation operation, DataType targetDataType) { try { boolean isElement = false; if (dataType == null) { @@ -112,7 +117,15 @@ public class JAXBDataBinding extends BaseDataBinding { arg = JAXBContextHelper.createJAXBElement(context, dataType, arg); Document doc = domHelper.newDocument(); context.createMarshaller().marshal(arg, doc); - Object value = context.createUnmarshaller().unmarshal(doc, dataType.getPhysical()); + + Object value; + if (targetDataType != null && targetDataType.getPhysical() != dataType.getPhysical()) { + JAXBContext targetContext = contextHelper.createJAXBContext(targetDataType); + value = targetContext.createUnmarshaller().unmarshal(doc, targetDataType.getPhysical()); + } else { + value = context.createUnmarshaller().unmarshal(doc, dataType.getPhysical()); + } + if (isElement && value instanceof JAXBElement) { return value; } -- cgit v1.2.3