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 --- .../DataBindingJavaInterfaceProcessor.java | 6 ++-- .../processor/WrapperJavaInterfaceProcessor.java | 19 +++++----- .../transformers/Input2InputTransformer.java | 32 ++++++++--------- .../transformers/Output2OutputTransformer.java | 42 +++++++++++----------- .../wire/DataBindingRuntimeWireProcessor.java | 6 +++- 5 files changed, 56 insertions(+), 49 deletions(-) (limited to 'branches/sca-java-1.x/modules/core-databinding') diff --git a/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/DataBindingJavaInterfaceProcessor.java b/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/DataBindingJavaInterfaceProcessor.java index 9e3fbaf4e4..8f35b2b00f 100644 --- a/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/DataBindingJavaInterfaceProcessor.java +++ b/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/DataBindingJavaInterfaceProcessor.java @@ -74,7 +74,8 @@ public class DataBindingJavaInterfaceProcessor implements JavaInterfaceVisitor { } if (dataBindingId != null) { op.setDataBinding(dataBindingId); - op.setWrapperStyle(wrapperStyle); + op.setInputWrapperStyle(wrapperStyle); + op.setOutputWrapperStyle(wrapperStyle); } } for (Method method : clazz.getMethods()) { @@ -95,7 +96,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/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/WrapperJavaInterfaceProcessor.java b/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/WrapperJavaInterfaceProcessor.java index 3de5261372..702da720a0 100644 --- a/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/WrapperJavaInterfaceProcessor.java +++ b/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/WrapperJavaInterfaceProcessor.java @@ -54,12 +54,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); } @@ -68,13 +69,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); } } } @@ -118,10 +119,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/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Input2InputTransformer.java b/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Input2InputTransformer.java index fb5f939edb..f537dc4524 100644 --- a/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Input2InputTransformer.java +++ b/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Input2InputTransformer.java @@ -105,13 +105,13 @@ public class Input2InputTransformer extends BaseTransformer 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 list1 = w1.getInputChildElements(); - List list2 = w2.getInputChildElements(); + List list1 = w1.getChildElements(); + List list2 = w2.getChildElements(); if (list1.size() != list2.size()) { return false; } @@ -133,8 +133,8 @@ public class Input2InputTransformer extends BaseTransformer // Check if the source operation is wrapped DataType> sourceType = context.getSourceDataType(); Operation sourceOp = context.getSourceOperation(); - boolean sourceWrapped = sourceOp != null && sourceOp.isWrapperStyle() && sourceOp.getWrapper() != null; - boolean sourceBare = sourceOp != null && !sourceOp.isWrapperStyle() && sourceOp.getWrapper() == null; + boolean sourceWrapped = sourceOp != null && sourceOp.isInputWrapperStyle() && sourceOp.getInputWrapper() != null; + boolean sourceBare = sourceOp != null && !sourceOp.isInputWrapperStyle() && sourceOp.getInputWrapper() == null; // Find the wrapper handler for source data WrapperHandler sourceWrapperHandler = null; @@ -144,8 +144,8 @@ public class Input2InputTransformer extends BaseTransformer // Check if the target operation is wrapped DataType> targetType = context.getTargetDataType(); Operation targetOp = (Operation)context.getTargetOperation(); - boolean targetWrapped = targetOp != null && targetOp.isWrapperStyle() && targetOp.getWrapper() != null; - boolean targetBare = targetOp != null && !targetOp.isWrapperStyle() && targetOp.getWrapper() == null; + boolean targetWrapped = targetOp != null && targetOp.isInputWrapperStyle() && targetOp.getInputWrapper() != null; + boolean targetBare = targetOp != null && !targetOp.isInputWrapperStyle() && targetOp.getInputWrapper() == null; // Find the wrapper handler for target data WrapperHandler targetWrapperHandler = null; @@ -154,7 +154,7 @@ public class Input2InputTransformer extends BaseTransformer if ((!sourceWrapped && !sourceBare) && targetWrapped) { // Unwrapped --> Wrapped - WrapperInfo wrapper = targetOp.getWrapper(); + WrapperInfo wrapper = targetOp.getInputWrapper(); // ElementInfo wrapperElement = wrapper.getInputWrapperElement(); // Class targetWrapperClass = wrapper != null ? wrapper.getInputWrapperClass() : null; @@ -167,12 +167,12 @@ public class Input2InputTransformer extends BaseTransformer // 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 @@ -221,10 +221,10 @@ public class Input2InputTransformer extends BaseTransformer // 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()); @@ -236,7 +236,7 @@ public class Input2InputTransformer extends BaseTransformer Object[] sourceChildren = sourceWrapperHandler.getChildren(sourceWrapper, sourceOp, true).toArray(); target = new Object[sourceChildren.length]; for (int i = 0; i < sourceChildren.length; i++) { - DataType childType = sourceOp.getWrapper().getUnwrappedInputType().getLogical().get(i); + DataType childType = sourceOp.getInputWrapper().getUnwrappedInputType().getLogical().get(i); target[i] = mediator.mediate(sourceChildren[i], childType, targetType.getLogical().get(i), context .getMetadata()); @@ -268,7 +268,7 @@ public class Input2InputTransformer extends BaseTransformer } private String getDataBinding(Operation operation) { - WrapperInfo wrapper = operation.getWrapper(); + WrapperInfo wrapper = operation.getInputWrapper(); if (wrapper != null) { return wrapper.getDataBinding(); } else { diff --git a/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Output2OutputTransformer.java b/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Output2OutputTransformer.java index 8d586905c4..348d8345b2 100644 --- a/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Output2OutputTransformer.java +++ b/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Output2OutputTransformer.java @@ -95,7 +95,7 @@ public class Output2OutputTransformer extends BaseTransformer im } private String getDataBinding(Operation operation) { - WrapperInfo wrapper = operation.getWrapper(); + WrapperInfo wrapper = operation.getOutputWrapper(); if (wrapper != null) { return wrapper.getDataBinding(); } else { @@ -126,13 +126,13 @@ public class Output2OutputTransformer extends BaseTransformer 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 list1 = w1.getOutputChildElements(); - List list2 = w2.getOutputChildElements(); + List list1 = w1.getChildElements(); + List list2 = w2.getChildElements(); if (list1.size() != list2.size()) { return false; } @@ -154,8 +154,8 @@ public class Output2OutputTransformer extends BaseTransformer im try { DataType sourceType = context.getSourceDataType(); Operation sourceOp = context.getSourceOperation(); - boolean sourceWrapped = sourceOp != null && sourceOp.isWrapperStyle() && sourceOp.getWrapper() != null; - boolean sourceBare = sourceOp != null && !sourceOp.isWrapperStyle() && sourceOp.getWrapper() == null; + boolean sourceWrapped = sourceOp != null && sourceOp.isOutputWrapperStyle() && sourceOp.getOutputWrapper() != null; + boolean sourceBare = sourceOp != null && !sourceOp.isOutputWrapperStyle() && sourceOp.getOutputWrapper() == null; WrapperHandler sourceWrapperHandler = null; String sourceDataBinding = getDataBinding(sourceOp); @@ -163,8 +163,8 @@ public class Output2OutputTransformer extends BaseTransformer im DataType targetType = context.getTargetDataType(); Operation targetOp = (Operation)context.getTargetOperation(); - boolean targetWrapped = targetOp != null && targetOp.isWrapperStyle() && targetOp.getWrapper() != null; - boolean targetBare = targetOp != null && !targetOp.isWrapperStyle() && targetOp.getWrapper() == null; + boolean targetWrapped = targetOp != null && targetOp.isOutputWrapperStyle() && targetOp.getOutputWrapper() != null; + boolean targetBare = targetOp != null && !targetOp.isOutputWrapperStyle() && targetOp.getOutputWrapper() == null; WrapperHandler targetWrapperHandler = null; String targetDataBinding = getDataBinding(targetOp); @@ -172,18 +172,18 @@ public class Output2OutputTransformer extends BaseTransformer im if ((!sourceWrapped &&!sourceBare) && targetWrapped) { // Unwrapped --> Wrapped - WrapperInfo wrapper = targetOp.getWrapper(); - ElementInfo wrapperElement = wrapper.getOutputWrapperElement(); - List childElements = wrapper.getOutputChildElements(); - Class targetWrapperClass = wrapper != null ? wrapper.getOutputWrapperClass() : null; + WrapperInfo wrapper = targetOp.getOutputWrapper(); + ElementInfo wrapperElement = wrapper.getWrapperElement(); + List childElements = wrapper.getChildElements(); + Class targetWrapperClass = wrapper != null ? wrapper.getWrapperClass() : null; // 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); @@ -217,23 +217,23 @@ public class Output2OutputTransformer extends BaseTransformer im } else if (sourceWrapped && (!targetWrapped && !targetBare)) { // Wrapped to Unwrapped Object sourceWrapper = response; - List childElements = sourceOp.getWrapper().getOutputChildElements(); + List 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(), targetWrapperType, context .getMetadata()); @@ -242,7 +242,7 @@ public class Output2OutputTransformer extends BaseTransformer im } } Object child = sourceWrapperHandler.getChildren(sourceWrapper, sourceOp, false).get(0); - DataType childType = sourceOp.getWrapper().getUnwrappedOutputType(); + DataType childType = sourceOp.getOutputWrapper().getUnwrappedOutputType(); return mediator.mediate(child, childType, targetType.getLogical(), context.getMetadata()); } else { // FIXME: Do we want to handle wrapped to wrapped? diff --git a/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java b/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java index b41c7fb012..4e67c4dee0 100644 --- a/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java +++ b/branches/sca-java-1.x/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java @@ -85,7 +85,11 @@ public class DataBindingRuntimeWireProcessor implements RuntimeWireProcessor { return false; } - if (source.isWrapperStyle() != target.isWrapperStyle()) { + if (source.isInputWrapperStyle() != target.isInputWrapperStyle()) { + return true; + } + + if (source.isOutputWrapperStyle() != target.isOutputWrapperStyle()) { return true; } -- cgit v1.2.3