diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/databinding/src')
4 files changed, 39 insertions, 20 deletions
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
|