From 110d33c76236d8f2c81f00945dd877870e898758 Mon Sep 17 00:00:00 2001 From: nash Date: Thu, 2 Dec 2010 13:03:23 +0000 Subject: TUSCANY-3804: Handle input and output wrappers separately git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1041359 13f79535-47bb-0310-9956-ffa450edef68 --- .../processor/WrapperJavaInterfaceProcessor.java | 49 ++++++++++++++++++++-- .../java/jaxws/JAXWSJavaInterfaceProcessor.java | 8 ++-- 2 files changed, 50 insertions(+), 7 deletions(-) (limited to 'sca-java-1.x') diff --git a/sca-java-1.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/WrapperJavaInterfaceProcessor.java b/sca-java-1.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/WrapperJavaInterfaceProcessor.java index 702da720a0..9d5c3d65b1 100644 --- a/sca-java-1.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/WrapperJavaInterfaceProcessor.java +++ b/sca-java-1.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/WrapperJavaInterfaceProcessor.java @@ -24,6 +24,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Set; +import org.apache.tuscany.sca.databinding.DataBinding; import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint; import org.apache.tuscany.sca.databinding.WrapperHandler; import org.apache.tuscany.sca.databinding.javabeans.JavaBeansDataBinding; @@ -59,22 +60,41 @@ public class WrapperJavaInterfaceProcessor implements JavaInterfaceVisitor { if (inputWrapperInfo == null || outputWrapperInfo == null) { continue; } - // JIRA: TUSCANY-842 + // JIRA: TUSCANY-824 String db = inputWrapperInfo.getDataBinding(); if (db == null || JAXB_DATABINDING.equals(db)) { db = assignOperationDataBinding(operation); } // Introspect the wrapper data type - org.apache.tuscany.sca.databinding.DataBinding dbObj = dataBindingRegistry.getDataBinding(db); + DataBinding dbObj = dataBindingRegistry.getDataBinding(db); WrapperHandler handler = dbObj == null ? null : dbObj.getWrapperHandler(); if (handler != null) { inputWrapperInfo.setWrapperType(handler.getWrapperType(operation, true)); - outputWrapperInfo.setWrapperType(handler.getWrapperType(operation, false)); + // TUSCANY-3804: handle output wrapper separately + //outputWrapperInfo.setWrapperType(handler.getWrapperType(operation, false)); } if (dbObj != null && handler == null) { // To avoid JAXB wrapper bean generation inputWrapperInfo.setWrapperType(null); + // TUSCANY-3804: handle output wrapper separately + //outputWrapperInfo.setWrapperType(null); + } + + // TUSCANY-3804: handle output wrapper separately + db = outputWrapperInfo.getDataBinding(); + if (db == null || JAXB_DATABINDING.equals(db)) { + db = assignOutputDataBinding(operation); + } + + // Introspect the wrapper data type + dbObj = dataBindingRegistry.getDataBinding(db); + handler = dbObj == null ? null : dbObj.getWrapperHandler(); + if (handler != null) { + outputWrapperInfo.setWrapperType(handler.getWrapperType(operation, false)); + } + if (dbObj != null && handler == null) { + // To avoid JAXB wrapper bean generation outputWrapperInfo.setWrapperType(null); } } @@ -95,7 +115,8 @@ public class WrapperJavaInterfaceProcessor implements JavaInterfaceVisitor { List opDataTypes = new LinkedList(); opDataTypes.addAll(operation.getInputType().getLogical()); - opDataTypes.add(operation.getOutputType()); + // TUSCANY-3804: handle output wrapper separately + //opDataTypes.add(operation.getOutputType()); /* for (DataType ft : operation.getFaultTypes()) { opDataTypes.add(ft.getLogical()); @@ -125,4 +146,24 @@ public class WrapperJavaInterfaceProcessor implements JavaInterfaceVisitor { return operation.getInputWrapper().getDataBinding(); } } + + // TUSCANY-3804: handle output wrapper separately + private String assignOutputDataBinding(Operation operation) { + String db = null; + DataType dt = operation.getOutputType(); + if (dt != null) { + db = dt.getDataBinding(); + if ("java:array".equals(db)) { + db = ((DataType)dt.getLogical()).getDataBinding(); + } + } + if (db != null && + !JavaBeansDataBinding.NAME.equals(db) && + !SimpleJavaDataBinding.NAME.equals(db)) { + operation.getOutputWrapper().setDataBinding(db); + return db; + } else { + return operation.getOutputWrapper().getDataBinding(); + } + } } diff --git a/sca-java-1.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java b/sca-java-1.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java index 27cd163d13..27324be42e 100644 --- a/sca-java-1.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java +++ b/sca-java-1.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java @@ -331,11 +331,13 @@ public class JAXWSJavaInterfaceProcessor implements JavaInterfaceVisitor { outputElements.add(new ElementInfo(element, new TypeInfo(type, false, null))); } - String db = inputWrapperDT != null ? inputWrapperDT.getDataBinding() : JAXB_DATABINDING; + // TUSCANY-3804: handle output wrapper separately + String dbIn = inputWrapperDT != null ? inputWrapperDT.getDataBinding() : JAXB_DATABINDING; + String dbOut = outputWrapperDT != null ? outputWrapperDT.getDataBinding() : JAXB_DATABINDING; - WrapperInfo inputWrapperInfo = new WrapperInfo(db, new ElementInfo(inputWrapper, null), inputElements); + WrapperInfo inputWrapperInfo = new WrapperInfo(dbIn, new ElementInfo(inputWrapper, null), inputElements); WrapperInfo outputWrapperInfo = - new WrapperInfo(db, new ElementInfo(outputWrapper, null), outputElements); + new WrapperInfo(dbOut, new ElementInfo(outputWrapper, null), outputElements); inputWrapperInfo.setWrapperType(inputWrapperDT); outputWrapperInfo.setWrapperType(outputWrapperDT); -- cgit v1.2.3