From aef1e52d6377f18516371655c32125c68bac0cce Mon Sep 17 00:00:00 2001 From: slaws Date: Thu, 26 Mar 2009 13:23:57 +0000 Subject: TUSCANY-2931 - allow separate request and response wire formats in binding.jms. The tuscany binding.jms XSD has been extended to allow a response wireFormat element to be specified. The knock on effect of all this is that the Operation interface has been changed to allow input and output wrapper info to be held separately. Also Interface has some new operations. There are changes across the code base to take account of this interface change. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@758625 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tuscany/sca/interfacedef/DataType.java | 2 +- .../apache/tuscany/sca/interfacedef/Interface.java | 16 +++ .../apache/tuscany/sca/interfacedef/Operation.java | 37 ++++-- .../impl/InterfaceContractMapperImpl.java | 8 +- .../sca/interfacedef/impl/InterfaceImpl.java | 82 ++++++++++-- .../sca/interfacedef/impl/OperationImpl.java | 74 ++++++++--- .../tuscany/sca/interfacedef/util/WrapperInfo.java | 144 +++++++-------------- 7 files changed, 227 insertions(+), 136 deletions(-) (limited to 'branches/sca-java-1.x/modules/interface/src/main/java') diff --git a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java index 1f5620c0b9..63e26ef7f7 100644 --- a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java +++ b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java @@ -27,7 +27,7 @@ import java.lang.reflect.Type; * runtime is written in Java. This may be the same form used by the application * but it may not; for example, an application that is performing stream * processing may want a physical form such as an - * {@link java.io.InputStream InputStream} to semantially operate on application + * {@link java.io.InputStream InputStream} to semantically operate on application * data such as a purchase order. The logical description is that used by the * assembly model and is an identifier into some well-known type space; examples * may be a Java type represented by its Class or an XML type represented by its diff --git a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java index f9de645a6e..1e91dc6fdb 100644 --- a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java +++ b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java @@ -79,6 +79,22 @@ public interface Interface extends Cloneable, PolicySetAttachPoint { * @param dataBinding */ void resetDataBinding(String dataBinding); + + /** + * Set the interface input types by copying those from the + * interface provided + * + * @param newInterface + */ + public void resetInterfaceInputTypes(Interface newInterface); + + /** + * Set the interface output types by copying those from the + * interface provided + * + * @param newInterface + */ + public void resetInterfaceOutputTypes(Interface newInterface); /** * Returns true if the Interface is dynamic. diff --git a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java index 4676e35f80..51b7645e57 100644 --- a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java +++ b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java @@ -132,26 +132,47 @@ public interface Operation extends Cloneable, PolicySetAttachPoint { * Set the operation to be non-blocking */ void setNonBlocking(boolean nonBlocking); + + /** + * @return the inputWrapperInfo + */ + WrapperInfo getInputWrapper(); + + /** + * @param wrapperInfo the inputWrapperInfo to set + */ + void setInputWrapper(WrapperInfo wrapperInfo); /** - * @return the wrapperInfo + * @return the outputWrapperInfo */ - WrapperInfo getWrapper(); + WrapperInfo getOutputWrapper(); /** - * @param wrapperInfo the wrapperInfo to set + * @param wrapperInfo the outputWrapperInfo to set */ - void setWrapper(WrapperInfo wrapperInfo); + // TODO - WI + void setOutputWrapper(WrapperInfo wrapperInfo); /** - * @return the wrapperStyle + * @return the inputWrapperStyle + */ + boolean isInputWrapperStyle(); + + /** + * @param inputWrapperStyle the wrapperStyle to set + */ + void setInputWrapperStyle(boolean wrapperStyle); + + /** + * @return the outputWrapperStyle */ - boolean isWrapperStyle(); + boolean isOutputWrapperStyle(); /** - * @param wrapperStyle the wrapperStyle to set + * @param outputWrapperStyle the wrapperStyle to set */ - void setWrapperStyle(boolean wrapperStyle); + void setOutputWrapperStyle(boolean wrapperStyle); /** * @deprecated This should be the WrapperInfo.getDataBinding() diff --git a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java index 9e7d6882f7..149e6306e5 100644 --- a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java +++ b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java @@ -87,14 +87,14 @@ public class InterfaceContractMapperImpl implements InterfaceContractMapper { boolean checkSourceWrapper = true; List sourceInputType = source.getInputType().getLogical(); - if (source.isWrapperStyle() && source.getWrapper() != null) { - sourceInputType = source.getWrapper().getUnwrappedInputType().getLogical(); + if (source.isInputWrapperStyle() && source.getInputWrapper() != null) { + sourceInputType = source.getInputWrapper().getUnwrappedInputType().getLogical(); checkSourceWrapper = false; } boolean checkTargetWrapper = true; List targetInputType = target.getInputType().getLogical(); - if (target.isWrapperStyle() && target.getWrapper() != null) { - targetInputType = target.getWrapper().getUnwrappedInputType().getLogical(); + if (target.isInputWrapperStyle() && target.getInputWrapper() != null) { + targetInputType = target.getInputWrapper().getUnwrappedInputType().getLogical(); checkTargetWrapper = false; } diff --git a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java index e2a524c5e0..23f1eec8cf 100644 --- a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java +++ b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java @@ -151,10 +151,11 @@ public class InterfaceImpl implements Interface { } } - if (op.isWrapperStyle()) { - WrapperInfo wrapper = op.getWrapper(); - if (wrapper != null) { - DataType> unwrappedInputType = wrapper.getUnwrappedInputType(); + + if (op.isInputWrapperStyle()) { + WrapperInfo inputWrapperInfo = op.getInputWrapper(); + if (inputWrapperInfo != null) { + DataType> unwrappedInputType = inputWrapperInfo.getUnwrappedInputType(); if (unwrappedInputType != null) { for (DataType d : unwrappedInputType.getLogical()) { if (d.getDataBinding() == null) { @@ -162,7 +163,13 @@ public class InterfaceImpl implements Interface { } } } - DataType unwrappedOutputType = wrapper.getUnwrappedOutputType(); + } + } + + if (op.isOutputWrapperStyle()) { + WrapperInfo outputWrapperInfo = op.getOutputWrapper(); + if (outputWrapperInfo != null){ + DataType unwrappedOutputType = outputWrapperInfo.getUnwrappedOutputType(); if (unwrappedOutputType != null && unwrappedOutputType.getDataBinding() == null) { unwrappedOutputType.setDataBinding(dataBinding); } @@ -179,6 +186,54 @@ public class InterfaceImpl implements Interface { dataType.setDataBinding(dataBinding); } } + + public void resetInterfaceInputTypes(Interface newInterface){ + for (int i = 0; i < getOperations().size(); i++) { + // TODO - same operation order is assumed. How to really + // find the right operation when we know that the + // data types will be different + Operation oldOperation = getOperations().get(i); + Operation newOperation = newInterface.getOperations().get(i); + + if (!oldOperation.getName().equals(newOperation.getName())){ + break; + } + + // set input types + oldOperation.setInputType(newOperation.getInputType()); + + // set wrapper + if (newOperation.isInputWrapperStyle()) { + oldOperation.setInputWrapperStyle(true); + oldOperation.setInputWrapper(newOperation.getInputWrapper()); + } + } + } + + public void resetInterfaceOutputTypes(Interface newInterface){ + for (int i = 0; i < getOperations().size(); i++) { + // TODO - same operation order is assumed. How to really + // find the right operation when we know that the + // data types will be different + Operation oldOperation = getOperations().get(i); + Operation newOperation = newInterface.getOperations().get(i); + + if (!oldOperation.getName().equals(newOperation.getName())){ + break; + } + + // set output types + oldOperation.setOutputType(newOperation.getOutputType()); + + // set fault types + oldOperation.setFaultTypes(newOperation.getFaultTypes()); + + // set wrapper + if (newOperation.isOutputWrapperStyle()) { + oldOperation.setOutputWrapper(newOperation.getOutputWrapper()); + } + } + } public void resetDataBinding(String dataBinding) { for (Operation op : getOperations()) { @@ -200,16 +255,23 @@ public class InterfaceImpl implements Interface { setDataBinding((DataType) d.getLogical(), dataBinding); } } - if (op.isWrapperStyle()) { - WrapperInfo wrapper = op.getWrapper(); - if (wrapper != null) { - DataType> unwrappedInputType = wrapper.getUnwrappedInputType(); + + if (op.isInputWrapperStyle()) { + WrapperInfo inputWrapperInfo = op.getInputWrapper(); + if (inputWrapperInfo != null) { + DataType> unwrappedInputType = inputWrapperInfo.getUnwrappedInputType(); if (unwrappedInputType != null) { for (DataType d : unwrappedInputType.getLogical()) { setDataBinding(d, dataBinding); } } - DataType unwrappedOutputType = wrapper.getUnwrappedOutputType(); + } + } + + if (op.isOutputWrapperStyle()) { + WrapperInfo outputWrapperInfo = op.getOutputWrapper(); + if (outputWrapperInfo != null){ + DataType unwrappedOutputType = outputWrapperInfo.getUnwrappedOutputType(); if (unwrappedOutputType != null) { setDataBinding(unwrappedOutputType, dataBinding); } diff --git a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java index 00a5dc3065..4b61dbe7ea 100644 --- a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java +++ b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java @@ -50,8 +50,12 @@ public class OperationImpl implements Operation { private Interface interfaze; private ConversationSequence conversationSequence = ConversationSequence.CONVERSATION_NONE; private boolean nonBlocking; - private boolean wrapperStyle; - private WrapperInfo wrapper; + // TODO - WI + //private WrapperInfo wrapper; + private boolean inputWrapperStyle; + private boolean outputWrapperStyle; + private WrapperInfo inputWrapper; + private WrapperInfo outputWrapper; private boolean dynamic; private Map>> faultBeans; @@ -238,38 +242,76 @@ public class OperationImpl implements Operation { /** * @return the wrapperInfo */ - public WrapperInfo getWrapper() { - return wrapper; - } + // TODO - WI + //public WrapperInfo getWrapper() { + // return wrapper; + //} /** * @param wrapperInfo the wrapperInfo to set */ - public void setWrapper(WrapperInfo wrapperInfo) { - this.wrapper = wrapperInfo; + // TODO - WI + //public void setWrapper(WrapperInfo wrapperInfo) { + // this.wrapper = wrapperInfo; + //} + + public WrapperInfo getInputWrapper() { + return inputWrapper; + } + + public void setInputWrapper(WrapperInfo inputWrapper) { + this.inputWrapper = inputWrapper; + } + + public WrapperInfo getOutputWrapper() { + return outputWrapper; + } + + public void setOutputWrapper(WrapperInfo outputWrapper) { + this.outputWrapper = outputWrapper; } /** - * @return the wrapperStyle + * @return the inputWrapperStyle */ - public boolean isWrapperStyle() { - return wrapperStyle; + public boolean isInputWrapperStyle() { + return inputWrapperStyle; } /** - * @param wrapperStyle the wrapperStyle to set + * @param inputWrapperStyle the wrapperStyle to set */ - public void setWrapperStyle(boolean wrapperStyle) { - this.wrapperStyle = wrapperStyle; + public void setInputWrapperStyle(boolean wrapperStyle) { + this.inputWrapperStyle = wrapperStyle; + } + + /** + * @return the outputWrapperStyle + */ + public boolean isOutputWrapperStyle() { + return inputWrapperStyle; } + /** + * @param outputWrapperStyle the wrapperStyle to set + */ + public void setOutputWrapperStyle(boolean wrapperStyle) { + this.inputWrapperStyle = wrapperStyle; + } + + // TODO - WI + // These are deprecated and are a little awkward now that + // we split input wrapper from output wrapper public String getDataBinding() { - return wrapper != null ? wrapper.getDataBinding() : null; + return inputWrapper != null ? inputWrapper.getDataBinding() : null; } public void setDataBinding(String dataBinding) { - if (wrapper != null) { - wrapper.setDataBinding(dataBinding); + if (inputWrapper != null) { + inputWrapper.setDataBinding(dataBinding); + } + if (outputWrapper != null) { + outputWrapper.setDataBinding(dataBinding); } } diff --git a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java index 12db460959..b5a7915a11 100644 --- a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java +++ b/branches/sca-java-1.x/modules/interface/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: *
    - *
  • (i) The operation�s input and output messages (if present) each contain + *
  • (i) The operation is input and output messages (if present) each contain * only a single part *
  • (ii) The input message part refers to a global element declaration whose * localname is equal to the operation name @@ -48,76 +48,61 @@ import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl; * @version $Rev$ $Date$ */ public class WrapperInfo { - private ElementInfo inputWrapperElement; - - private ElementInfo outputWrapperElement; - - private List inputChildElements; - - private List outputChildElements; + private String dataBinding; + private ElementInfo wrapperElement; + private List childElements; + private DataType wrapperType; - // The data type of the unwrapped input child elements + // A cache for the derived data type of the unwrapped + // input child elements private DataType> unwrappedInputType; - // The data type of the unwrapped output child element (we only supports one child) + // A cache for the derived data type of the unwrapped + // output child element (we only support one child) private DataType unwrappedOutputType; - // The data for the input/output wrappers - private String dataBinding; - - // The data type for the input (request) wrapper bean - private DataType inputWrapperType; - // The data type for the output (response) wrapper bean - private DataType outputWrapperType; - public WrapperInfo(String dataBinding, - ElementInfo inputWrapperElement, - ElementInfo outputWrapperElement, - List inputElements, - List outputElements) { + ElementInfo wrapperElement, + List 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 - */ - public List getInputChildElements() { - return inputChildElements; + public List getChildElements() { + return childElements; } - /** - * @return the inputWrapperElement - */ - public ElementInfo getInputWrapperElement() { - return inputWrapperElement; + public ElementInfo getWrapperElement() { + return wrapperElement; + } + + public String getDataBinding() { + return dataBinding; + } + + public void setDataBinding(String dataBinding) { + this.dataBinding = dataBinding; } - /** - * @return the outputElements - */ - public List getOutputChildElements() { - return outputChildElements; + public DataType getWrapperType() { + return wrapperType; } - /** - * @return the outputWrapperElement - */ - public ElementInfo getOutputWrapperElement() { - return outputWrapperElement; + public void setWrapperType(DataType wrapperType) { + this.wrapperType = wrapperType; } + + public Class getWrapperClass() { + return wrapperType == null ? null : wrapperType.getPhysical(); + } + - /** - * @return the unwrappedInputType - */ public DataType> getUnwrappedInputType() { if (unwrappedInputType == null) { List childTypes = new ArrayList(); - for (ElementInfo element : getInputChildElements()) { + for (ElementInfo element : getChildElements()) { DataType type = getDataType(element); childTypes.add(type); } @@ -126,23 +111,9 @@ public class WrapperInfo { return unwrappedInputType; } - private DataType getDataType(ElementInfo element) { - DataType type = null; - if (element.isMany()) { - DataType logical = new DataTypeImpl(dataBinding, Object.class, new XMLType(element)); - type = new DataTypeImpl("java:array", Object[].class, logical); - } else { - type = new DataTypeImpl(dataBinding, Object.class, new XMLType(element)); - } - return type; - } - - /** - * @return the unwrappedOutputType - */ public DataType getUnwrappedOutputType() { if (unwrappedOutputType == null) { - List elements = getOutputChildElements(); + List elements = getChildElements(); if (elements != null && elements.size() > 0) { if (elements.size() > 1) { // We don't support output with multiple parts @@ -155,36 +126,15 @@ public class WrapperInfo { } 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 getInputWrapperType() { - return inputWrapperType; - } - - public void setInputWrapperType(DataType inputWrapperType) { - this.inputWrapperType = inputWrapperType; - } - - public DataType getOutputWrapperType() { - return outputWrapperType; - } - - public void setOutputWrapperType(DataType outputWrapperType) { - this.outputWrapperType = outputWrapperType; - } + + private DataType getDataType(ElementInfo element) { + DataType type = null; + if (element.isMany()) { + DataType logical = new DataTypeImpl(dataBinding, Object.class, new XMLType(element)); + type = new DataTypeImpl("java:array", Object[].class, logical); + } else { + type = new DataTypeImpl(dataBinding, Object.class, new XMLType(element)); + } + return type; + } } -- cgit v1.2.3