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