summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/assembly
diff options
context:
space:
mode:
authorbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-11-14 22:34:32 +0000
committerbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-11-14 22:34:32 +0000
commitda521c2a4e5904efcec4c702d4c90e18e0e8745d (patch)
tree236e29656cc292ac8757347232bc99dd447c68aa /sca-java-2.x/trunk/modules/assembly
parentebc9f8e8938b56b0564ca447fef38ba42db689dd (diff)
TUSCANY-3664 Add support for multiple operation output types
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1035091 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/assembly')
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java15
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java35
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java9
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java40
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java23
5 files changed, 92 insertions, 30 deletions
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java
index 71c641fa38..fd47ece34c 100644
--- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java
@@ -79,13 +79,12 @@ public interface Operation extends Cloneable, PolicySubject {
* Get the data type for the output
*
* @return the outputType
- */
- DataType getOutputType();
-
+ */
+ DataType<List<DataType>> getOutputType();
/**
* @param outputType
*/
- void setOutputType(DataType outputType);
+ void setOutputType(DataType<List<DataType>> outputType);
/**
* Get a list of data types to represent the faults/exceptions
@@ -206,4 +205,12 @@ public interface Operation extends Cloneable, PolicySubject {
* @return
*/
List<ParameterMode> getParameterModes();
+
+ /**
+ * Returns true
+ * @return
+ */
+ public boolean hasHolders();
+
+ public void setHasHolders(boolean value);
}
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
index 3dedb5e62c..c28694c930 100644
--- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.interfacedef.impl;
+import java.util.ArrayList;
import java.util.List;
import javax.xml.namespace.QName;
@@ -252,21 +253,23 @@ public class InterfaceContractMapperImpl implements InterfaceContractMapper {
// FIXME: We need to deal with wrapped<-->unwrapped conversion
// Check output type
- DataType<?> sourceOutputType = source.getOutputType();
- DataType<?> targetOutputType = target.getOutputType();
+ List<DataType> sourceOutputType = source.getOutputType().getLogical();
+ List<DataType> targetOutputType = target.getOutputType().getLogical();
boolean checkSourceWrapper = true;
List<DataType> sourceInputType = source.getInputType().getLogical();
if (source.isWrapperStyle() && source.getWrapper() != null) {
sourceInputType = source.getWrapper().getUnwrappedInputType().getLogical();
- sourceOutputType = source.getWrapper().getUnwrappedOutputType();
+ sourceOutputType = new ArrayList<DataType>();
+ sourceOutputType.add(source.getWrapper().getUnwrappedOutputType());
checkSourceWrapper = false;
}
boolean checkTargetWrapper = true;
List<DataType> targetInputType = target.getInputType().getLogical();
if (target.isWrapperStyle() && target.getWrapper() != null) {
targetInputType = target.getWrapper().getUnwrappedInputType().getLogical();
- targetOutputType = target.getWrapper().getUnwrappedOutputType();
+ targetOutputType = new ArrayList<DataType>();
+ targetOutputType.add(target.getWrapper().getUnwrappedOutputType());
checkTargetWrapper = false;
}
@@ -276,13 +279,25 @@ public class InterfaceContractMapperImpl implements InterfaceContractMapper {
}
*/
- if (!isCompatible(targetOutputType, sourceOutputType, passByValue, audit)) {
- if (audit != null){
- audit.append(" output types");
- audit.appendSeperator();
- }
- return false;
+
+ if ( sourceOutputType.size() != targetOutputType.size()) {
+ if (audit != null){
+ audit.append("different number of output types");
+ audit.appendSeperator();
+ }
+ return false;
+ }
+
+ for ( int i=0; i < sourceOutputType.size(); i++) {
+ if (!isCompatible(targetOutputType.get(i), sourceOutputType.get(i), passByValue, audit)) {
+ if (audit != null){
+ audit.append(" output types");
+ audit.appendSeperator();
+ }
+ return false;
+ }
}
+
if (sourceInputType.size() != targetInputType.size()) {
if (audit != null){
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java
index c56b5545ce..eeab73e14e 100644
--- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java
@@ -199,10 +199,13 @@ public class InterfaceImpl implements Interface {
setDataBinding(d, dataBinding);
}
}
- DataType outputType = op.getOutputType();
- if (outputType != null) {
- setDataBinding(outputType, dataBinding);
+ List<DataType> outputTypes = op.getOutputType().getLogical();
+ for ( DataType outputType : outputTypes ) {
+ if (outputType != null) {
+ setDataBinding(outputType, dataBinding);
+ }
}
+
List<DataType> faultTypes = op.getFaultTypes();
if (faultTypes != null) {
for (DataType d : faultTypes) {
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java
index 21debb6ea3..350135d974 100644
--- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java
@@ -45,8 +45,7 @@ import org.apache.tuscany.sca.policy.PolicySet;
public class OperationImpl implements Operation {
private String name;
- private boolean unresolved;
- private DataType outputType;
+ private boolean unresolved;
private DataType<List<DataType>> inputType;
private List<DataType> faultTypes;
private Interface interfaze;
@@ -64,6 +63,8 @@ public class OperationImpl implements Operation {
private List<PolicySet> policySets = new ArrayList<PolicySet>();
private List<Intent> requiredIntents = new ArrayList<Intent>();
private ExtensionType type;
+ private DataType<List<DataType>> outputType;
+ private boolean hasHolders;
/**
* @param name
@@ -121,15 +122,16 @@ public class OperationImpl implements Operation {
/**
* @return the outputType
*/
- public DataType getOutputType() {
- return outputType;
- }
+ public DataType<List<DataType>> getOutputType() {
+ return this.outputType;
+ }
+
/**
* @param outputType the outputType to set
*/
- public void setOutputType(DataType outputType) {
- this.outputType = outputType;
+ public void setOutputType(DataType<List<DataType>> outputType) {
+ this.outputType = outputType;
}
/**
@@ -234,8 +236,20 @@ public class OperationImpl implements Operation {
clonedInputType.setDataBinding(inputType.getDataBinding());
copy.inputType = clonedInputType;
- if (this.outputType != null) {
- copy.outputType = (DataType) this.outputType.clone();
+ if ( outputType != null ) {
+ List<DataType> clonedLogicalOutputTypes = new ArrayList<DataType>();
+ for ( DataType t : outputType.getLogical()) {
+ if ( t == null ) {
+ clonedLogicalOutputTypes.add(null);
+ } else {
+ DataType type = (DataType) t.clone();
+ clonedLogicalOutputTypes.add(type);
+ }
+ }
+ DataType<List<DataType>> clonedOutputType =
+ new DataTypeImpl<List<DataType>>(outputType.getPhysical(), clonedLogicalOutputTypes);
+ clonedOutputType.setDataBinding(outputType.getDataBinding());
+ copy.outputType = clonedOutputType;
}
copy.attributes = new ConcurrentHashMap<Object, Object>();
@@ -284,5 +298,13 @@ public class OperationImpl implements Operation {
public List<ParameterMode> getParameterModes() {
return this.parameterModes;
}
+
+ public boolean hasHolders() {
+ return this.hasHolders;
+ }
+
+ public void setHasHolders(boolean value) {
+ this.hasHolders = value;
+ }
}
diff --git a/sca-java-2.x/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java b/sca-java-2.x/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java
index 603d393e5c..8d945038bf 100644
--- a/sca-java-2.x/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java
+++ b/sca-java-2.x/trunk/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java
@@ -189,7 +189,10 @@ public class ContractCompatibilityTestCase {
@Test
public void testOutputTypes() throws Exception {
InterfaceContract source = new MockContract("FooContract");
- DataType sourceOutputType = new DataTypeImpl<Type>(String.class, String.class);
+ DataType sourceStringType = new DataTypeImpl<Type>(String.class, String.class);
+ ArrayList sourceTypes = new ArrayList();
+ sourceTypes.add(sourceStringType);
+ DataType sourceOutputType = new DataTypeImpl(Object[].class, sourceTypes);
Operation opSource1 = newOperation("op1");
opSource1.setOutputType(sourceOutputType);
Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
@@ -197,7 +200,10 @@ public class ContractCompatibilityTestCase {
source.getInterface().getOperations().addAll(sourceOperations.values());
InterfaceContract target = new MockContract("FooContract");
- DataType targetOutputType = new DataTypeImpl<Type>(String.class, String.class);
+ DataType stringType = new DataTypeImpl<Type>(String.class, String.class);
+ ArrayList types = new ArrayList();
+ types.add(stringType);
+ DataType targetOutputType = new DataTypeImpl(Object[].class, types);
Operation opTarget = newOperation("op1");
opTarget.setOutputType(targetOutputType);
Map<String, Operation> targetOperations = new HashMap<String, Operation>();
@@ -236,7 +242,10 @@ public class ContractCompatibilityTestCase {
@Test
public void testIncompatibleOutputTypes() throws Exception {
InterfaceContract source = new MockContract("FooContract");
- DataType sourceOutputType = new DataTypeImpl<Type>(String.class, String.class);
+ DataType sourceType = new DataTypeImpl<Type>(String.class, String.class);
+ ArrayList sourceTypes = new ArrayList();
+ sourceTypes.add(sourceType);
+ DataType sourceOutputType = new DataTypeImpl(Object[].class, sourceTypes);
Operation opSource1 = newOperation("op1");
opSource1.setOutputType(sourceOutputType);
Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
@@ -244,7 +253,10 @@ public class ContractCompatibilityTestCase {
source.getInterface().getOperations().addAll(sourceOperations.values());
InterfaceContract target = new MockContract("FooContract");
- DataType targetOutputType = new DataTypeImpl<Type>(Integer.class, Integer.class);
+ DataType targetType = new DataTypeImpl<Type>(Integer.class, Integer.class);
+ ArrayList targetTypes = new ArrayList();
+ targetTypes.add(targetType);
+ DataType targetOutputType = new DataTypeImpl(Object[].class, targetTypes);
Operation opTarget = newOperation("op1");
opTarget.setOutputType(targetOutputType);
Map<String, Operation> targetOperations = new HashMap<String, Operation>();
@@ -391,6 +403,9 @@ public class ContractCompatibilityTestCase {
private static Operation newOperation(String name) {
Operation operation = new OperationImpl();
operation.setName(name);
+ ArrayList<Object> outputTypes = new ArrayList<Object>();
+ outputTypes.add(new DataTypeImpl(Object.class, Object.class));
+ operation.setOutputType(new DataTypeImpl(Object[].class, outputTypes));
return operation;
}
}