diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-02-11 04:21:00 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-02-11 04:21:00 +0000 |
commit | 45f532168598a09d523eb051fa78c6416f913b2a (patch) | |
tree | 5f2b518acfca5ae0a285f1ace69b5af7ebcd8dd7 /sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org | |
parent | fd16cfb3af0bb7063dcc59210b475dbc98bc3424 (diff) |
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
Diffstat (limited to 'sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org')
-rw-r--r-- | sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java | 17 |
1 files changed, 15 insertions, 2 deletions
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; } |