From 699653d2ae2df1cec6af2915c90a6a7137a1c077 Mon Sep 17 00:00:00 2001 From: slaws Date: Tue, 13 Dec 2011 14:12:38 +0000 Subject: TUSCANY-3890 - separate the request wrapper model from the response wrapper model as per the change in 1.x under TUSCANY-2931. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1213702 13f79535-47bb-0310-9956-ffa450edef68 --- .../databinding/axiom/OMElementWrapperHandler.java | 33 ++++++++++++++++------ .../axiom/OMElementWrapperHandlerTestCase.java | 4 +-- 2 files changed, 26 insertions(+), 11 deletions(-) (limited to 'sca-java-2.x/trunk/modules/databinding-axiom/src') 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 { } 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 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 { } public List getChildren(OMElement wrapper, Operation operation, boolean input) { - List childElements = input? operation.getWrapper().getInputChildElements(): - operation.getWrapper().getOutputChildElements(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + List childElements = input? inputWrapperInfo.getChildElements(): + outputWrapperInfo.getChildElements(); // Used in both the schema-valid and schema-invalid paths List> groupedElements = getElements(wrapper); @@ -264,16 +273,22 @@ public class OMElementWrapperHandler implements WrapperHandler { * @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 wrapperType = new DataTypeImpl(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 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 -- cgit v1.2.3