summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/databinding/src/main/java
diff options
context:
space:
mode:
authorbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-11-14 22:32:24 +0000
committerbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-11-14 22:32:24 +0000
commitebc9f8e8938b56b0564ca447fef38ba42db689dd (patch)
tree91f7ad5ea13a1a5e1b4776e31d1f9c845addbab0 /sca-java-2.x/trunk/modules/databinding/src/main/java
parent5670f96c39fb938bfc6951dcb87d623a2d03bf8d (diff)
TUSCANY-3664 Add support for multiple operation output types
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1035090 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/databinding/src/main/java')
-rw-r--r--sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java52
1 files changed, 43 insertions, 9 deletions
diff --git a/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java b/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java
index 5227b95432..5137338f4d 100644
--- a/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java
+++ b/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java
@@ -386,14 +386,10 @@ public class MediatorImpl implements Mediator {
Operation sourceOperation,
Operation targetOperation,
Map<String, Object> metadata) {
- // Create a data type to represent the ouput produced by the target operation
- DataType<DataType> targetType =
- new DataTypeImpl<DataType>(IDL_OUTPUT, Object.class, targetOperation.getOutputType());
-
- // Create a data type to represent the ouput expected by the source operation
- DataType<DataType> sourceType =
- new DataTypeImpl<DataType>(IDL_OUTPUT, Object.class, sourceOperation.getOutputType());
-
+
+ DataType sourceType = new DataTypeImpl<DataType>(IDL_OUTPUT, Object.class, sourceOperation.getOutputType());
+ DataType targetType = new DataTypeImpl<DataType>(IDL_OUTPUT, Object.class, targetOperation.getOutputType());
+
if (sourceType == targetType || (sourceType != null && sourceType.equals(targetType))) {
return output;
}
@@ -579,7 +575,45 @@ public class MediatorImpl implements Mediator {
}
public Object copyOutput(Object data, Operation sourceOperation, Operation targetOperation) {
- return copy(data, targetOperation.getOutputType(), sourceOperation.getOutputType(), targetOperation, sourceOperation);
+ if ( data == null )
+ return null;
+ Object[] output = null;
+
+ if ( !sourceOperation.hasHolders() ) {
+ output = new Object[] {data};
+ } else {
+ output = (Object[])data;
+ }
+
+ List<DataType> outputTypes = sourceOperation.getOutputType().getLogical();
+ List<DataType> outputTypesTarget = targetOperation == null ? null : targetOperation.getOutputType().getLogical();
+ Object[] copy = new Object[output.length];
+ Map<Object, Object> map = new IdentityHashMap<Object, Object>();
+ for (int i = 0, size = output.length; i < size; i++) {
+ Object arg = output[i];
+ if (arg == null) {
+ copy[i] = null;
+ } else {
+ Object copiedArg = map.get(arg);
+ if (copiedArg != null) {
+ copy[i] = copiedArg;
+ } else {
+ copiedArg =
+ copy(arg,
+ outputTypes.get(i),
+ outputTypesTarget == null ? null : outputTypesTarget.get(i),
+ sourceOperation,
+ targetOperation);
+ map.put(arg, copiedArg);
+ copy[i] = copiedArg;
+ }
+ }
+ }
+ if ( !targetOperation.hasHolders()) {
+ return copy[0];
+ } else {
+ return copy;
+ }
}
public Object copyFault(Object fault, Operation operation) {