diff options
Diffstat (limited to '')
7 files changed, 227 insertions, 136 deletions
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<DataType> 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<DataType> 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<List<DataType>> unwrappedInputType = wrapper.getUnwrappedInputType(); + + if (op.isInputWrapperStyle()) { + WrapperInfo inputWrapperInfo = op.getInputWrapper(); + if (inputWrapperInfo != null) { + DataType<List<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<List<DataType>> unwrappedInputType = wrapper.getUnwrappedInputType(); + + if (op.isInputWrapperStyle()) { + WrapperInfo inputWrapperInfo = op.getInputWrapper(); + if (inputWrapperInfo != null) { + DataType<List<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<QName, List<DataType<XMLType>>> 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: * <ul> - * <li>(i) The operation�s input and output messages (if present) each contain + * <li>(i) The operation is 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 @@ -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<ElementInfo> inputChildElements; - - private List<ElementInfo> outputChildElements; + private String dataBinding; + private ElementInfo wrapperElement; + private List<ElementInfo> childElements; + private DataType<XMLType> 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<List<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<XMLType> unwrappedOutputType; - // The data for the input/output wrappers - 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; - 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 - */ - public List<ElementInfo> getInputChildElements() { - return inputChildElements; + public List<ElementInfo> 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<ElementInfo> getOutputChildElements() { - return outputChildElements; + public DataType<XMLType> getWrapperType() { + return wrapperType; } - /** - * @return the outputWrapperElement - */ - public ElementInfo getOutputWrapperElement() { - return outputWrapperElement; + public void setWrapperType(DataType<XMLType> wrapperType) { + this.wrapperType = wrapperType; } + + public Class<?> getWrapperClass() { + return wrapperType == null ? null : wrapperType.getPhysical(); + } + - /** - * @return the unwrappedInputType - */ public DataType<List<DataType>> getUnwrappedInputType() { if (unwrappedInputType == null) { List<DataType> childTypes = new ArrayList<DataType>(); - 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<XMLType>(dataBinding, Object.class, new XMLType(element)); - type = new DataTypeImpl<DataType>("java:array", Object[].class, logical); - } else { - type = new DataTypeImpl<XMLType>(dataBinding, Object.class, new XMLType(element)); - } - return type; - } - - /** - * @return the unwrappedOutputType - */ public DataType getUnwrappedOutputType() { if (unwrappedOutputType == null) { - List<ElementInfo> elements = getOutputChildElements(); + List<ElementInfo> 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<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; - } + + private DataType getDataType(ElementInfo element) { + DataType type = null; + if (element.isMany()) { + DataType logical = new DataTypeImpl<XMLType>(dataBinding, Object.class, new XMLType(element)); + type = new DataTypeImpl<DataType>("java:array", Object[].class, logical); + } else { + type = new DataTypeImpl<XMLType>(dataBinding, Object.class, new XMLType(element)); + } + return type; + } } |