diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules')
13 files changed, 140 insertions, 48 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; } } diff --git a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java index 7a522beecc..2801690f41 100644 --- a/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java +++ b/sca-java-2.x/trunk/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java @@ -91,7 +91,7 @@ class AtomReferenceBindingProvider implements ReferenceBindingProvider { // Determine the collection item type itemXMLType = new DataTypeImpl<Class<?>>(String.class.getName(), String.class, String.class); Class<?> itemClass = operation.getOutputType().getPhysical(); - DataType<XMLType> outputType = operation.getOutputType(); + DataType<XMLType> outputType = operation.getOutputType().getLogical().get(0); itemClassType = outputType; if (itemClassType.getPhysical() == org.apache.abdera.model.Entry.class) { supportsFeedEntries = true; diff --git a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestOperation.java b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestOperation.java index 8cfcf7af5c..1a82a16bbd 100644 --- a/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestOperation.java +++ b/sca-java-2.x/trunk/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestOperation.java @@ -180,4 +180,22 @@ public class TestOperation implements Operation { return null; } + public List<DataType> getOutputTypes() { + // TODO Auto-generated method stub + return null; + } + + + public boolean hasHolders() { + // TODO Auto-generated method stub + return false; + } + + public void setHasHolders(boolean arg0) { + // TODO Auto-generated method stub + + } + + + } diff --git a/sca-java-2.x/trunk/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/ComplexStuffTestCase.java b/sca-java-2.x/trunk/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/ComplexStuffTestCase.java index d15f898531..704a24554b 100644 --- a/sca-java-2.x/trunk/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/ComplexStuffTestCase.java +++ b/sca-java-2.x/trunk/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/ComplexStuffTestCase.java @@ -70,7 +70,13 @@ public class ComplexStuffTestCase { public void testEchoBean() throws Exception {
URL url = new URL("http://localhost:8080/ComplexComponent/ComplexStuff/echoBeanA?x={\"s\":\"petra\",\"b\":true,\"y\":42,\"x\":1}");
InputStream is = url.openStream();
- Assert.assertEquals("{\"s\":\"petra\",\"b\":true,\"y\":42,\"x\":1}", read(is));
+ String result = read(is);
+ Assert.assertTrue(result.startsWith("{"));
+ Assert.assertTrue(result.contains("\"s\":\"petra\""));
+ Assert.assertTrue(result.contains("\"b\":true"));
+ Assert.assertTrue(result.contains("\"y\":42"));
+ Assert.assertTrue(result.contains("\"x\":1"));
+ // Assert.assertEquals("{\"s\":\"petra\",\"b\":true,\"y\":42,\"x\":1}", read(is));
}
@Test
diff --git a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCDatabindingHelper.java b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCDatabindingHelper.java index f9b37f30b2..fc43835b9b 100644 --- a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCDatabindingHelper.java +++ b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCDatabindingHelper.java @@ -52,12 +52,14 @@ public class JSONRPCDatabindingHelper { } } } - DataType outputType = operation.getOutputType(); - if (outputType != null) { - if (!SimpleJavaDataBinding.NAME.equals(outputType.getDataBinding()) || - outputType.getPhysical() == BigDecimal.class ) { - outputType.setDataBinding(JSONDataBinding.NAME); - } + + for (DataType outputType : operation.getOutputType().getLogical() ) { + if (outputType != null) { + if (!SimpleJavaDataBinding.NAME.equals(outputType.getDataBinding()) || + outputType.getPhysical() == BigDecimal.class ) { + outputType.setDataBinding(JSONDataBinding.NAME); + } + } } } } diff --git a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java index 1e4292e66a..7ecfa83893 100644 --- a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java +++ b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java @@ -328,7 +328,7 @@ public class JSONRPCServiceServlet extends JSONRPCServlet { result = responseMessage.getBody(); return result.toString().getBytes("UTF-8"); } else { - if (jsonOperation.getOutputType() == null) { + if (jsonOperation.getOutputType().getLogical().get(0) == null) { // void operation (json-rpc notification) try { JSONObject jsonResponse = new JSONObject(); diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java index 1673f3aefa..2463883b80 100644 --- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java +++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTBindingInvoker.java @@ -140,7 +140,7 @@ public class RESTBindingInvoker implements Invoker { } if (operation.getOutputType() != null) { - responseType = operation.getOutputType().getPhysical(); + responseType = operation.getOutputType().getLogical().get(0).getPhysical(); } else { responseType = null; } diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatServiceProvider.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatServiceProvider.java index fcb311a105..754fdfc73e 100644 --- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatServiceProvider.java +++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/json/provider/JSONWireFormatServiceProvider.java @@ -124,11 +124,13 @@ public class JSONWireFormatServiceProvider implements WireFormatProvider { // handle output types if (configureOutput) { - DataType outputType = operation.getOutputType(); - if (outputType != null) { - if (!SimpleJavaDataBinding.NAME.equals(outputType.getDataBinding())) { - outputType.setDataBinding(JSONDataBinding.NAME); - } + List<DataType> outputTypes = operation.getOutputType().getLogical(); + for ( DataType outputType : outputTypes) { + if (outputType != null) { + if (!SimpleJavaDataBinding.NAME.equals(outputType.getDataBinding())) { + outputType.setDataBinding(JSONDataBinding.NAME); + } + } } } } diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatServiceProvider.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatServiceProvider.java index 32d718b509..01b439961c 100644 --- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatServiceProvider.java +++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/wireformat/xml/provider/XMLWireFormatServiceProvider.java @@ -127,9 +127,11 @@ public class XMLWireFormatServiceProvider implements WireFormatProvider { // handle output types if (configureOutput) { - DataType outputType = operation.getOutputType(); - if (outputType != null) { - outputType.setDataBinding(XMLStringDataBinding.NAME); + List<DataType> outputTypes = operation.getOutputType().getLogical(); + for ( DataType outputType : outputTypes ) { + if (outputType != null) { + outputType.setDataBinding(XMLStringDataBinding.NAME); + } } } } |