diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules')
41 files changed, 518 insertions, 429 deletions
diff --git a/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/InterfaceContractProcessor.java b/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/InterfaceContractProcessor.java index d1da967c4d..e1d54f5b6e 100644 --- a/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/InterfaceContractProcessor.java +++ b/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/InterfaceContractProcessor.java @@ -150,7 +150,8 @@ public class InterfaceContractProcessor extends BaseAssemblyProcessor implements operation.setName(getString(reader, "name"));
operation.setDynamic(getBoolean(reader, "isDynamic"));
operation.setNonBlocking(getBoolean(reader, "isNonBlocking"));
- operation.setWrapperStyle(getBoolean(reader, "isWrapperStyle"));
+ operation.setInputWrapperStyle(getBoolean(reader, "isInputWrapperStyle"));
+ operation.setOutputWrapperStyle(getBoolean(reader, "isOutputWrapperStyle"));
inputs = new ArrayList<DataType>();
DataType inputType = new DataTypeImpl<List<DataType>>(null, null);
@@ -276,15 +277,18 @@ public class InterfaceContractProcessor extends BaseAssemblyProcessor implements writer.writeAttribute("name", operation.getName());
writer.writeAttribute("isDynamic", String.valueOf(operation.isDynamic()));
writer.writeAttribute("isNonBlocking", String.valueOf(operation.isNonBlocking()));
- writer.writeAttribute("isWrapperStyle", String.valueOf(operation.isWrapperStyle()));
+ writer.writeAttribute("isInputWrapperStyle", String.valueOf(operation.isInputWrapperStyle()));
+ writer.writeAttribute("isOutputWrapperStyle", String.valueOf(operation.isOutputWrapperStyle()));
List<DataType> outputTypes = operation.getOutputType().getLogical();
List<DataType> inputTypes = operation.getInputType().getLogical();
List<DataType> faultTypes = operation.getFaultTypes();
- if (operation.isWrapperStyle() && operation.getWrapper() != null) {
- inputTypes = operation.getWrapper().getUnwrappedInputType().getLogical();
- outputTypes = operation.getWrapper().getUnwrappedOutputType().getLogical();
+ if (operation.isInputWrapperStyle() && operation.getInputWrapper() != null) {
+ inputTypes = operation.getInputWrapper().getUnwrappedType().getLogical();
+ }
+ if (operation.isOutputWrapperStyle() && operation.getOutputWrapper() != null) {
+ outputTypes = operation.getOutputWrapper().getUnwrappedType().getLogical();
}
writer.writeStartElement(Constants.SCA11_TUSCANY_NS, INPUT);
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 59a79c72d6..100387ce30 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 @@ -130,24 +130,44 @@ public interface Operation extends Cloneable, PolicySubject { /** * @return the wrapperInfo */ - WrapperInfo getWrapper(); + WrapperInfo getInputWrapper(); /** * @param wrapperInfo the wrapperInfo to set */ - void setWrapper(WrapperInfo wrapperInfo); + void setInputWrapper(WrapperInfo wrapperInfo); + + /** + * @return the wrapperInfo + */ + WrapperInfo getOutputWrapper(); + + /** + * @param wrapperInfo the wrapperInfo to set + */ + void setOutputWrapper(WrapperInfo wrapperInfo); /** * @return the wrapperStyle */ - boolean isWrapperStyle(); + boolean isInputWrapperStyle(); /** * @param wrapperStyle the wrapperStyle to set */ - void setWrapperStyle(boolean wrapperStyle); + void setInputWrapperStyle(boolean wrapperStyle); /** + * @return the wrapperStyle + */ + boolean isOutputWrapperStyle(); + + /** + * @param wrapperStyle the wrapperStyle to set + */ + void setOutputWrapperStyle(boolean wrapperStyle); + + /** * @deprecated This should be the WrapperInfo.getDataBinding() * Get the databinding for the operation * @return 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 7e51e38aaf..d04c8b4d97 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 @@ -245,36 +245,29 @@ public class InterfaceContractMapperImpl implements InterfaceContractMapper { boolean passByValue = (source.getInterface().isRemotable()) && byValue; - // if (source.getInterface().isRemotable()) { - // return true; - // } - // FIXME: We need to deal with wrapped<-->unwrapped conversion - // Check output type 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().getLogical(); - 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().getLogical(); - checkTargetWrapper = false; + + if (source.isInputWrapperStyle() && source.getInputWrapper() != null) { + sourceInputType = source.getInputWrapper().getUnwrappedType().getLogical(); + } + + if (source.isOutputWrapperStyle() && source.getOutputWrapper() != null) { + sourceOutputType = source.getOutputWrapper().getUnwrappedType().getLogical(); } - /* TODO - Why are we assuming compatibility if one side is wrapped and the other is not? - if (checkSourceWrapper != checkTargetWrapper) { - return true; + if (target.isInputWrapperStyle() && target.getInputWrapper() != null) { + targetInputType = target.getInputWrapper().getUnwrappedType().getLogical(); + } + + if (target.isOutputWrapperStyle() && target.getOutputWrapper() != null) { + targetOutputType = target.getOutputWrapper().getUnwrappedType().getLogical(); } - */ if ( sourceOutputType.size() != targetOutputType.size()) { if (audit != null){ @@ -294,7 +287,6 @@ public class InterfaceContractMapperImpl implements InterfaceContractMapper { } } - if (sourceInputType.size() != targetInputType.size()) { if (audit != null){ audit.append("different number of input types"); @@ -348,7 +340,9 @@ public class InterfaceContractMapperImpl implements InterfaceContractMapper { @Override public boolean isCompatibleWithoutUnwrapByValue(Operation source, Operation target, Compatibility compatibilityType) { - if (!source.isWrapperStyle() == target.isWrapperStyle()) { + if (!source.isInputWrapperStyle() == target.isInputWrapperStyle()) { + return false; + } else if (!source.isOutputWrapperStyle() == target.isOutputWrapperStyle()) { return false; } else { return isCompatible(source, target, compatibilityType, true); 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 1daa6baf9c..ec7c784547 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 @@ -161,10 +161,10 @@ public class InterfaceImpl implements Interface { } } - if (op.isWrapperStyle()) { - WrapperInfo wrapper = op.getWrapper(); + if (op.isInputWrapperStyle()) { + WrapperInfo wrapper = op.getInputWrapper(); if (wrapper != null) { - DataType<List<DataType>> unwrappedInputType = wrapper.getUnwrappedInputType(); + DataType<List<DataType>> unwrappedInputType = wrapper.getUnwrappedType(); if (unwrappedInputType != null) { for (DataType d : unwrappedInputType.getLogical()) { if (d.getDataBinding() == null) { @@ -172,12 +172,21 @@ public class InterfaceImpl implements Interface { } } } - DataType unwrappedOutputType = wrapper.getUnwrappedOutputType(); - if (unwrappedOutputType != null && unwrappedOutputType.getDataBinding() == null) { - unwrappedOutputType.setDataBinding(dataBinding); - } } } + if (op.isOutputWrapperStyle()) { + WrapperInfo wrapper = op.getOutputWrapper(); + if (wrapper != null) { + DataType<List<DataType>> unwrappedOutputType = wrapper.getUnwrappedType(); + if (unwrappedOutputType != null){ + for (DataType d : unwrappedOutputType.getLogical()) { + if (d.getDataBinding() == null) { + d.setDataBinding(dataBinding); + } + } + } + } + } } } } @@ -188,7 +197,7 @@ public class InterfaceImpl implements Interface { } else { dataType.setDataBinding(dataBinding); } - } + } public void resetDataBinding(String dataBinding) { for (Operation op : getOperations()) { @@ -213,29 +222,34 @@ public class InterfaceImpl implements Interface { setDataBinding((DataType) d.getLogical(), dataBinding); } } - if (op.isWrapperStyle()) { - WrapperInfo wrapper = op.getWrapper(); - if (wrapper != null) { - DataType<List<DataType>> unwrappedInputType = wrapper.getUnwrappedInputType(); + if (op.isInputWrapperStyle()) { + WrapperInfo inputWrapper = op.getInputWrapper(); + if (inputWrapper != null) { + DataType<List<DataType>> unwrappedInputType = inputWrapper.getUnwrappedType(); if (unwrappedInputType != null) { for (DataType d : unwrappedInputType.getLogical()) { setDataBinding(d, dataBinding); } } - DataType<List<DataType>> unwrappedOutputType = wrapper.getUnwrappedOutputType(); + } + } + if (op.isOutputWrapperStyle()) { + WrapperInfo outputWrapper = op.getOutputWrapper(); + if (outputWrapper != null) { + DataType<List<DataType>> unwrappedOutputType = outputWrapper.getUnwrappedType(); if (unwrappedOutputType != null) { for (DataType d : unwrappedOutputType.getLogical()) { setDataBinding(d, dataBinding); } } } - } + } } } public void resetInterfaceInputTypes(Interface newInterface){ for (int i = 0; i < getOperations().size(); i++) { - // only remote interfaces only have a data type model defined + // only remote interfaces have a data type model defined // and in this case operations cannot be overloaded so match // operations by name Operation oldOperation = getOperations().get(i); @@ -255,16 +269,16 @@ public class InterfaceImpl implements Interface { oldOperation.setInputType(newOperation.getInputType()); // set wrapper - if (newOperation.isWrapperStyle()) { - oldOperation.setWrapperStyle(true); - oldOperation.setWrapper(newOperation.getWrapper()); + if (newOperation.isInputWrapperStyle()) { + oldOperation.setInputWrapperStyle(true); + oldOperation.setInputWrapper(newOperation.getInputWrapper()); } } } public void resetInterfaceOutputTypes(Interface newInterface){ for (int i = 0; i < getOperations().size(); i++) { - // only remote interfaces only have a data type model defined + // only remote interfaces have a data type model defined // and in this case operations cannot be overloaded so match // operations by name Operation oldOperation = getOperations().get(i); @@ -287,9 +301,9 @@ public class InterfaceImpl implements Interface { oldOperation.setFaultTypes(newOperation.getFaultTypes()); // set wrapper - if (newOperation.isWrapperStyle()) { - oldOperation.setWrapperStyle(true); - oldOperation.setWrapper(newOperation.getWrapper()); + if (newOperation.isOutputWrapperStyle()) { + oldOperation.setOutputWrapperStyle(true); + oldOperation.setOutputWrapper(newOperation.getOutputWrapper()); } } } 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 b820f95fcf..8d6cbc6d86 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 @@ -51,8 +51,10 @@ public class OperationImpl implements Operation { private Interface interfaze; private List<ParameterMode> parameterModes = new ArrayList<ParameterMode>(); private boolean nonBlocking; - private boolean wrapperStyle; - private WrapperInfo wrapper; + private boolean inputWrapperStyle; + private boolean outputWrapperStyle; + private WrapperInfo inputWrapper; + private WrapperInfo outputWrapper; private boolean dynamic; private boolean notSubjectToWrapping; @@ -167,38 +169,75 @@ public class OperationImpl implements Operation { /** * @return the wrapperInfo */ - public WrapperInfo getWrapper() { - return wrapper; + public WrapperInfo getInputWrapper() { + return inputWrapper; } /** * @param wrapperInfo the wrapperInfo to set */ - public void setWrapper(WrapperInfo wrapperInfo) { - this.wrapper = wrapperInfo; + public void setInputWrapper(WrapperInfo wrapperInfo) { + this.inputWrapper = wrapperInfo; } + + /** + * @return the wrapperInfo + */ + public WrapperInfo getOutputWrapper() { + return outputWrapper; + } + + /** + * @param wrapperInfo the wrapperInfo to set + */ + public void setOutputWrapper(WrapperInfo wrapperInfo) { + this.outputWrapper = wrapperInfo; + } /** * @return the wrapperStyle */ - public boolean isWrapperStyle() { - return wrapperStyle; + public boolean isInputWrapperStyle() { + return inputWrapperStyle; } /** * @param wrapperStyle the wrapperStyle to set */ - public void setWrapperStyle(boolean wrapperStyle) { - this.wrapperStyle = wrapperStyle; + public void setInputWrapperStyle(boolean wrapperStyle) { + this.inputWrapperStyle = wrapperStyle; + } + + /** + * @return the wrapperStyle + */ + public boolean isOutputWrapperStyle() { + return outputWrapperStyle; } + /** + * @param wrapperStyle the wrapperStyle to set + */ + public void setOutputWrapperStyle(boolean wrapperStyle) { + this.outputWrapperStyle = wrapperStyle; + } + public String getDataBinding() { - return wrapper != null ? wrapper.getDataBinding() : null; + if (inputWrapper != null){ + return inputWrapper.getDataBinding(); + } + if (outputWrapper != null){ + return outputWrapper.getDataBinding(); + } + return null; } public void setDataBinding(String dataBinding) { - if (wrapper != null) { - wrapper.setDataBinding(dataBinding); + if (inputWrapper != null) { + inputWrapper.setDataBinding(dataBinding); + } + if (outputWrapper != null) { + outputWrapper.setDataBinding(dataBinding); } } @@ -258,8 +297,12 @@ public class OperationImpl implements Operation { copy.attributes.putAll(attributes); // [rfeng] We need to clone the wrapper as it holds the databinding information - if (wrapper != null) { - copy.wrapper = (WrapperInfo)wrapper.clone(); + if (inputWrapper != null) { + copy.inputWrapper = (WrapperInfo)inputWrapper.clone(); + } + + if (outputWrapper != null) { + copy.outputWrapper = (WrapperInfo)outputWrapper.clone(); } return copy; diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java index dfdc85d405..6873943efc 100644 --- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java +++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java @@ -31,7 +31,7 @@ import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl; * A WSDL operation qualifies for wrapper style mapping only if the following * criteria are met: * <ul> - * <li>(i) The operation�s input and output messages (if present) each contain + * <li>(i) The operations input and output messages (if present) each contain * only a single part * <li>(ii) The input message part refers to a global element declaration whose * localname is equal to the operation name @@ -49,83 +49,123 @@ import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl; * @tuscany.spi.extension.asclient */ public class WrapperInfo implements Cloneable { - private ElementInfo inputWrapperElement; - - private ElementInfo outputWrapperElement; - - private List<ElementInfo> inputChildElements; - - private List<ElementInfo> outputChildElements; - - // The data type of the unwrapped input child elements - private DataType<List<DataType>> unwrappedInputType; - - // The data type of the unwrapped output child elements - private DataType<List<DataType>> unwrappedOutputType; - - // The data for the input/output wrappers + + // The databinding for the wrapper private String dataBinding; - - // The data type for the input (request) wrapper bean - private DataType<XMLType> inputWrapperType; - // The data type for the output (response) wrapper bean - private DataType<XMLType> outputWrapperType; + + // The XML element representation of the wrapper + private ElementInfo wrapperElement; + + // The XML child elements of the wrapper + private List<ElementInfo> childElements; + + // The data type for the wrapper bean + private DataType<XMLType> wrapperType; + + // The data types of the unwrapped child elements + private DataType<List<DataType>> unwrappedType; public WrapperInfo(String dataBinding, - ElementInfo inputWrapperElement, - ElementInfo outputWrapperElement, - List<ElementInfo> inputElements, - List<ElementInfo> outputElements) { + ElementInfo wrapperElement, + List<ElementInfo> childElements) { super(); this.dataBinding = dataBinding; - this.inputWrapperElement = inputWrapperElement; - this.outputWrapperElement = outputWrapperElement; - this.inputChildElements = inputElements; - this.outputChildElements = outputElements; + this.wrapperElement = wrapperElement; + this.childElements = childElements; } /** - * @return the inputElements + * Get the list of XML child elements that this + * wrapper wraps + * + * @return the childElements */ - public List<ElementInfo> getInputChildElements() { - return inputChildElements; + public List<ElementInfo> getChildElements() { + return childElements; } /** - * @return the inputWrapperElement + * Get the XML element that represents this wrapper + * + * @return the wrapperElement */ - public ElementInfo getInputWrapperElement() { - return inputWrapperElement; + public ElementInfo getWrapperElement() { + return wrapperElement; } - + /** - * @return the outputElements + * Get the databinding that this wrapper will + * be subject to + * + * @return dataBinding */ - public List<ElementInfo> getOutputChildElements() { - return outputChildElements; + public String getDataBinding() { + return dataBinding; } /** - * @return the outputWrapperElement + * Set the databinding that this wrapper will + * be subject to + * + * @param dataBinding + */ + public void setDataBinding(String dataBinding) { + this.dataBinding = dataBinding; + } + + /** + * Get the Tuscany data type for the wrapper + * + * @return Tuscany data type for the wrapper */ - public ElementInfo getOutputWrapperElement() { - return outputWrapperElement; + public DataType<XMLType> getWrapperType() { + return wrapperType; } /** - * @return the unwrappedInputType + * Set the Tuscany data type for the wrapper + * + * @param wrapperType Tuscany data type for the wrapper + */ + public void setWrapperType(DataType<XMLType> wrapperType) { + this.wrapperType = wrapperType; + } + + /** + * Return the Java class for the wrapper + * + * @return Java class for the wrapper + */ + public Class<?> getWrapperClass() { + return wrapperType == null ? null : wrapperType.getPhysical(); + } + + @Override + public Object clone() throws CloneNotSupportedException { + WrapperInfo copy = (WrapperInfo) super.clone(); + if (wrapperType != null) { + copy.wrapperType = (DataType<XMLType>)wrapperType.clone(); + } + return copy; + + } + + /** + * Creates and caches the data types for the child elements + * + * @return The list of child element data types */ - public DataType<List<DataType>> getUnwrappedInputType() { - if (unwrappedInputType == null) { + public DataType<List<DataType>> getUnwrappedType() { + if (unwrappedType == null) { List<DataType> childTypes = new ArrayList<DataType>(); - for (ElementInfo element : getInputChildElements()) { + for (ElementInfo element : getChildElements()) { DataType type = getDataType(element); childTypes.add(type); } - unwrappedInputType = new DataTypeImpl<List<DataType>>("idl:unwrapped.input", Object[].class, childTypes); + unwrappedType = new DataTypeImpl<List<DataType>>("idl:unwrapped", Object[].class, childTypes); } - return unwrappedInputType; - } + return unwrappedType; + } private DataType getDataType(ElementInfo element) { DataType type = null; @@ -138,84 +178,4 @@ public class WrapperInfo implements Cloneable { return type; } - /** - * @return the unwrappedOutputType - */ - public DataType<List<DataType>> getUnwrappedOutputType() { - if (unwrappedOutputType == null) { - List<DataType> childTypes = new ArrayList<DataType>(); - for (ElementInfo element : getOutputChildElements()) { - DataType type = getDataType(element); - childTypes.add(type); - } - unwrappedOutputType = new DataTypeImpl<List<DataType>>("idl:unwrapped.input", Object[].class, childTypes); - } - return unwrappedOutputType; } - - public Class<?> getInputWrapperClass() { - return inputWrapperType == null ? null : inputWrapperType.getPhysical(); - } - - public Class<?> getOutputWrapperClass() { - return outputWrapperType == null ? null : outputWrapperType.getPhysical(); - } - - public String getDataBinding() { - return dataBinding; - } - - public void setDataBinding(String dataBinding) { - this.dataBinding = dataBinding; - } - - public DataType<XMLType> getInputWrapperType() { - return inputWrapperType; - } - - public void setInputWrapperType(DataType<XMLType> inputWrapperType) { - this.inputWrapperType = inputWrapperType; - } - - public DataType<XMLType> getOutputWrapperType() { - return outputWrapperType; - } - - public void setOutputWrapperType(DataType<XMLType> outputWrapperType) { - this.outputWrapperType = outputWrapperType; - } - - @Override - public Object clone() throws CloneNotSupportedException { - WrapperInfo copy = (WrapperInfo) super.clone(); - if (inputWrapperType != null) { - copy.inputWrapperType = (DataType<XMLType>)inputWrapperType.clone(); - } - if (outputWrapperType != null) { - copy.outputWrapperType = (DataType<XMLType>)outputWrapperType.clone(); - } - if (unwrappedInputType != null) { - List<DataType> clonedLogicalTypes = new ArrayList<DataType>(); - for (DataType t : unwrappedInputType.getLogical()) { - DataType type = (DataType) t.clone(); - clonedLogicalTypes.add(type); - } - DataType<List<DataType>> clonedUnwrappedInputType = - new DataTypeImpl<List<DataType>>(unwrappedInputType.getPhysical(), clonedLogicalTypes); - clonedUnwrappedInputType.setDataBinding(unwrappedInputType.getDataBinding()); - copy.unwrappedInputType = clonedUnwrappedInputType; - } - if (unwrappedOutputType != null) { - List<DataType> clonedLogicalTypes = new ArrayList<DataType>(); - for (DataType t : unwrappedOutputType.getLogical()) { - DataType type = (DataType) t.clone(); - clonedLogicalTypes.add(type); - } - DataType<List<DataType>> clonedUnwrappedOutputType = - new DataTypeImpl<List<DataType>>(unwrappedOutputType.getPhysical(), clonedLogicalTypes); - clonedUnwrappedOutputType.setDataBinding(unwrappedOutputType.getDataBinding()); - copy.unwrappedOutputType = clonedUnwrappedOutputType; - } - return copy; - - } } 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 81bbcec3f6..50e40896fa 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 @@ -71,9 +71,13 @@ public class TestOperation implements Operation { return outputType; } - public WrapperInfo getWrapper() { + public WrapperInfo getInputWrapper() { return null; } + + public WrapperInfo getOutputWrapper() { + return null; + } public boolean isDynamic() { return false; @@ -87,9 +91,13 @@ public class TestOperation implements Operation { return false; } - public boolean isWrapperStyle() { + public boolean isInputWrapperStyle() { return false; } + + public boolean isOutputWrapperStyle() { + return false; + } public void setDataBinding(String dataBinding) { @@ -131,14 +139,22 @@ public class TestOperation implements Operation { } - public void setWrapper(WrapperInfo wrapperInfo) { + public void setInputWrapper(WrapperInfo wrapperInfo) { } - public void setWrapperStyle(boolean wrapperStyle) { + public void setOutputWrapper(WrapperInfo wrapperInfo) { + + } + + public void setInputWrapperStyle(boolean wrapperStyle) { } + public void setOutputWrapperStyle(boolean wrapperStyle) { + + } + public List<PolicySet> getApplicablePolicySets() { return null; } diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java index b2b424378f..797b0e45de 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java @@ -64,7 +64,7 @@ public class WireFormatJMSBytesXMLServiceProvider implements WireFormatProvider } // create a local interface contract that is configured specifically to - // deal with the data format that this wire format is expecting to sent to + // deal with the data format that this wire format is expecting to send to // and receive from the databinding interceptor. The request/response parts of // this interface contract will be copied into the binding interface contract // as required diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java index 67ee7309e2..b04072c992 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java @@ -121,7 +121,7 @@ public class WireFormatJMSDefaultReferenceProvider implements WireFormatProvider // like the separate code paths imply. Not sure how many @OneWay tests we have, this might // not be an issue. - if (matchingWsdlOp.isWrapperStyle()) { + if (matchingWsdlOp.isInputWrapperStyle()) { if (op.getInputType().getLogical().size() == 1) { this.inputWrapperMap.put(name, true); } else { @@ -131,10 +131,10 @@ public class WireFormatJMSDefaultReferenceProvider implements WireFormatProvider this.inputWrapperMap.put(name, false); } - if (matchingWsdlOp.isWrapperStyle()) { + if (matchingWsdlOp.isOutputWrapperStyle()) { // we only need to know what the wrapper is on the deserialization // might need to change this when there input/output wrapper style is different - ElementInfo ei = op.getWrapper().getOutputWrapperElement(); + ElementInfo ei = op.getOutputWrapper().getWrapperElement(); this.outputWrapperMap.put(name, xmlHelper.createWrapper(ei.getQName())); } } diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java index e24be41ebf..408aba9bbb 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java @@ -115,16 +115,16 @@ public class WireFormatJMSDefaultServiceProvider implements WireFormatProvider { // TODO - not sure we really support viewing the input/output as separately wrapped // like the separate code paths imply. Not sure how many @OneWay tests we have, this might // not be an issue. - if (matchingWsdlOp.isWrapperStyle()) { + if (matchingWsdlOp.isInputWrapperStyle()) { if (op.getInputType().getLogical().size() == 1) { // we only need to know what the wrapper is on the deserialization // might need to change this when the input/output wrapper style is different - ElementInfo ei = op.getWrapper().getInputWrapperElement(); + ElementInfo ei = op.getInputWrapper().getWrapperElement(); this.inputWrapperMap.put(name, xmlHelper.createWrapper(ei.getQName())); } } - if (matchingWsdlOp.isWrapperStyle()) { + if (matchingWsdlOp.isOutputWrapperStyle()) { this.outputWrapperMap.put(name, true); } else { this.outputWrapperMap.put(name, false); diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java index a2830d1fc3..48b377607e 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java @@ -64,7 +64,7 @@ public class WireFormatJMSTextXMLReferenceProvider implements WireFormatProvider } // create a local interface contract that is configured specifically to - // deal with the data format that this wire format is expecting to sent to + // deal with the data format that this wire format is expecting to send to // and receive from the databinding interceptor. The request/response parts of // this interface contract will be copied into the binding interface contract // as required diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java index fef9e78937..89fe2c7c39 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java @@ -67,7 +67,7 @@ public class WireFormatJMSTextXMLServiceProvider implements WireFormatProvider { } // create a local interface contract that is configured specifically to - // deal with the data format that this wire format is expecting to sent to + // deal with the data format that this wire format is expecting to send to // and receive from the databinding interceptor. The request/response parts of // this interface contract will be copied into the binding interface contract // as required diff --git a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JsonRpcInvoker.java b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JsonRpcInvoker.java index b2c7c428ec..713122f479 100644 --- a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JsonRpcInvoker.java +++ b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JsonRpcInvoker.java @@ -82,7 +82,7 @@ public class JsonRpcInvoker implements Invoker, DataExchangeSemantics { post = new HttpPost(uri); HttpEntity entity = null; Object[] args = msg.getBody(); - final String db = msg.getOperation().getWrapper().getDataBinding(); + final String db = msg.getOperation().getInputWrapper().getDataBinding(); if (!db.equals(JSONDataBinding.NAME)) { Object[] params = new Object[0]; diff --git a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JsonRpcServlet.java b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JsonRpcServlet.java index 2febbf5dc3..4261f5bffc 100644 --- a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JsonRpcServlet.java +++ b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JsonRpcServlet.java @@ -188,7 +188,7 @@ public class JsonRpcServlet extends HttpServlet { requestMessage.getHeaders().put("RequestMessage", request); - if (jsonOperation.getWrapper().getDataBinding().equals(JSONDataBinding.NAME)) { + if (jsonOperation.getInputWrapper().getDataBinding().equals(JSONDataBinding.NAME)) { requestMessage.setBody(new Object[] {JacksonHelper.toString(request.getJsonNode())}); } else { requestMessage.setBody(params); @@ -210,7 +210,7 @@ public class JsonRpcServlet extends HttpServlet { } if (!responseMessage.isFault()) { - if (jsonOperation.getWrapper().getDataBinding().equals(JSONDataBinding.NAME)) { + if (jsonOperation.getOutputWrapper().getDataBinding().equals(JSONDataBinding.NAME)) { result = responseMessage.getBody(); return new JsonRpc20Response((ObjectNode)JacksonHelper.MAPPER.readTree(result.toString())); } else { @@ -262,7 +262,7 @@ public class JsonRpcServlet extends HttpServlet { requestMessage.setOperation(jsonOperation); requestMessage.getHeaders().put("RequestMessage", request); - if (jsonOperation.getWrapper().getDataBinding().equals(JSONDataBinding.NAME)) { + if (jsonOperation.getInputWrapper().getDataBinding().equals(JSONDataBinding.NAME)) { requestMessage.setBody(new Object[] {JacksonHelper.toString(request.getJsonNode())}); } else { requestMessage.setBody(params); @@ -283,7 +283,7 @@ public class JsonRpcServlet extends HttpServlet { } if (!responseMessage.isFault()) { - if (jsonOperation.getWrapper().getDataBinding().equals(JSONDataBinding.NAME)) { + if (jsonOperation.getOutputWrapper().getDataBinding().equals(JSONDataBinding.NAME)) { result = responseMessage.getBody(); return new JsonRpc10Response((ObjectNode)JacksonHelper.MAPPER.readTree(result.toString())); } else { diff --git a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java index 795aae53b8..b4e3387d84 100644 --- a/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java +++ b/sca-java-2.x/trunk/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java @@ -230,11 +230,11 @@ public class Interface2WSDLGenerator { private Map<XMLTypeHelper, List<DataType>> getDataTypes(Interface intf, boolean useWrapper, Map<String, XMLTypeHelper> helpers) { Map<XMLTypeHelper, List<DataType>> dataTypes = new HashMap<XMLTypeHelper, List<DataType>>(); for (Operation op : intf.getOperations()) { - WrapperInfo wrapper = op.getWrapper(); + WrapperInfo inputWrapper = op.getInputWrapper(); DataType dt1 = null; - boolean useInputWrapper = useWrapper & wrapper != null; + boolean useInputWrapper = useWrapper & inputWrapper != null; if (useInputWrapper) { - dt1 = wrapper.getInputWrapperType(); + dt1 = inputWrapper.getWrapperType(); useInputWrapper &= inputTypesCompatible(dt1, op.getInputType(), helpers); } if (useInputWrapper) { @@ -245,10 +245,11 @@ public class Interface2WSDLGenerator { } } + WrapperInfo outputWrapper = op.getOutputWrapper(); DataType dt2 = null; - boolean useOutputWrapper = useWrapper & wrapper != null; + boolean useOutputWrapper = useWrapper & outputWrapper != null; if (useOutputWrapper) { - dt2 = wrapper.getOutputWrapperType(); + dt2 = outputWrapper.getWrapperType(); useOutputWrapper &= outputTypeCompatible(dt2, op.getOutputType(), helpers); } if (useOutputWrapper) { @@ -334,7 +335,7 @@ public class Interface2WSDLGenerator { javax.wsdl.Operation operation = generateOperation(definition, op, helpers, wrappers); portType.addOperation(operation); String action = ((JavaOperation)op).getAction(); - if ((action == null || "".equals(action)) && !op.isWrapperStyle() && op.getWrapper() == null) { + if ((action == null || "".equals(action)) && !op.isInputWrapperStyle() && op.getInputWrapper() == null) { // Bare style action = "urn:" + op.getName(); } @@ -631,7 +632,7 @@ public class Interface2WSDLGenerator { List<ElementInfo> elements = null; // FIXME: By default, java interface is mapped to doc-lit-wrapper style WSDL - if (op.getWrapper() != null) { + if (op.getInputWrapper() != null) { // Generate doc-lit-wrapper style inputMsg.addPart(generateWrapperPart(definition, op, helpers, wrappers, true)); } else { @@ -658,7 +659,7 @@ public class Interface2WSDLGenerator { outputMsg.setUndefined(false); definition.addMessage(outputMsg); - if (op.getWrapper() != null) { + if (op.getOutputWrapper() != null) { outputMsg.addPart(generateWrapperPart(definition, op, helpers, wrappers, false)); } else { @@ -741,12 +742,15 @@ public class Interface2WSDLGenerator { Part part = definition.createPart(); String partName = input ? operation.getName() : (operation.getName() + "Response"); part.setName(partName); - WrapperInfo opWrapper = operation.getWrapper(); - if (opWrapper != null) { + + WrapperInfo inputWrapper = operation.getInputWrapper(); + WrapperInfo outputWrapper = operation.getOutputWrapper(); + + if ((inputWrapper != null) && (outputWrapper != null)) { ElementInfo elementInfo = - input ? opWrapper.getInputWrapperElement() : opWrapper.getOutputWrapperElement(); + input ? inputWrapper.getWrapperElement() : outputWrapper.getWrapperElement(); List<ElementInfo> elements = - input ? opWrapper.getInputChildElements() : opWrapper.getOutputChildElements(); + input ? inputWrapper.getChildElements() : outputWrapper.getChildElements(); QName wrapperName = elementInfo.getQName(); part.setElementName(wrapperName); addNamespace(definition, wrapperName); diff --git a/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java b/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java index 25991c2970..dd931476ff 100644 --- a/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java +++ b/sca-java-2.x/trunk/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java @@ -402,7 +402,7 @@ class WebServiceBindingImpl implements WebServiceBinding, DefaultingPolicySubjec protected void setIsMessageWrapped() { if (getBindingInterfaceContract() != null) { - isMessageWrapped = getBindingInterfaceContract().getInterface().getOperations().get(0).isWrapperStyle(); + isMessageWrapped = getBindingInterfaceContract().getInterface().getOperations().get(0).isInputWrapperStyle(); } } diff --git a/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/DataBindingJavaInterfaceProcessor.java b/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/DataBindingJavaInterfaceProcessor.java index 0ab01fbe0b..e904e36901 100644 --- a/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/DataBindingJavaInterfaceProcessor.java +++ b/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/DataBindingJavaInterfaceProcessor.java @@ -70,7 +70,8 @@ public class DataBindingJavaInterfaceProcessor implements JavaInterfaceVisitor { if (dataBindingId != null) { op.setDataBinding(dataBindingId); - op.setWrapperStyle(wrapperStyle); + op.setInputWrapperStyle(wrapperStyle); + op.setOutputWrapperStyle(wrapperStyle); } Method method = operation.getJavaMethod(); @@ -85,7 +86,8 @@ public class DataBindingJavaInterfaceProcessor implements JavaInterfaceVisitor { dataBindingId = dataBinding.value(); wrapperStyle = dataBinding.wrapped(); operation.setDataBinding(dataBindingId); - operation.setWrapperStyle(wrapperStyle); + operation.setInputWrapperStyle(wrapperStyle); + operation.setOutputWrapperStyle(wrapperStyle); } // FIXME: We need a better way to identify simple java types diff --git a/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/WrapperJavaInterfaceProcessor.java b/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/WrapperJavaInterfaceProcessor.java index e72c1b7999..d152c0dc0a 100644 --- a/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/WrapperJavaInterfaceProcessor.java +++ b/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/WrapperJavaInterfaceProcessor.java @@ -55,12 +55,13 @@ public class WrapperJavaInterfaceProcessor implements JavaInterfaceVisitor { return; } for (Operation operation : javaInterface.getOperations()) { - WrapperInfo wrapper = operation.getWrapper(); - if (wrapper == null) { + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + if (inputWrapperInfo == null || outputWrapperInfo == null) { continue; } // JIRA: TUSCANY-842 - String db = wrapper.getDataBinding(); + String db = inputWrapperInfo.getDataBinding(); if (db == null || JAXB_DATABINDING.equals(db)) { db = assignOperationDataBinding(operation); } @@ -69,13 +70,13 @@ public class WrapperJavaInterfaceProcessor implements JavaInterfaceVisitor { org.apache.tuscany.sca.databinding.DataBinding dbObj = dataBindingRegistry.getDataBinding(db); WrapperHandler handler = dbObj == null ? null : dbObj.getWrapperHandler(); if (handler != null) { - wrapper.setInputWrapperType(handler.getWrapperType(operation, true)); - wrapper.setOutputWrapperType(handler.getWrapperType(operation, false)); + inputWrapperInfo.setWrapperType(handler.getWrapperType(operation, true)); + outputWrapperInfo.setWrapperType(handler.getWrapperType(operation, false)); } if (dbObj != null && handler == null) { // To avoid JAXB wrapper bean generation - wrapper.setInputWrapperType(null); - wrapper.setOutputWrapperType(null); + inputWrapperInfo.setWrapperType(null); + outputWrapperInfo.setWrapperType(null); } } } @@ -117,10 +118,10 @@ public class WrapperJavaInterfaceProcessor implements JavaInterfaceVisitor { if (dbs.size() == 1) { String db = dbs.iterator().next(); - operation.getWrapper().setDataBinding(db); + operation.getInputWrapper().setDataBinding(db); return db; } else { - return operation.getWrapper().getDataBinding(); + return operation.getInputWrapper().getDataBinding(); } } } diff --git a/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Input2InputTransformer.java b/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Input2InputTransformer.java index 1386aa38e9..3fb405064b 100644 --- a/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Input2InputTransformer.java +++ b/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Input2InputTransformer.java @@ -97,13 +97,13 @@ public class Input2InputTransformer extends BaseTransformer<Object[], Object[]> if (w1 == null || w2 == null) { return false; } - if (!w1.getInputWrapperElement().equals(w2.getInputWrapperElement())) { + if (!w1.getWrapperElement().equals(w2.getWrapperElement())) { return false; } // Compare the child elements - List<ElementInfo> list1 = w1.getInputChildElements(); - List<ElementInfo> list2 = w2.getInputChildElements(); + List<ElementInfo> list1 = w1.getChildElements(); + List<ElementInfo> list2 = w2.getChildElements(); if (list1.size() != list2.size()) { return false; } @@ -125,7 +125,7 @@ public class Input2InputTransformer extends BaseTransformer<Object[], Object[]> // Check if the source operation is wrapped DataType<List<DataType>> sourceType = context.getSourceDataType(); Operation sourceOp = context.getSourceOperation(); - boolean sourceWrapped = sourceOp != null && sourceOp.isWrapperStyle() && sourceOp.getWrapper() != null; + boolean sourceWrapped = sourceOp != null && sourceOp.isInputWrapperStyle() && sourceOp.getInputWrapper() != null; boolean sourceNotSubjectToWrapping = sourceOp != null && sourceOp.isNotSubjectToWrapping(); // Find the wrapper handler for source data @@ -136,7 +136,7 @@ public class Input2InputTransformer extends BaseTransformer<Object[], Object[]> // Check if the target operation is wrapped DataType<List<DataType>> targetType = context.getTargetDataType(); Operation targetOp = (Operation)context.getTargetOperation(); - boolean targetWrapped = targetOp != null && targetOp.isWrapperStyle() && targetOp.getWrapper() != null; + boolean targetWrapped = targetOp != null && targetOp.isInputWrapperStyle() && targetOp.getInputWrapper() != null; boolean targetNotSubjectToWrapping = targetOp != null && targetOp.isNotSubjectToWrapping(); // Find the wrapper handler for target data @@ -146,7 +146,7 @@ public class Input2InputTransformer extends BaseTransformer<Object[], Object[]> if ((!sourceWrapped && !sourceNotSubjectToWrapping) && targetWrapped) { // Unwrapped --> Wrapped - WrapperInfo wrapper = targetOp.getWrapper(); + WrapperInfo wrapper = targetOp.getInputWrapper(); // ElementInfo wrapperElement = wrapper.getInputWrapperElement(); // Class<?> targetWrapperClass = wrapper != null ? wrapper.getInputWrapperClass() : null; @@ -159,12 +159,12 @@ public class Input2InputTransformer extends BaseTransformer<Object[], Object[]> // If the source can be wrapped, wrapped it first if (sourceWrapperHandler != null) { - WrapperInfo sourceWrapperInfo = sourceOp.getWrapper(); - DataType sourceWrapperType = sourceWrapperInfo != null ? sourceWrapperInfo.getInputWrapperType() : null; + WrapperInfo sourceWrapperInfo = sourceOp.getInputWrapper(); + DataType sourceWrapperType = sourceWrapperInfo != null ? sourceWrapperInfo.getWrapperType() : null; // We only do wrapper to wrapper transformation if the source has a wrapper and both sides // match by XML structure - if (sourceWrapperType != null && matches(sourceOp.getWrapper(), targetOp.getWrapper())) { + if (sourceWrapperType != null && matches(sourceOp.getInputWrapper(), targetOp.getInputWrapper())) { Class<?> sourceWrapperClass = sourceWrapperType.getPhysical(); // Create the source wrapper @@ -187,7 +187,7 @@ public class Input2InputTransformer extends BaseTransformer<Object[], Object[]> } // Fall back to child by child transformation Object targetWrapper = targetWrapperHandler.create(targetOp, true); - List<DataType> argTypes = wrapper.getUnwrappedInputType().getLogical(); + List<DataType> argTypes = wrapper.getUnwrappedType().getLogical(); Object[] targetChildren = new Object[source.length]; for (int i = 0; i < source.length; i++) { // ElementInfo argElement = wrapper.getInputChildElements().get(i); @@ -213,10 +213,10 @@ public class Input2InputTransformer extends BaseTransformer<Object[], Object[]> // under the wrapper that only matches by position if (sourceWrapperHandler.isInstance(sourceWrapper, sourceOp, true)) { - WrapperInfo targetWrapperInfo = targetOp.getWrapper(); + WrapperInfo targetWrapperInfo = targetOp.getInputWrapper(); DataType targetWrapperType = - targetWrapperInfo != null ? targetWrapperInfo.getInputWrapperType() : null; - if (targetWrapperType != null && matches(sourceOp.getWrapper(), targetOp.getWrapper())) { + targetWrapperInfo != null ? targetWrapperInfo.getWrapperType() : null; + if (targetWrapperType != null && matches(sourceOp.getInputWrapper(), targetOp.getInputWrapper())) { Object targetWrapper = mediator.mediate(sourceWrapper, sourceType.getLogical().get(0), targetWrapperType, context .getMetadata()); @@ -228,7 +228,7 @@ public class Input2InputTransformer extends BaseTransformer<Object[], Object[]> Object[] sourceChildren = sourceWrapperHandler.getChildren(sourceWrapper, sourceOp, true).toArray(); target = new Object[sourceChildren.length]; for (int i = 0; i < sourceChildren.length; i++) { - DataType<XMLType> childType = sourceOp.getWrapper().getUnwrappedInputType().getLogical().get(i); + DataType<XMLType> childType = sourceOp.getInputWrapper().getUnwrappedType().getLogical().get(i); target[i] = mediator.mediate(sourceChildren[i], childType, targetType.getLogical().get(i), context .getMetadata()); @@ -260,7 +260,7 @@ public class Input2InputTransformer extends BaseTransformer<Object[], Object[]> } private String getDataBinding(Operation operation) { - WrapperInfo wrapper = operation.getWrapper(); + WrapperInfo wrapper = operation.getInputWrapper(); if (wrapper != null) { return wrapper.getDataBinding(); } else { diff --git a/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Output2OutputTransformer.java b/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Output2OutputTransformer.java index 706e01aac7..f2e1eb7742 100644 --- a/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Output2OutputTransformer.java +++ b/sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Output2OutputTransformer.java @@ -91,7 +91,7 @@ public class Output2OutputTransformer extends BaseTransformer<Object, Object> im } private String getDataBinding(Operation operation) { - WrapperInfo wrapper = operation.getWrapper(); + WrapperInfo wrapper = operation.getOutputWrapper(); if (wrapper != null) { return wrapper.getDataBinding(); } else { @@ -122,13 +122,13 @@ public class Output2OutputTransformer extends BaseTransformer<Object, Object> im if (w1 == null || w2 == null) { return false; } - if (!w1.getOutputWrapperElement().equals(w2.getOutputWrapperElement())) { + if (!w1.getWrapperElement().equals(w2.getWrapperElement())) { return false; } // Compare the child elements - List<ElementInfo> list1 = w1.getOutputChildElements(); - List<ElementInfo> list2 = w2.getOutputChildElements(); + List<ElementInfo> list1 = w1.getChildElements(); + List<ElementInfo> list2 = w2.getChildElements(); if (list1.size() != list2.size()) { return false; } @@ -151,7 +151,7 @@ public class Output2OutputTransformer extends BaseTransformer<Object, Object> im DataType<List<DataType>> sourceType = context.getSourceDataType(); Operation sourceOp = context.getSourceOperation(); - boolean sourceWrapped = sourceOp != null && sourceOp.isWrapperStyle() && sourceOp.getWrapper() != null; + boolean sourceWrapped = sourceOp != null && sourceOp.isOutputWrapperStyle() && sourceOp.getOutputWrapper() != null; boolean sourceNotSubjectToWrapping = sourceOp != null && sourceOp.isNotSubjectToWrapping(); WrapperHandler sourceWrapperHandler = null; @@ -160,7 +160,7 @@ public class Output2OutputTransformer extends BaseTransformer<Object, Object> im DataType<List<DataType>> targetType = context.getTargetDataType(); Operation targetOp = (Operation)context.getTargetOperation(); - boolean targetWrapped = targetOp != null && targetOp.isWrapperStyle() && targetOp.getWrapper() != null; + boolean targetWrapped = targetOp != null && targetOp.isOutputWrapperStyle() && targetOp.getOutputWrapper() != null; boolean targetNotSubjectToWrapping = targetOp != null && targetOp.isNotSubjectToWrapping(); WrapperHandler targetWrapperHandler = null; @@ -169,10 +169,10 @@ public class Output2OutputTransformer extends BaseTransformer<Object, Object> im if ((!sourceWrapped &&!sourceNotSubjectToWrapping) && targetWrapped) { // Unwrapped --> Wrapped - WrapperInfo wrapper = targetOp.getWrapper(); - ElementInfo wrapperElement = wrapper.getOutputWrapperElement(); - List<ElementInfo> childElements = wrapper.getOutputChildElements(); - Class<?> targetWrapperClass = wrapper != null ? wrapper.getOutputWrapperClass() : null; + WrapperInfo wrapper = targetOp.getOutputWrapper(); + ElementInfo wrapperElement = wrapper.getWrapperElement(); + List<ElementInfo> childElements = wrapper.getChildElements(); + Class<?> targetWrapperClass = wrapper != null ? wrapper.getWrapperClass() : null; Object[] outputs = null; if ( !sourceOp.hasArrayWrappedOutput() ) { @@ -183,11 +183,11 @@ public class Output2OutputTransformer extends BaseTransformer<Object, Object> im // If the source can be wrapped, wrapped it first if (sourceWrapperHandler != null) { - WrapperInfo sourceWrapperInfo = sourceOp.getWrapper(); + WrapperInfo sourceWrapperInfo = sourceOp.getOutputWrapper(); DataType sourceWrapperType = - sourceWrapperInfo != null ? sourceWrapperInfo.getOutputWrapperType() : null; + sourceWrapperInfo != null ? sourceWrapperInfo.getWrapperType() : null; - if (sourceWrapperType != null && matches(sourceOp.getWrapper(), targetOp.getWrapper())) { + if (sourceWrapperType != null && matches(sourceOp.getOutputWrapper(), targetOp.getOutputWrapper())) { Class<?> sourceWrapperClass = sourceWrapperType.getPhysical(); Object sourceWrapper = sourceWrapperHandler.create(sourceOp, false); @@ -218,7 +218,7 @@ public class Output2OutputTransformer extends BaseTransformer<Object, Object> im Object[] targetChildren = new Object[outputs.length]; for (int i = 0; i < outputs.length; i++) { - DataType<XMLType> targetOutputType = wrapper.getUnwrappedOutputType().getLogical().get(i); + DataType<XMLType> targetOutputType = wrapper.getUnwrappedType().getLogical().get(i); targetChildren[i] = mediator.mediate(outputs[i], sourceType.getLogical().get(i), targetOutputType, context.getMetadata()); } @@ -231,23 +231,23 @@ public class Output2OutputTransformer extends BaseTransformer<Object, Object> im } else if (sourceWrapped && (!targetWrapped && !targetNotSubjectToWrapping)) { // Wrapped to Unwrapped Object sourceWrapper = response; - List<ElementInfo> childElements = sourceOp.getWrapper().getOutputChildElements(); + List<ElementInfo> childElements = sourceOp.getOutputWrapper().getChildElements(); if (childElements.isEmpty()) { // The void output return null; } if (targetWrapperHandler != null) { - ElementInfo wrapperElement = sourceOp.getWrapper().getOutputWrapperElement(); + ElementInfo wrapperElement = sourceOp.getOutputWrapper().getWrapperElement(); // FIXME: This is a workaround for the wsdless support as it passes in child elements // under the wrapper that only matches by position if (sourceWrapperHandler.isInstance(sourceWrapper, sourceOp, false)) { - WrapperInfo targetWrapperInfo = targetOp.getWrapper(); + WrapperInfo targetWrapperInfo = targetOp.getOutputWrapper(); DataType targetWrapperType = - targetWrapperInfo != null ? targetWrapperInfo.getOutputWrapperType() : null; + targetWrapperInfo != null ? targetWrapperInfo.getWrapperType() : null; - if (targetWrapperType != null && matches(sourceOp.getWrapper(), targetOp.getWrapper())) { + if (targetWrapperType != null && matches(sourceOp.getOutputWrapper(), targetOp.getOutputWrapper())) { Object targetWrapper = mediator.mediate(sourceWrapper, sourceType.getLogical().get(0), targetWrapperType, context .getMetadata()); @@ -265,7 +265,7 @@ public class Output2OutputTransformer extends BaseTransformer<Object, Object> im Object[] sourceChildren = sourceWrapperHandler.getChildren(sourceWrapper, sourceOp, false).toArray(); Object[] target = new Object[sourceChildren.length]; for (int i = 0; i < sourceChildren.length; i++) { - DataType<XMLType> childType = sourceOp.getWrapper().getUnwrappedOutputType().getLogical().get(i); + DataType<XMLType> childType = sourceOp.getOutputWrapper().getUnwrappedType().getLogical().get(i); target[i] = mediator.mediate(sourceChildren[i], childType, targetType.getLogical().get(i), context .getMetadata()); diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java index 89388fa9af..dc5738af96 100644 --- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java +++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java @@ -379,8 +379,8 @@ public class AsyncJDKInvocationHandler extends JDKInvocationHandler { if (type instanceof ParameterizedType) { // Check if the parameterized type of Response<T> is a doc-lit-wrapper class Class<?> wrapperClass = (Class<?>)((ParameterizedType)type).getActualTypeArguments()[0]; - WrapperInfo wrapperInfo = chain.getSourceOperation().getWrapper(); - if (wrapperInfo != null && wrapperInfo.getOutputWrapperClass() == wrapperClass) { + WrapperInfo wrapperInfo = chain.getSourceOperation().getOutputWrapper(); + if (wrapperInfo != null && wrapperInfo.getWrapperClass() == wrapperClass) { Object wrapper = wrapperClass.newInstance(); // Find the 1st matching property for (PropertyDescriptor p : Introspector.getBeanInfo(wrapperClass).getPropertyDescriptors()) { diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java index 41f469cc1b..827008dc73 100644 --- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java +++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java @@ -214,8 +214,8 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable { Class<?>[] params = method.getParameterTypes(); DataType<List<DataType>> inputType = null; - if (operation.isWrapperStyle()) { - inputType = operation.getWrapper().getUnwrappedInputType(); + if (operation.isInputWrapperStyle()) { + inputType = operation.getInputWrapper().getUnwrappedType(); } else { inputType = operation.getInputType(); } diff --git a/sca-java-2.x/trunk/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java b/sca-java-2.x/trunk/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java index 09fc0a311b..c2c2d8a313 100644 --- a/sca-java-2.x/trunk/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java +++ b/sca-java-2.x/trunk/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java @@ -57,16 +57,22 @@ public class OMElementWrapperHandler implements WrapperHandler<OMElement> { } public OMElement create(Operation operation, boolean input) { - WrapperInfo wrapperInfo = operation.getWrapper(); - ElementInfo element = input ? wrapperInfo.getInputWrapperElement() : wrapperInfo.getOutputWrapperElement(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + ElementInfo element = input ? inputWrapperInfo.getWrapperElement() : outputWrapperInfo.getWrapperElement(); // Class<?> wrapperClass = input ? wrapperInfo.getInputWrapperClass() : wrapperInfo.getOutputWrapperClass(); OMElement wrapper = AxiomHelper.createOMElement(factory, element.getQName()); return wrapper; } public void setChildren(OMElement wrapper, Object[] childObjects, Operation operation, boolean input) { + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + List<ElementInfo> childElements = - input ? operation.getWrapper().getInputChildElements() : operation.getWrapper().getOutputChildElements(); + input ? inputWrapperInfo.getChildElements() : outputWrapperInfo.getChildElements(); + for (int i = 0; i < childElements.size(); i++) { setChild(wrapper, i, childElements.get(i), childObjects[i]); } @@ -108,8 +114,11 @@ public class OMElementWrapperHandler implements WrapperHandler<OMElement> { } public List getChildren(OMElement wrapper, Operation operation, boolean input) { - List<ElementInfo> childElements = input? operation.getWrapper().getInputChildElements(): - operation.getWrapper().getOutputChildElements(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + List<ElementInfo> childElements = input? inputWrapperInfo.getChildElements(): + outputWrapperInfo.getChildElements(); // Used in both the schema-valid and schema-invalid paths List<List<OMElement>> groupedElements = getElements(wrapper); @@ -264,16 +273,22 @@ public class OMElementWrapperHandler implements WrapperHandler<OMElement> { * @see org.apache.tuscany.sca.databinding.WrapperHandler#getWrapperType(Operation, boolean) */ public DataType getWrapperType(Operation operation, boolean input) { - WrapperInfo wrapper = operation.getWrapper(); - ElementInfo element = input ? wrapper.getInputWrapperElement() : wrapper.getOutputWrapperElement(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + ElementInfo element = input ? inputWrapperInfo.getWrapperElement() : outputWrapperInfo.getWrapperElement(); + DataType<XMLType> wrapperType = new DataTypeImpl<XMLType>(AxiomDataBinding.NAME, OMElement.class, new XMLType(element)); return wrapperType; } public boolean isInstance(Object wrapperObj, Operation operation, boolean input) { - WrapperInfo wrapperInfo = operation.getWrapper(); - ElementInfo element = input ? wrapperInfo.getInputWrapperElement() : wrapperInfo.getOutputWrapperElement(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + ElementInfo element = input ? inputWrapperInfo.getWrapperElement() : outputWrapperInfo.getWrapperElement(); + // List<ElementInfo> childElements = // input ? wrapperInfo.getInputChildElements() : wrapperInfo.getOutputChildElements(); OMElement wrapper = (OMElement)wrapperObj; diff --git a/sca-java-2.x/trunk/modules/databinding-axiom/src/test/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandlerTestCase.java b/sca-java-2.x/trunk/modules/databinding-axiom/src/test/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandlerTestCase.java index 2270947c29..fe42603108 100644 --- a/sca-java-2.x/trunk/modules/databinding-axiom/src/test/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandlerTestCase.java +++ b/sca-java-2.x/trunk/modules/databinding-axiom/src/test/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandlerTestCase.java @@ -93,9 +93,9 @@ public class OMElementWrapperHandlerTestCase { elements.get(1).setOmissible(true);
elements.get(1).setNillable(false);
- WrapperInfo wrapperInfo = new WrapperInfo(AxiomDataBinding.NAME, null, null, elements, null);
+ WrapperInfo wrapperInfo = new WrapperInfo(AxiomDataBinding.NAME, null, elements);
this.op = new OperationImpl();
- op.setWrapper(wrapperInfo);
+ op.setInputWrapper(wrapperInfo);
}
@Test
diff --git a/sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java b/sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java index f369b491e7..1837e43c36 100644 --- a/sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java +++ b/sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java @@ -446,13 +446,17 @@ public final class JAXBContextHelper { } private static void getDataTypes(List<DataType> dataTypes, Operation op, boolean useWrapper) { - WrapperInfo wrapper = op.getWrapper(); - if (useWrapper && wrapper != null) { - DataType dt1 = wrapper.getInputWrapperType(); + WrapperInfo inputWrapper = op.getInputWrapper(); + WrapperInfo outputWrapper = op.getOutputWrapper(); + + if (useWrapper && (inputWrapper != null)) { + DataType dt1 = inputWrapper.getWrapperType(); if (dt1 != null) { dataTypes.add(dt1); } - DataType dt2 = wrapper.getOutputWrapperType(); + } + if (useWrapper && (outputWrapper != null)) { + DataType dt2 = outputWrapper.getWrapperType(); if (dt2 != null) { dataTypes.add(dt2); } diff --git a/sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java b/sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java index a1f4c12c8f..9b0c0dc8dc 100644 --- a/sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java +++ b/sca-java-2.x/trunk/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java @@ -46,9 +46,12 @@ public class JAXBWrapperHandler implements WrapperHandler<Object> { private JAXBWrapperHelper helper = new JAXBWrapperHelper(); public Object create(Operation operation, boolean input) { - WrapperInfo wrapperInfo = operation.getWrapper(); - ElementInfo element = input ? wrapperInfo.getInputWrapperElement() : wrapperInfo.getOutputWrapperElement(); - final Class<?> wrapperClass = input ? wrapperInfo.getInputWrapperClass() : wrapperInfo.getOutputWrapperClass(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + ElementInfo element = input ? inputWrapperInfo.getWrapperElement() : outputWrapperInfo.getWrapperElement(); + final Class<?> wrapperClass = input ? inputWrapperInfo.getWrapperClass() : outputWrapperInfo.getWrapperClass(); + try { if (wrapperClass == null) { return null; @@ -64,8 +67,12 @@ public class JAXBWrapperHandler implements WrapperHandler<Object> { } public void setChildren(Object wrapper, Object[] childObjects, Operation operation, boolean input) { + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + List<ElementInfo> childElements = - input ? operation.getWrapper().getInputChildElements() : operation.getWrapper().getOutputChildElements(); + input ? inputWrapperInfo.getChildElements() : outputWrapperInfo.getChildElements(); + List<String> childNames = new ArrayList<String>(); Map<String, Object> values = new HashMap<String, Object>(); for (int i = 0; i < childElements.size(); i++) { @@ -121,8 +128,11 @@ public class JAXBWrapperHandler implements WrapperHandler<Object> { * @see org.apache.tuscany.sca.databinding.WrapperHandler#getChildren(java.lang.Object, Operation, boolean) */ public List getChildren(Object wrapper, Operation operation, boolean input) { - List<ElementInfo> childElements = input? operation.getWrapper().getInputChildElements(): - operation.getWrapper().getOutputChildElements(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + List<ElementInfo> childElements = input? inputWrapperInfo.getChildElements(): + outputWrapperInfo.getChildElements(); List<String> childNames = new ArrayList<String>(); for (ElementInfo e : childElements) { @@ -135,8 +145,10 @@ public class JAXBWrapperHandler implements WrapperHandler<Object> { * @see org.apache.tuscany.sca.databinding.WrapperHandler#getWrapperType(Operation, boolean) */ public DataType getWrapperType(Operation operation, boolean input) { - WrapperInfo wrapper = operation.getWrapper(); - DataType dt = input ? wrapper.getInputWrapperType() : wrapper.getOutputWrapperType(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + DataType dt = input ? inputWrapperInfo.getWrapperType() : outputWrapperInfo.getWrapperType(); return dt; } @@ -144,8 +156,12 @@ public class JAXBWrapperHandler implements WrapperHandler<Object> { * @see org.apache.tuscany.sca.databinding.WrapperHandler#isInstance(java.lang.Object, Operation, boolean) */ public boolean isInstance(Object wrapper, Operation operation, boolean input) { + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + Class<?> wrapperClass = - input ? operation.getWrapper().getInputWrapperClass() : operation.getWrapper().getOutputWrapperClass(); + input ? inputWrapperInfo.getWrapperClass() : outputWrapperInfo.getWrapperClass(); + return wrapperClass == null ? false : wrapperClass.isInstance(wrapper); } } diff --git a/sca-java-2.x/trunk/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandlerTestCase.java b/sca-java-2.x/trunk/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandlerTestCase.java index 6037212e5a..94b85afca7 100644 --- a/sca-java-2.x/trunk/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandlerTestCase.java +++ b/sca-java-2.x/trunk/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandlerTestCase.java @@ -58,10 +58,10 @@ public class JAXBWrapperHandlerTestCase { public void testCreate() { ElementInfo element = new ElementInfo(ELEMENT, null); Operation op = new OperationImpl(); - WrapperInfo wrapperInfo = new WrapperInfo(JAXBDataBinding.NAME, element, null, null, null); - wrapperInfo.setInputWrapperType(new DataTypeImpl<XMLType>(JAXBDataBinding.NAME, StockQuoteOffer.class, - XMLType.UNKNOWN)); - op.setWrapper(wrapperInfo); + WrapperInfo wrapperInfo = new WrapperInfo(JAXBDataBinding.NAME, element, null); + wrapperInfo.setWrapperType(new DataTypeImpl<XMLType>(JAXBDataBinding.NAME, StockQuoteOffer.class, + XMLType.UNKNOWN)); + op.setInputWrapper(wrapperInfo); Object offer = handler.create(op, true); Assert.assertTrue(offer instanceof StockQuoteOffer); } @@ -79,9 +79,9 @@ public class JAXBWrapperHandlerTestCase { wrapper.setInput("IBM"); List<ElementInfo> elements = new ArrayList<ElementInfo>(); elements.add(new ElementInfo(INPUT, null)); - WrapperInfo wrapperInfo = new WrapperInfo(JAXBDataBinding.NAME, null, null, elements, null); + WrapperInfo wrapperInfo = new WrapperInfo(JAXBDataBinding.NAME, null, elements); Operation op = new OperationImpl(); - op.setWrapper(wrapperInfo); + op.setInputWrapper(wrapperInfo); List children = handler.getChildren(wrapper, op, true); assertNotNull(children); assertEquals(1, children.size()); diff --git a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java index 381249d9bb..dc1b3fc4fa 100644 --- a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java +++ b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java @@ -202,14 +202,16 @@ public class SDOTypeHelper implements XMLTypeHelper { private static List<DataType> getDataTypes(Interface intf) { List<DataType> dataTypes = new ArrayList<DataType>(); for (Operation op : intf.getOperations()) { - WrapperInfo wrapperInfo = op.getWrapper(); - if (wrapperInfo != null ) { - DataType dt1 = wrapperInfo.getInputWrapperType(); + WrapperInfo inputWrapperInfo = op.getInputWrapper(); + WrapperInfo outputWrapperInfo = op.getOutputWrapper(); + + if ((inputWrapperInfo != null) && (outputWrapperInfo != null)) { + DataType dt1 = inputWrapperInfo.getWrapperType(); if (dt1 != null) { dataTypes.add(dt1); } - DataType dt2 = wrapperInfo.getOutputWrapperType(); + DataType dt2 = outputWrapperInfo.getWrapperType(); if (dt2 != null) { dataTypes.add(dt2); } diff --git a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandler.java b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandler.java index 58c69858b7..167be60640 100644 --- a/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandler.java +++ b/sca-java-2.x/trunk/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandler.java @@ -51,11 +51,11 @@ import commonj.sdo.helper.XSDHelper; public class SDOWrapperHandler implements WrapperHandler<Object> { public Object create(Operation operation, boolean input) { - WrapperInfo wrapperInfo = operation.getWrapper(); - + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); - ElementInfo element = input ? wrapperInfo.getInputWrapperElement() : - wrapperInfo.getOutputWrapperElement(); + ElementInfo element = input ? inputWrapperInfo.getWrapperElement() : + outputWrapperInfo.getWrapperElement(); HelperContext helperContext = SDOContextHelper.getHelperContext(operation); Type sdoType = getSDOType(helperContext, element); @@ -67,11 +67,11 @@ public class SDOWrapperHandler implements WrapperHandler<Object> { } public void setChildren(Object wrapper, Object[] childObjects, Operation operation, boolean input) { - WrapperInfo wrapperInfo = operation.getWrapper(); - + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); - List<ElementInfo> childElements = input? wrapperInfo.getInputChildElements(): - wrapperInfo.getOutputChildElements(); + List<ElementInfo> childElements = input? inputWrapperInfo.getChildElements(): + outputWrapperInfo.getChildElements(); for (int i = 0; i < childElements.size(); i++) { setChild(wrapper, i, childElements.get(i), childObjects[i]); @@ -129,11 +129,11 @@ public class SDOWrapperHandler implements WrapperHandler<Object> { * @see org.apache.tuscany.sca.databinding.WrapperHandler#getWrapperType(Operation, boolean) */ public DataType getWrapperType(Operation operation, boolean input) { - WrapperInfo wrapperInfo = operation.getWrapper(); - + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); - ElementInfo element = input ? wrapperInfo.getInputWrapperElement() : - wrapperInfo.getOutputWrapperElement(); + ElementInfo element = input ? inputWrapperInfo.getWrapperElement() : + outputWrapperInfo.getWrapperElement(); HelperContext helperContext = SDOContextHelper.getHelperContext(operation); Type sdoType = getSDOType(helperContext, element); @@ -174,11 +174,11 @@ public class SDOWrapperHandler implements WrapperHandler<Object> { * @see org.apache.tuscany.sca.databinding.WrapperHandler#isInstance(java.lang.Object, Operation, boolean) */ public boolean isInstance(Object wrapper, Operation operation, boolean input) { - WrapperInfo wrapperInfo = operation.getWrapper(); - + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); - ElementInfo element = input ? wrapperInfo.getInputWrapperElement() : - wrapperInfo.getOutputWrapperElement(); + ElementInfo element = input ? inputWrapperInfo.getWrapperElement() : + outputWrapperInfo.getWrapperElement(); // List<ElementInfo> childElements = // input ? wrapperInfo.getInputChildElements() : wrapperInfo.getOutputChildElements(); diff --git a/sca-java-2.x/trunk/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandlerTestCase.java b/sca-java-2.x/trunk/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandlerTestCase.java index 2326d1b93b..3fa5ee7d55 100644 --- a/sca-java-2.x/trunk/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandlerTestCase.java +++ b/sca-java-2.x/trunk/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandlerTestCase.java @@ -76,8 +76,8 @@ public class SDOWrapperHandlerTestCase extends TestCase { xsdHelper.define(getClass().getResourceAsStream("/wrapper.xsd"), null); ElementInfo element = new ElementInfo(new QName("http://www.example.com/wrapper", "op"), null); Operation op = new OperationImpl(); - WrapperInfo wrapperInfo = new WrapperInfo(SDODataBinding.NAME, element, null, null, null); - op.setWrapper(wrapperInfo); + WrapperInfo wrapperInfo = new WrapperInfo(SDODataBinding.NAME, element, null); + op.setInputWrapper(wrapperInfo); DataObject wrapper = (DataObject) handler.create(op, true); assertNotNull(wrapper); } diff --git a/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/DataTypeHelper.java b/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/DataTypeHelper.java index 847fcf226c..8a0789c673 100644 --- a/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/DataTypeHelper.java +++ b/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/DataTypeHelper.java @@ -132,13 +132,15 @@ public final class DataTypeHelper { } private static void getDataTypes(List<DataType> dataTypes, Operation op, boolean useWrapper) { - WrapperInfo wrapper = op.getWrapper(); - if (useWrapper && wrapper != null) { - DataType dt1 = wrapper.getInputWrapperType(); + WrapperInfo inputWrapper = op.getInputWrapper(); + WrapperInfo outputWrapper = op.getOutputWrapper(); + + if (useWrapper && (inputWrapper != null) && (outputWrapper != null)) { + DataType dt1 = inputWrapper.getWrapperType(); if (dt1 != null) { dataTypes.add(dt1); } - DataType dt2 = wrapper.getOutputWrapperType(); + DataType dt2 = outputWrapper.getWrapperType(); if (dt2 != null) { dataTypes.add(dt2); } diff --git a/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/OperationDataBindingHelper.java b/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/OperationDataBindingHelper.java index 56c32ef2b6..8ecd0ffb7f 100644 --- a/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/OperationDataBindingHelper.java +++ b/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/OperationDataBindingHelper.java @@ -55,10 +55,14 @@ public class OperationDataBindingHelper { return false;
}
- if (source.isWrapperStyle() != target.isWrapperStyle()) {
+ if (source.isInputWrapperStyle() != target.isInputWrapperStyle()) {
return true;
}
+ if (source.isOutputWrapperStyle() != target.isOutputWrapperStyle()) {
+ return true;
+ }
+
// Check output type
List<DataType> sourceOutputType = source.getOutputType().getLogical();
List<DataType> targetOutputType = target.getOutputType().getLogical();
diff --git a/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMWrapperHandler.java b/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMWrapperHandler.java index abeeae47a6..6736888b0e 100644 --- a/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMWrapperHandler.java +++ b/sca-java-2.x/trunk/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMWrapperHandler.java @@ -47,10 +47,11 @@ public class DOMWrapperHandler implements WrapperHandler<Node> { } public Node create(Operation operation, boolean input) { + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + ElementInfo element = input ? inputWrapperInfo.getWrapperElement() : outputWrapperInfo.getWrapperElement(); - WrapperInfo wrapperInfo = operation.getWrapper(); - ElementInfo element = input ? wrapperInfo.getInputWrapperElement() : wrapperInfo.getOutputWrapperElement(); - // Class<?> wrapperClass = input ? wrapperInfo.getInputWrapperClass() : wrapperInfo.getOutputWrapperClass(); Document document = domHelper.newDocument(); QName name = element.getQName(); return DOMHelper.createElement(document, name); @@ -59,8 +60,11 @@ public class DOMWrapperHandler implements WrapperHandler<Node> { public void setChildren(Node wrapper, Object[] childObjects, Operation operation, boolean input) { - List<ElementInfo> childElements = input? operation.getWrapper().getInputChildElements(): - operation.getWrapper().getOutputChildElements(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + List<ElementInfo> childElements = input? inputWrapperInfo.getChildElements(): + outputWrapperInfo.getChildElements(); for (int i = 0; i < childElements.size(); i++) { setChild(wrapper, i, childElements.get(i), childObjects[i]); } @@ -76,8 +80,13 @@ public class DOMWrapperHandler implements WrapperHandler<Node> { public List getChildren(Node wrapper, Operation operation, boolean input) { assert wrapper != null; - List<ElementInfo> childElements = input? operation.getWrapper().getInputChildElements(): - operation.getWrapper().getOutputChildElements(); + + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + List<ElementInfo> childElements = input? inputWrapperInfo.getChildElements(): + outputWrapperInfo.getChildElements(); + if (wrapper.getNodeType() == Node.DOCUMENT_NODE) { wrapper = ((Document)wrapper).getDocumentElement(); } @@ -96,8 +105,10 @@ public class DOMWrapperHandler implements WrapperHandler<Node> { * @see org.apache.tuscany.sca.databinding.WrapperHandler#getWrapperType(Operation, boolean) */ public DataType getWrapperType(Operation operation, boolean input) { - WrapperInfo wrapper = operation.getWrapper(); - ElementInfo element = input? wrapper.getInputWrapperElement(): wrapper.getOutputWrapperElement(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + ElementInfo element = input? inputWrapperInfo.getWrapperElement(): outputWrapperInfo.getWrapperElement(); DataType<XMLType> wrapperType = new DataTypeImpl<XMLType>(DOMDataBinding.NAME, Node.class, new XMLType(element)); return wrapperType; @@ -106,10 +117,12 @@ public class DOMWrapperHandler implements WrapperHandler<Node> { public boolean isInstance(Object wrapperObj, Operation operation, boolean input) { - WrapperInfo wrapperInfo = operation.getWrapper(); - ElementInfo element = input ? wrapperInfo.getInputWrapperElement() : wrapperInfo.getOutputWrapperElement(); - List<ElementInfo> childElements = - input ? wrapperInfo.getInputChildElements() : wrapperInfo.getOutputChildElements(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + ElementInfo element = input ? inputWrapperInfo.getWrapperElement() : outputWrapperInfo.getWrapperElement(); + List<ElementInfo> childElements = input ? inputWrapperInfo.getChildElements() : outputWrapperInfo.getChildElements(); + Node wrapper = (Node)wrapperObj; if (wrapper.getNodeType() == Node.DOCUMENT_NODE) { wrapper = ((Document)wrapper).getDocumentElement(); diff --git a/sca-java-2.x/trunk/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DOMWrapperHandlerTestCase.java b/sca-java-2.x/trunk/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DOMWrapperHandlerTestCase.java index b587393ce0..08ec98fca9 100644 --- a/sca-java-2.x/trunk/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DOMWrapperHandlerTestCase.java +++ b/sca-java-2.x/trunk/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DOMWrapperHandlerTestCase.java @@ -102,9 +102,9 @@ public class DOMWrapperHandlerTestCase { elements.get(1).setOmissible(true);
elements.get(1).setNillable(false);
- WrapperInfo wrapperInfo = new WrapperInfo(DOMDataBinding.NAME, null, null, elements, null);
+ WrapperInfo wrapperInfo = new WrapperInfo(DOMDataBinding.NAME, null, elements);
this.op = new OperationImpl();
- op.setWrapper(wrapperInfo);
+ op.setInputWrapper(wrapperInfo);
}
@Test
diff --git a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessor.java b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessor.java index daa0bebd81..672c01a0b9 100644 --- a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessor.java +++ b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessor.java @@ -118,9 +118,9 @@ public class JAXWSAsyncInterfaceProcessor implements JavaInterfaceVisitor { asyncActualReturnTypeClass = (Class<?>)asyncReturnType.getActualTypeArguments()[0]; } - if (operation.getWrapper() != null) { + if (operation.getOutputWrapper() != null) { // The return type could be the wrapper type per JAX-WS spec - Class<?> wrapperClass = operation.getWrapper().getOutputWrapperClass(); + Class<?> wrapperClass = operation.getOutputWrapper().getWrapperClass(); if (wrapperClass == asyncActualReturnTypeClass) { return true; } @@ -182,9 +182,9 @@ public class JAXWSAsyncInterfaceProcessor implements JavaInterfaceVisitor { asyncActualLastParameterTypeClass = (Class<?>)asyncLastParameterType.getActualTypeArguments()[0]; } - if (operation.getWrapper() != null) { + if (operation.getOutputWrapper() != null) { // The return type could be the wrapper type per JAX-WS spec - Class<?> wrapperClass = operation.getWrapper().getOutputWrapperClass(); + Class<?> wrapperClass = operation.getOutputWrapper().getWrapperClass(); if (wrapperClass == asyncActualLastParameterTypeClass) { return true; } diff --git a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java index e8faa88de3..223f879570 100644 --- a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java +++ b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java @@ -142,7 +142,8 @@ public class JAXWSJavaInterfaceProcessor implements JavaInterfaceVisitor { if(bare) { // For BARE parameter style, the data won't be unwrapped // The wrapper should be null - operation.setWrapperStyle(false); + operation.setInputWrapperStyle(false); + operation.setOutputWrapperStyle(false); } documentStyle = methodSOAPBinding.style() == Style.DOCUMENT; } @@ -338,14 +339,14 @@ public class JAXWSJavaInterfaceProcessor implements JavaInterfaceVisitor { } String db = inputWrapperDT != null ? inputWrapperDT.getDataBinding() : JAXB_DATABINDING; - WrapperInfo wrapperInfo = - new WrapperInfo(db, new ElementInfo(inputWrapper, null), new ElementInfo(outputWrapper, null), - inputElements, outputElements); + WrapperInfo inputWrapperInfo = new WrapperInfo(db, new ElementInfo(inputWrapper, null), inputElements); + WrapperInfo outputWrapperInfo = new WrapperInfo(db, new ElementInfo(outputWrapper, null), outputElements); - wrapperInfo.setInputWrapperType(inputWrapperDT); - wrapperInfo.setOutputWrapperType(outputWrapperDT); + inputWrapperInfo.setWrapperType(inputWrapperDT); + outputWrapperInfo.setWrapperType(outputWrapperDT); - operation.setWrapper(wrapperInfo); + operation.setInputWrapper(inputWrapperInfo); + operation.setOutputWrapper(outputWrapperInfo); } // In both bare and wrapped cases, remove OUT-only parameters from input DataType. diff --git a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessorTestCase.java b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessorTestCase.java index 5f3114a67c..517f922a54 100644 --- a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessorTestCase.java +++ b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessorTestCase.java @@ -61,9 +61,9 @@ public class JAXWSJavaInterfaceProcessorTestCase { // interfaceProcessor.visitInterface(contract); Operation op = contract.getOperations().get(0); - Assert.assertTrue(!op.isWrapperStyle()); - Assert.assertEquals(new QName("http://www.example.com/stock", "stockQuoteOffer"), op.getWrapper().getInputWrapperElement().getQName()); - Assert.assertEquals(new QName("http://www.example.com/stock", "stockQuoteOfferResponse"), op.getWrapper().getOutputWrapperElement().getQName()); + Assert.assertTrue(!op.isInputWrapperStyle()); + Assert.assertEquals(new QName("http://www.example.com/stock", "stockQuoteOffer"), op.getInputWrapper().getWrapperElement().getQName()); + Assert.assertEquals(new QName("http://www.example.com/stock", "stockQuoteOfferResponse"), op.getOutputWrapper().getWrapperElement().getQName()); } /** @@ -92,14 +92,14 @@ public class JAXWSJavaInterfaceProcessorTestCase { op = op2; } - assertTrue(!op.isWrapperStyle() && op.getWrapper() == null); + assertTrue(!op.isInputWrapperStyle() && op.getInputWrapper() == null); if ("M2".equals(op2.getName())) { op = op2; } else { op = op1; } - assertTrue(!op.isWrapperStyle() && op.getWrapper() != null); + assertTrue(!op.isInputWrapperStyle() && op.getInputWrapper() != null); } diff --git a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java index 430f724d2e..9adeb26451 100644 --- a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java +++ b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java @@ -210,8 +210,10 @@ public class JavaInterfaceImpl extends InterfaceImpl implements JavaInterface { syncOperation.setName(opName); syncOperation.setAsyncServer(true); - syncOperation.setWrapper(operation.getWrapper()); - syncOperation.setWrapperStyle(operation.isWrapperStyle()); + syncOperation.setInputWrapper(operation.getInputWrapper()); + syncOperation.setOutputWrapper(operation.getOutputWrapper()); + syncOperation.setInputWrapperStyle(operation.isInputWrapperStyle()); + syncOperation.setOutputWrapperStyle(operation.isOutputWrapperStyle()); syncOperation.setHasArrayWrappedOutput(operation.hasArrayWrappedOutput()); syncOperation.setNotSubjectToWrapping(operation.isNotSubjectToWrapping()); // syncOperation.setInputType(inputType); diff --git a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java index 275049c0fe..830258a8c0 100644 --- a/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java +++ b/sca-java-2.x/trunk/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java @@ -219,10 +219,12 @@ public class WSDLOperationIntrospectorImpl { } operationModel.setOutputType(getOutputType()); - operationModel.setWrapperStyle(isWrapperStyle()); + operationModel.setInputWrapperStyle(isWrapperStyle()); + operationModel.setOutputWrapperStyle(isWrapperStyle()); + if (isWrapperStyle()) { - WrapperInfo wrapperInfo = getWrapper().getWrapperInfo(); - operationModel.setWrapper(wrapperInfo); + operationModel.setInputWrapper(getWrapper().getInputWrapperInfo()); + operationModel.setOutputWrapper(getWrapper().getOutputWrapperInfo()); } } return operationModel; @@ -347,11 +349,8 @@ public class WSDLOperationIntrospectorImpl { private List<XmlSchemaElement> outputElements; - // private DataType<List<DataType<XMLType>>> unwrappedInputType; - // - // private DataType<XMLType> unwrappedOutputType; - - private transient WrapperInfo wrapperInfo; + private transient WrapperInfo inputWrapperInfo; + private transient WrapperInfo outputWrapperInfo; private List<XmlSchemaElement> getChildElements(XmlSchemaElement element) throws InvalidWSDLException { if (element == null) { @@ -519,61 +518,34 @@ public class WSDLOperationIntrospectorImpl { return outputWrapperElement; } - /* - public DataType<List<DataType<XMLType>>> getUnwrappedInputType() throws InvalidWSDLException { - if (unwrappedInputType == null) { - List<DataType<XMLType>> childTypes = new ArrayList<DataType<XMLType>>(); - for (XmlSchemaElement element : getInputChildElements()) { - DataType<XMLType> type = - new DataType<XMLType>(dataBinding, Object.class, new XMLType(getElementInfo(element))); - // type.setMetadata(ElementInfo.class.getName(), getElementInfo(element)); - childTypes.add(type); - } - unwrappedInputType = - new DataType<List<DataType<XMLType>>>("idl:unwrapped.input", Object[].class, childTypes); - } - return unwrappedInputType; - } - - public DataType<XMLType> getUnwrappedOutputType() throws InvalidServiceContractException { - if (unwrappedOutputType == null) { - List<XmlSchemaElement> elements = getOutputChildElements(); - if (elements != null && elements.size() > 0) { - if (elements.size() > 1) { - // We don't support output with multiple parts - throw new NotSupportedWSDLException("Multi-part output is not supported"); - } - XmlSchemaElement element = elements.get(0); - unwrappedOutputType = - new DataType<XMLType>(dataBinding, Object.class, new XMLType(getElementInfo(element))); - // unwrappedOutputType.setMetadata(ElementInfo.class.getName(), getElementInfo(element)); - } - } - return unwrappedOutputType; - } - */ - - public WrapperInfo getWrapperInfo() throws InvalidWSDLException { - if (wrapperInfo == null) { + public WrapperInfo getInputWrapperInfo() throws InvalidWSDLException { + if (inputWrapperInfo == null) { ElementInfo in = getElementInfo(getInputWrapperElement()); - ElementInfo out = getElementInfo(getOutputWrapperElement()); List<ElementInfo> inChildren = new ArrayList<ElementInfo>(); if (in != null) { for (XmlSchemaElement e : getInputChildElements()) { inChildren.add(getElementInfo(e)); } } + inputWrapperInfo = new WrapperInfo(dataBinding, in, inChildren); + } + return inputWrapperInfo; + } + + public WrapperInfo getOutputWrapperInfo() throws InvalidWSDLException { + if (outputWrapperInfo == null) { + ElementInfo out = getElementInfo(getOutputWrapperElement()); List<ElementInfo> outChildren = new ArrayList<ElementInfo>(); if (out != null) { for (XmlSchemaElement e : getOutputChildElements()) { outChildren.add(getElementInfo(e)); } } - wrapperInfo = new WrapperInfo(dataBinding, in, out, inChildren, outChildren); + outputWrapperInfo = new WrapperInfo(dataBinding, out, outChildren); } - return wrapperInfo; + return outputWrapperInfo; } - } + } private static ElementInfo getElementInfo(XmlSchemaElement element) { if (element == null) { diff --git a/sca-java-2.x/trunk/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java b/sca-java-2.x/trunk/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java index cb0b347ae4..20397b5093 100644 --- a/sca-java-2.x/trunk/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java +++ b/sca-java-2.x/trunk/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java @@ -71,15 +71,15 @@ public class WSDLOperationIntrospectorTestCase extends AbstractWSDLTestCase { DataType<XMLType> logical = outputType.getLogical().get(0); Assert.assertEquals(new QName("http://example.com/stockquote.xsd", "getLastTradePriceResponse"), logical.getLogical().getElementName()); - Assert.assertTrue(op.isWrapperStyle()); + Assert.assertTrue(op.isInputWrapperStyle()); - DataType<List<DataType>> unwrappedInputType = op.getWrapper().getUnwrappedInputType(); + DataType<List<DataType>> unwrappedInputType = op.getInputWrapper().getUnwrappedType(); List<DataType> childTypes = unwrappedInputType.getLogical(); Assert.assertEquals(1, childTypes.size()); DataType<XMLType> childType = childTypes.get(0); Assert.assertEquals(new QName(null, "tickerSymbol"), childType.getLogical().getElementName()); - DataType<List<DataType>> unwrappedOutputType = op.getWrapper().getUnwrappedOutputType(); + DataType<List<DataType>> unwrappedOutputType = op.getOutputWrapper().getUnwrappedType(); childTypes = unwrappedOutputType.getLogical(); Assert.assertEquals(1, childTypes.size()); childType = childTypes.get(0); @@ -97,11 +97,11 @@ public class WSDLOperationIntrospectorTestCase extends AbstractWSDLTestCase { WSDLInterface wi = wsdlFactory.createWSDLInterface(portType, definition, resolver, context.getMonitor()); WSDLOperation op = (WSDLOperation) wi.getOperations().get(1); - Assert.assertFalse(op.isWrapperStyle()); + Assert.assertFalse(op.isInputWrapperStyle()); Assert.assertEquals(1, op.getInputType().getLogical().size()); op = (WSDLOperation) wi.getOperations().get(2); - Assert.assertFalse(op.isWrapperStyle()); + Assert.assertFalse(op.isInputWrapperStyle()); Assert.assertEquals(2, op.getInputType().getLogical().size()); } @@ -118,7 +118,7 @@ public class WSDLOperationIntrospectorTestCase extends AbstractWSDLTestCase { WSDLInterface wi = wsdlFactory.createWSDLInterface(portType, definition, resolver, context.getMonitor()); WSDLOperation op = (WSDLOperation) wi.getOperations().get(0); - op.isWrapperStyle(); + op.isInputWrapperStyle(); fail("InvalidWSDLException should have been thrown"); } catch (InvalidInterfaceException e) { // Expected diff --git a/sca-java-2.x/trunk/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java b/sca-java-2.x/trunk/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java index c2d6f40416..533bb6fe29 100644 --- a/sca-java-2.x/trunk/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java +++ b/sca-java-2.x/trunk/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java @@ -52,9 +52,9 @@ public class WrapperStyleOperationTestCase extends AbstractWSDLTestCase { PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME); WSDLInterface wi = wsdlFactory.createWSDLInterface(portType, definition, resolver, context.getMonitor()); WSDLOperation op = (WSDLOperation) wi.getOperations().get(0); - Assert.assertTrue(op.isWrapperStyle()); - Assert.assertEquals(1, op.getWrapper().getInputChildElements().size()); - Assert.assertEquals(1, op.getWrapper().getOutputChildElements().size()); + Assert.assertTrue(op.isInputWrapperStyle()); + Assert.assertEquals(1, op.getInputWrapper().getChildElements().size()); + Assert.assertEquals(1, op.getOutputWrapper().getChildElements().size()); } @Test @@ -67,11 +67,11 @@ public class WrapperStyleOperationTestCase extends AbstractWSDLTestCase { PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME); WSDLInterface wi = wsdlFactory.createWSDLInterface(portType, definition, resolver, context.getMonitor()); WSDLOperation op = (WSDLOperation) wi.getOperations().get(0); - Assert.assertTrue(op.isWrapperStyle()); + Assert.assertTrue(op.isInputWrapperStyle()); op = (WSDLOperation) wi.getOperations().get(1); - Assert.assertFalse(op.isWrapperStyle()); + Assert.assertFalse(op.isInputWrapperStyle()); op = (WSDLOperation) wi.getOperations().get(2); - Assert.assertFalse(op.isWrapperStyle()); + Assert.assertFalse(op.isInputWrapperStyle()); } @@ -86,7 +86,7 @@ public class WrapperStyleOperationTestCase extends AbstractWSDLTestCase { PortType portType = definition.getDefinition().getPortType(PORTTYPE_NAME); WSDLInterface wi = wsdlFactory.createWSDLInterface(portType, definition, resolver, context.getMonitor()); WSDLOperation op = (WSDLOperation) wi.getOperations().get(0); - Assert.assertFalse(op.isWrapperStyle()); + Assert.assertFalse(op.isInputWrapperStyle()); } } |