summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2012-01-09 10:35:27 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2012-01-09 10:35:27 +0000
commit2729709882692f467eb7efd67da251627e18cdc9 (patch)
tree8748b9cce79a6f2592b5c64d0d7cf7fd3bcef757 /sca-java-2.x/trunk/modules
parent485441f2635effb8655d7d00d7f6896bfab996cb (diff)
TUSCANY-3910, TUSCANY-3804 - Set ranking so that JAXWSInterfaceProcessor runs before WrapperJavaInterfaceProcess and apply 3804 style changes to ensure the output wrapper databinding is set separately from the output wrapper.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1229088 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules')
-rw-r--r--sca-java-2.x/trunk/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/WrapperJavaInterfaceProcessor.java73
-rw-r--r--sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java9
-rw-r--r--sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor2
3 files changed, 68 insertions, 16 deletions
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 d152c0dc0a..7bae80d2c4 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
@@ -25,6 +25,7 @@ import java.util.List;
import java.util.Set;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+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;
@@ -60,24 +61,41 @@ public class WrapperJavaInterfaceProcessor implements JavaInterfaceVisitor {
if (inputWrapperInfo == null || outputWrapperInfo == null) {
continue;
}
- // JIRA: TUSCANY-842
+ // TUSCANY-824
+ // TUSCANY-3804 - modify the existing code to set up the input wrapper
String db = inputWrapperInfo.getDataBinding();
if (db == null || JAXB_DATABINDING.equals(db)) {
- db = assignOperationDataBinding(operation);
+ db = assignInputDataBinding(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));
}
if (dbObj != null && handler == null) {
// To avoid JAXB wrapper bean generation
inputWrapperInfo.setWrapperType(null);
- 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);
+ }
}
}
@@ -88,15 +106,46 @@ public class WrapperJavaInterfaceProcessor implements JavaInterfaceVisitor {
*
* The method logic assumes the JavaBeans DataBinding is the default
*/
- private String assignOperationDataBinding(Operation operation) {
+ private String assignInputDataBinding(Operation operation) {
Set<String> dbs = new HashSet<String>();
+ List<DataType> opDataTypes = new LinkedList<DataType>();
- // Can't use DataType<?> since operation.getInputType() returns: DataType<List<DataType>>
+ opDataTypes.addAll(operation.getInputType().getLogical());
+
+ for (DataType<?> d : opDataTypes) {
+ if (d != null) {
+ String dataBinding = d.getDataBinding();
+ if ("java:array".equals(dataBinding)) {
+ dataBinding = ((DataType)d.getLogical()).getDataBinding();
+ }
+ if (dataBinding != null) {
+ dbs.add(dataBinding);
+ }
+ }
+ }
+
+ dbs.remove(JavaBeansDataBinding.NAME);
+ dbs.remove(SimpleJavaDataBinding.NAME);
+
+ if (dbs.size() == 1) {
+ String db = dbs.iterator().next();
+ operation.getInputWrapper().setDataBinding(db);
+ return db;
+ } else {
+ return operation.getInputWrapper().getDataBinding();
+ }
+ }
+
+ // TUSCANY-3804: handle output wrapper separately
+ // change here is different to that in 3804
+ // to deal with logical data type + faults
+ private String assignOutputDataBinding(Operation operation) {
+ Set<String> dbs = new HashSet<String>();
List<DataType> opDataTypes = new LinkedList<DataType>();
- opDataTypes.addAll(operation.getInputType().getLogical());
opDataTypes.addAll(operation.getOutputType().getLogical());
+
for (DataType<DataType> ft : operation.getFaultTypes()) {
opDataTypes.add(ft.getLogical());
}
@@ -118,10 +167,10 @@ public class WrapperJavaInterfaceProcessor implements JavaInterfaceVisitor {
if (dbs.size() == 1) {
String db = dbs.iterator().next();
- operation.getInputWrapper().setDataBinding(db);
+ operation.getOutputWrapper().setDataBinding(db);
return db;
} else {
- return operation.getInputWrapper().getDataBinding();
- }
- }
+ return operation.getOutputWrapper().getDataBinding();
+ }
+ }
}
diff --git a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java
index 223f879570..15cac415ac 100644
--- a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java
+++ b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java
@@ -338,9 +338,12 @@ public class JAXWSJavaInterfaceProcessor implements JavaInterfaceVisitor {
}
}
- String db = inputWrapperDT != null ? inputWrapperDT.getDataBinding() : JAXB_DATABINDING;
- WrapperInfo inputWrapperInfo = new WrapperInfo(db, new ElementInfo(inputWrapper, null), inputElements);
- WrapperInfo outputWrapperInfo = new WrapperInfo(db, new ElementInfo(outputWrapper, null), outputElements);
+ // 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(dbIn, new ElementInfo(inputWrapper, null), inputElements);
+ WrapperInfo outputWrapperInfo = new WrapperInfo(dbOut, new ElementInfo(outputWrapper, null), outputElements);
inputWrapperInfo.setWrapperType(inputWrapperDT);
outputWrapperInfo.setWrapperType(outputWrapperDT);
diff --git a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor
index 05b1ccea9b..ff9887366a 100644
--- a/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor
+++ b/sca-java-2.x/trunk/modules/interface-java-jaxws/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor
@@ -18,6 +18,6 @@
# first one, set remotable flag
org.apache.tuscany.sca.interfacedef.java.jaxws.WebServiceInterfaceProcessor;ranking=400
# second one, introspect the JAXWS annotations
-org.apache.tuscany.sca.interfacedef.java.jaxws.JAXWSJavaInterfaceProcessor;ranking=100
+org.apache.tuscany.sca.interfacedef.java.jaxws.JAXWSJavaInterfaceProcessor;ranking=300
# third one, introspect JAXWS async methods
org.apache.tuscany.sca.interfacedef.java.jaxws.JAXWSAsyncInterfaceProcessor;ranking=50