diff options
Diffstat (limited to '')
44 files changed, 776 insertions, 438 deletions
diff --git a/branches/sca-java-1.x/modules/assembly-xsd/src/main/resources/sca-binding-jms.xsd b/branches/sca-java-1.x/modules/assembly-xsd/src/main/resources/sca-binding-jms.xsd index b315ca0ad1..faaa7640ee 100644 --- a/branches/sca-java-1.x/modules/assembly-xsd/src/main/resources/sca-binding-jms.xsd +++ b/branches/sca-java-1.x/modules/assembly-xsd/src/main/resources/sca-binding-jms.xsd @@ -98,6 +98,8 @@ <element name="connectionFactory" type="sca:ConnectionFactory" minOccurs="0"/> <element name="activationSpec" type="sca:ActivationSpec" minOccurs="0"/> + <any namespace="##other" processContents="lax" + minOccurs="0" maxOccurs="unbounded"/> </sequence> </complexType> diff --git a/branches/sca-java-1.x/modules/assembly-xsd/src/main/resources/tuscany-sca-binding-jms.xsd b/branches/sca-java-1.x/modules/assembly-xsd/src/main/resources/tuscany-sca-binding-jms.xsd index b998427ecb..7ecf58df30 100644 --- a/branches/sca-java-1.x/modules/assembly-xsd/src/main/resources/tuscany-sca-binding-jms.xsd +++ b/branches/sca-java-1.x/modules/assembly-xsd/src/main/resources/tuscany-sca-binding-jms.xsd @@ -24,7 +24,10 @@ elementFormDefault="qualified"> <import namespace="http://www.osoa.org/xmlns/sca/1.0" schemaLocation="sca-binding-jms.xsd"/> - + + <complexType name="WireFormatJMSDefaultType"/> + <element name="wireFormat.jmsDefault" type="t:WireFormatJMSDefaultType"/> + <complexType name="WireFormatJMSTextXMLType"/> <element name="wireFormat.jmsTextXML" type="t:WireFormatJMSTextXMLType"/> diff --git a/branches/sca-java-1.x/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterface.java b/branches/sca-java-1.x/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterface.java index 2c5a0d8159..296fa0a454 100644 --- a/branches/sca-java-1.x/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterface.java +++ b/branches/sca-java-1.x/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestInterface.java @@ -23,6 +23,7 @@ import java.util.List; import javax.xml.namespace.QName; +import org.apache.tuscany.sca.interfacedef.Interface; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.interfacedef.java.JavaInterface; import org.apache.tuscany.sca.policy.Intent; @@ -61,6 +62,14 @@ public class TestInterface implements JavaInterface { public void resetDataBinding(String dataBinding) { } + + public void resetInterfaceInputTypes(Interface newInterface) { + + } + + public void resetInterfaceOutputTypes(Interface newInterface) { + + } public void setConversational(boolean conversational) { diff --git a/branches/sca-java-1.x/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestOperation.java b/branches/sca-java-1.x/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestOperation.java index 90551ec25d..58b161d587 100644 --- a/branches/sca-java-1.x/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestOperation.java +++ b/branches/sca-java-1.x/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/service/mocks/TestOperation.java @@ -75,7 +75,11 @@ public class TestOperation implements Operation { return outputType; } - public WrapperInfo getWrapper() { + public WrapperInfo getInputWrapper() { + return null; + } + + public WrapperInfo getOutputWrapper() { return null; } @@ -91,7 +95,11 @@ public class TestOperation implements Operation { return false; } - public boolean isWrapperStyle() { + public boolean isInputWrapperStyle() { + return false; + } + + public boolean isOutputWrapperStyle() { return false; } @@ -139,11 +147,19 @@ public class TestOperation implements Operation { } - public void setWrapper(WrapperInfo wrapperInfo) { + public void setInputWrapper(WrapperInfo wrapperInfo) { } + + public void setOutputWrapper(WrapperInfo wrapperInfo) { - public void setWrapperStyle(boolean wrapperStyle) { + } + + public void setInputWrapperStyle(boolean wrapperStyle) { + + } + + public void setOutputWrapperStyle(boolean wrapperStyle) { } diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java index f785a8fdb9..0e44b84ea0 100644 --- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java +++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java @@ -52,7 +52,6 @@ public class JMSBindingReferenceBindingProvider implements ReferenceBindingProvi private RuntimeComponentReference reference; private JMSBinding jmsBinding; - private List<JMSBindingInvoker> jmsBindingInvokers = new ArrayList<JMSBindingInvoker>(); private JMSResourceFactory jmsResourceFactory; private RuntimeComponent component; private InterfaceContract interfaceContract; @@ -87,7 +86,18 @@ public class JMSBindingReferenceBindingProvider implements ReferenceBindingProvi (WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getResponseWireFormat().getClass()); if (this.responseWireFormatProviderFactory != null){ this.responseWireFormatProvider = responseWireFormatProviderFactory.createReferenceWireFormatProvider(component, reference, jmsBinding); - } + } + + // create an interface contract that reflects both request and response + // wire formats + try { + interfaceContract = (InterfaceContract)reference.getInterfaceContract().clone(); + + requestWireFormatProvider.configureWireFormatInterfaceContract(interfaceContract); + responseWireFormatProvider.configureWireFormatInterfaceContract(interfaceContract); + } catch (CloneNotSupportedException ex){ + interfaceContract = reference.getInterfaceContract(); + } } public Invoker createInvoker(Operation operation) { @@ -109,9 +119,6 @@ public class JMSBindingReferenceBindingProvider implements ReferenceBindingProvi } public InterfaceContract getBindingInterfaceContract() { - if (interfaceContract == null){ - interfaceContract = this.requestWireFormatProvider.getWireFormatInterfaceContract(); - } return interfaceContract; } diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java index 106d0b37cf..4a86a92b0e 100644 --- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java +++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java @@ -59,12 +59,9 @@ public class JMSBindingServiceBindingProvider implements ServiceBindingProviderR private JMSServiceListenerFactory serviceListenerFactory; private JMSServiceListener serviceListener; - private ExtensionPointRegistry extensionPoints; - private RuntimeComponent component; - private InterfaceContract wsdlInterfaceContract; + private InterfaceContract interfaceContract; - private ProviderFactoryExtensionPoint providerFactories; private ModelFactoryExtensionPoint modelFactories; @@ -85,7 +82,6 @@ public class JMSBindingServiceBindingProvider implements ServiceBindingProviderR this.jmsBinding = binding; this.serviceListenerFactory = serviceListenerFactory; this.targetBinding = targetBinding; - this.extensionPoints = extensionPoints; this.jmsResourceFactory = jmsResourceFactory; // Set the default destination when using a connection factory. @@ -123,10 +119,21 @@ public class JMSBindingServiceBindingProvider implements ServiceBindingProviderR if (this.responseWireFormatProviderFactory != null){ this.responseWireFormatProvider = responseWireFormatProviderFactory.createServiceWireFormatProvider(component, service, jmsBinding); } + + // create an interface contract that reflects both request and response + // wire formats + try { + interfaceContract = (InterfaceContract)service.getInterfaceContract().clone(); + + requestWireFormatProvider.configureWireFormatInterfaceContract(interfaceContract); + responseWireFormatProvider.configureWireFormatInterfaceContract(interfaceContract); + } catch (CloneNotSupportedException ex){ + interfaceContract = service.getInterfaceContract(); + } } public InterfaceContract getBindingInterfaceContract() { - return requestWireFormatProvider.getWireFormatInterfaceContract(); + return interfaceContract; } public boolean supportsOneWayInvocation() { diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.java index 00aa060ce7..de5a83bfdb 100644 --- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.java +++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.java @@ -19,27 +19,14 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.runtime; -import java.util.List; - -import org.apache.axiom.om.OMElement; import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; -import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil; -import org.apache.tuscany.sca.binding.jms.provider.XMLTextMessageProcessor; -import org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.WireFormatJMSTextXML; -import org.apache.tuscany.sca.binding.ws.WebServiceBinding; -import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory; -import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator; +import org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.WireFormatJMSBytes; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.apache.tuscany.sca.policy.util.PolicyHandler; -import org.apache.tuscany.sca.provider.PolicyProvider; import org.apache.tuscany.sca.provider.WireFormatProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; @@ -69,8 +56,12 @@ public class WireFormatJMSBytesReferenceProvider implements WireFormatProvider { // currently maintaining the message processor structure which // contains the details of jms message processing however overried // any message processors specied in the SCDL in this case - this.binding.setRequestMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME); - this.binding.setResponseMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME); + if (this.binding.getRequestWireFormat() instanceof WireFormatJMSBytes){ + this.binding.setRequestMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME); + } + if (this.binding.getResponseWireFormat() instanceof WireFormatJMSBytes){ + this.binding.setResponseMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME); + } // just point to the reference interface contract so no // databinding transformation takes place @@ -80,6 +71,22 @@ public class WireFormatJMSBytesReferenceProvider implements WireFormatProvider { public InterfaceContract getWireFormatInterfaceContract() { return interfaceContract; } + + public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ + + if (this.interfaceContract != null ) { + if (this.binding.getRequestWireFormat() instanceof WireFormatJMSBytes){ + // set the request data transformation + interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface()); + } + if (this.binding.getResponseWireFormat() instanceof WireFormatJMSBytes){ + // set the response data transformation + interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface()); + } + } + + return interfaceContract; + } public Interceptor createInterceptor() { return new WireFormatJMSBytesReferenceInterceptor(binding, diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.java index 8cf1bc7e4d..2fcb9ef118 100644 --- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.java +++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.java @@ -19,20 +19,14 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.runtime; -import java.util.List; - import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; +import org.apache.tuscany.sca.binding.jms.wireformat.jmsbytes.WireFormatJMSBytes; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.apache.tuscany.sca.policy.util.PolicyHandler; -import org.apache.tuscany.sca.provider.PolicyProvider; import org.apache.tuscany.sca.provider.WireFormatProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentService; @@ -60,10 +54,14 @@ public class WireFormatJMSBytesServiceProvider implements WireFormatProvider { // configure the service based on this wire format // currently maintaining the message processor structure which - // contains the details of jms message processing however overried - // any message processors specied in the SCDL in this case - this.binding.setRequestMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME); - this.binding.setResponseMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME); + // contains the details of jms message processing however override + // any message processors specified in the SCDL in this case + if (this.binding.getRequestWireFormat() instanceof WireFormatJMSBytes){ + this.binding.setRequestMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME); + } + if (this.binding.getResponseWireFormat() instanceof WireFormatJMSBytes){ + this.binding.setResponseMessageProcessorName(JMSBindingConstants.BYTES_MP_CLASSNAME); + } // just point to the reference interface contract so no // databinding transformation takes place @@ -73,6 +71,22 @@ public class WireFormatJMSBytesServiceProvider implements WireFormatProvider { public InterfaceContract getWireFormatInterfaceContract() { return interfaceContract; } + + public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ + + if (this.interfaceContract != null ) { + if (this.binding.getRequestWireFormat() instanceof WireFormatJMSBytes){ + // set the request data transformation + interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface()); + } + if (this.binding.getResponseWireFormat() instanceof WireFormatJMSBytes){ + // set the response data transformation + interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface()); + } + } + + return interfaceContract; + } /** */ diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java index 42719e842f..e566764ce4 100644 --- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java +++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java @@ -19,27 +19,14 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.runtime; -import java.util.List; - -import org.apache.axiom.om.OMElement; import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; -import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil; -import org.apache.tuscany.sca.binding.jms.provider.XMLTextMessageProcessor; -import org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.WireFormatJMSTextXML; -import org.apache.tuscany.sca.binding.ws.WebServiceBinding; -import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory; -import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator; +import org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.WireFormatJMSObject; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.apache.tuscany.sca.policy.util.PolicyHandler; -import org.apache.tuscany.sca.provider.PolicyProvider; import org.apache.tuscany.sca.provider.WireFormatProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; @@ -67,10 +54,14 @@ public class WireFormatJMSObjectReferenceProvider implements WireFormatProvider // configure the reference based on this wire format // currently maintaining the message processor structure which - // contains the details of jms message processing however overried - // any message processors specied in the SCDL in this case - this.binding.setRequestMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME); - this.binding.setResponseMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME); + // contains the details of jms message processing however override + // any message processors specified in the SCDL in this case + if (this.binding.getRequestWireFormat() instanceof WireFormatJMSObject){ + this.binding.setRequestMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME); + } + if (this.binding.getResponseWireFormat() instanceof WireFormatJMSObject){ + this.binding.setResponseMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME); + } // just point to the reference interface contract so no // databinding transformation takes place @@ -80,6 +71,22 @@ public class WireFormatJMSObjectReferenceProvider implements WireFormatProvider public InterfaceContract getWireFormatInterfaceContract() { return interfaceContract; } + + public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ + + if (this.interfaceContract != null ) { + if (this.binding.getRequestWireFormat() instanceof WireFormatJMSObject){ + // set the request data transformation + interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface()); + } + if (this.binding.getResponseWireFormat() instanceof WireFormatJMSObject){ + // set the response data transformation + interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface()); + } + } + + return interfaceContract; + } public Interceptor createInterceptor() { return new WireFormatJMSObjectReferenceInterceptor(binding, diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java index 9b1b405fac..4f4d4b4bb5 100644 --- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java +++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java @@ -19,20 +19,15 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.runtime; -import java.util.List; import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; +import org.apache.tuscany.sca.binding.jms.wireformat.jmsobject.WireFormatJMSObject; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.apache.tuscany.sca.policy.util.PolicyHandler; -import org.apache.tuscany.sca.provider.PolicyProvider; import org.apache.tuscany.sca.provider.WireFormatProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentService; @@ -60,10 +55,14 @@ public class WireFormatJMSObjectServiceProvider implements WireFormatProvider { // configure the service based on this wire format // currently maintaining the message processor structure which - // contains the details of jms message processing however overried - // any message processors specied in the SCDL in this case - this.binding.setRequestMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME); - this.binding.setResponseMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME); + // contains the details of jms message processing however override + // any message processors specified in the SCDL in this case + if (this.binding.getRequestWireFormat() instanceof WireFormatJMSObject){ + this.binding.setRequestMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME); + } + if (this.binding.getResponseWireFormat() instanceof WireFormatJMSObject){ + this.binding.setResponseMessageProcessorName(JMSBindingConstants.OBJECT_MP_CLASSNAME); + } // just point to the reference interface contract so no // databinding transformation takes place @@ -73,6 +72,22 @@ public class WireFormatJMSObjectServiceProvider implements WireFormatProvider { public InterfaceContract getWireFormatInterfaceContract() { return interfaceContract; } + + public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ + + if (this.interfaceContract != null ) { + if (this.binding.getRequestWireFormat() instanceof WireFormatJMSObject){ + // set the request data transformation + interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface()); + } + if (this.binding.getResponseWireFormat() instanceof WireFormatJMSObject){ + // set the response data transformation + interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface()); + } + } + + return interfaceContract; + } /** */ diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.java index f7d125dd3e..c2030f9d4c 100644 --- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.java +++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.java @@ -19,27 +19,15 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmstext.runtime; -import java.util.List; -import org.apache.axiom.om.OMElement; import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; -import org.apache.tuscany.sca.binding.jms.provider.JMSMessageProcessorUtil; -import org.apache.tuscany.sca.binding.jms.provider.XMLTextMessageProcessor; -import org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.WireFormatJMSTextXML; -import org.apache.tuscany.sca.binding.ws.WebServiceBinding; -import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory; -import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator; +import org.apache.tuscany.sca.binding.jms.wireformat.jmstext.WireFormatJMSText; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.apache.tuscany.sca.policy.util.PolicyHandler; -import org.apache.tuscany.sca.provider.PolicyProvider; import org.apache.tuscany.sca.provider.WireFormatProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; @@ -67,10 +55,14 @@ public class WireFormatJMSTextReferenceProvider implements WireFormatProvider { // configure the reference based on this wire format // currently maintaining the message processor structure which - // contains the details of jms message processing however overried - // any message processors specied in the SCDL in this case - this.binding.setRequestMessageProcessorName(JMSBindingConstants.TEXT_MP_CLASSNAME); - this.binding.setResponseMessageProcessorName(JMSBindingConstants.TEXT_MP_CLASSNAME); + // contains the details of jms message processing however override + // any message processors specified in the SCDL in this case + if (this.binding.getRequestWireFormat() instanceof WireFormatJMSText){ + this.binding.setRequestMessageProcessorName(JMSBindingConstants.TEXT_MP_CLASSNAME); + } + if (this.binding.getResponseWireFormat() instanceof WireFormatJMSText){ + this.binding.setResponseMessageProcessorName(JMSBindingConstants.TEXT_MP_CLASSNAME); + } // just point to the reference interface contract so no @@ -81,6 +73,22 @@ public class WireFormatJMSTextReferenceProvider implements WireFormatProvider { public InterfaceContract getWireFormatInterfaceContract() { return interfaceContract; } + + public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ + + if (this.interfaceContract != null ) { + if (this.binding.getRequestWireFormat() instanceof WireFormatJMSText){ + // set the request data transformation + interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface()); + } + if (this.binding.getResponseWireFormat() instanceof WireFormatJMSText){ + // set the response data transformation + interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface()); + } + } + + return interfaceContract; + } public Interceptor createInterceptor() { return new WireFormatJMSTextReferenceInterceptor(binding, diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.java index f8fff8e981..d9ec72007a 100644 --- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.java +++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.java @@ -19,20 +19,14 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmstext.runtime; -import java.util.List; - import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; +import org.apache.tuscany.sca.binding.jms.wireformat.jmstext.WireFormatJMSText; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.apache.tuscany.sca.policy.util.PolicyHandler; -import org.apache.tuscany.sca.provider.PolicyProvider; import org.apache.tuscany.sca.provider.WireFormatProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentService; @@ -60,10 +54,14 @@ public class WireFormatJMSTextServiceProvider implements WireFormatProvider { // configure the service based on this wire format // currently maintaining the message processor structure which - // contains the details of jms message processing however overried - // any message processors specied in the SCDL in this case - this.binding.setRequestMessageProcessorName(JMSBindingConstants.TEXT_MP_CLASSNAME); - this.binding.setResponseMessageProcessorName(JMSBindingConstants.TEXT_MP_CLASSNAME); + // contains the details of jms message processing however override + // any message processors specified in the SCDL in this case + if (this.binding.getRequestWireFormat() instanceof WireFormatJMSText){ + this.binding.setRequestMessageProcessorName(JMSBindingConstants.TEXT_MP_CLASSNAME); + } + if (this.binding.getResponseWireFormat() instanceof WireFormatJMSText){ + this.binding.setResponseMessageProcessorName(JMSBindingConstants.TEXT_MP_CLASSNAME); + } // just point to the reference interface contract so no // databinding transformation takes place @@ -73,6 +71,22 @@ public class WireFormatJMSTextServiceProvider implements WireFormatProvider { public InterfaceContract getWireFormatInterfaceContract() { return interfaceContract; } + + public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ + + if (this.interfaceContract != null ) { + if (this.binding.getRequestWireFormat() instanceof WireFormatJMSText){ + // set the request data transformation + interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface()); + } + if (this.binding.getResponseWireFormat() instanceof WireFormatJMSText){ + // set the response data transformation + interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface()); + } + } + + return interfaceContract; + } /** */ diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java index 69369cd268..0c383c0579 100644 --- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java +++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java @@ -19,24 +19,18 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.runtime; -import java.util.List; - import org.apache.axiom.om.OMElement; import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; +import org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.WireFormatJMSTextXML; import org.apache.tuscany.sca.binding.ws.WebServiceBinding; import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory; import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.apache.tuscany.sca.policy.util.PolicyHandler; -import org.apache.tuscany.sca.provider.PolicyProvider; import org.apache.tuscany.sca.provider.WireFormatProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; @@ -66,23 +60,27 @@ public class WireFormatJMSTextXMLReferenceProvider implements WireFormatProvider // currently maintaining the message processor structure which // contains the details of jms message processing so set the message // type here if not set explicitly in SCDL - if (this.binding.getRequestMessageProcessorName().equals(JMSBindingConstants.XML_MP_CLASSNAME) ){ + // + // defaults to JMSBindingConstants.XML_MP_CLASSNAME so no need to set it +/* + if (this.binding.getRequestWireFormat() instanceof WireFormatJMSTextXML){ this.binding.setRequestMessageProcessorName(JMSBindingConstants.XML_MP_CLASSNAME); - this.binding.setResponseMessageProcessorName(JMSBindingConstants.XML_MP_CLASSNAME); } - - // set the binding interface contract to represent the WSDL for the - // xml messages that will be sent - if (reference.getInterfaceContract() != null && - !isOnMessage()) { - WebServiceBindingFactory wsFactory = registry.getExtensionPoint(WebServiceBindingFactory.class); - WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); - BindingWSDLGenerator.generateWSDL(component, reference, wsBinding, registry, null); - interfaceContract = wsBinding.getBindingInterfaceContract(); - interfaceContract.getInterface().resetDataBinding(OMElement.class.getName()); - } else { - interfaceContract = reference.getInterfaceContract(); + if (this.binding.getResponseWireFormat() instanceof WireFormatJMSTextXML){ + this.binding.setResponseMessageProcessorName(JMSBindingConstants.XML_MP_CLASSNAME); } +*/ + + // create a local interface contract that is configured specifically to + // deal with the data format that this wire format is expecting to sent to + // and receive from the databinding interceptor. The request/response parts of + // this interface contract will be copied into the binding interface contract + // as required + WebServiceBindingFactory wsFactory = registry.getExtensionPoint(WebServiceBindingFactory.class); + WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); + BindingWSDLGenerator.generateWSDL(component, reference, wsBinding, registry, null); + interfaceContract = wsBinding.getBindingInterfaceContract(); + interfaceContract.getInterface().resetDataBinding(OMElement.class.getName()); } protected boolean isOnMessage() { @@ -97,6 +95,23 @@ public class WireFormatJMSTextXMLReferenceProvider implements WireFormatProvider return interfaceContract; } + public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ + + if (this.interfaceContract != null && + !isOnMessage()) { + if (this.binding.getRequestWireFormat() instanceof WireFormatJMSTextXML){ + // set the request data transformation + interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface()); + } + if (this.binding.getResponseWireFormat() instanceof WireFormatJMSTextXML){ + // set the response data transformation + interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface()); + } + } + + return interfaceContract; + } + public Interceptor createInterceptor() { return new WireFormatJMSTextXMLReferenceInterceptor((JMSBinding)binding, null, diff --git a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java index 2a2332f5fb..95dcbdf189 100644 --- a/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java +++ b/branches/sca-java-1.x/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java @@ -19,25 +19,19 @@ package org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.runtime; -import java.util.List; - import org.apache.axiom.om.OMElement; import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.binding.jms.impl.JMSBinding; import org.apache.tuscany.sca.binding.jms.impl.JMSBindingConstants; import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory; +import org.apache.tuscany.sca.binding.jms.wireformat.jmstextxml.WireFormatJMSTextXML; import org.apache.tuscany.sca.binding.ws.WebServiceBinding; import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory; import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.interfacedef.InterfaceContract; -import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Phase; -import org.apache.tuscany.sca.policy.PolicySet; -import org.apache.tuscany.sca.policy.PolicySetAttachPoint; -import org.apache.tuscany.sca.policy.util.PolicyHandler; -import org.apache.tuscany.sca.provider.PolicyProvider; import org.apache.tuscany.sca.provider.WireFormatProvider; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentService; @@ -69,23 +63,23 @@ public class WireFormatJMSTextXMLServiceProvider implements WireFormatProvider { // currently maintaining the message processor structure which // contains the details of jms message processing so set the message // type here if not set explicitly in SCDL - if (this.binding.getRequestMessageProcessorName().equals(JMSBindingConstants.XML_MP_CLASSNAME) ){ + if (this.binding.getRequestWireFormat() instanceof WireFormatJMSTextXML){ this.binding.setRequestMessageProcessorName(JMSBindingConstants.XML_MP_CLASSNAME); + } + if (this.binding.getResponseWireFormat() instanceof WireFormatJMSTextXML){ this.binding.setResponseMessageProcessorName(JMSBindingConstants.XML_MP_CLASSNAME); } - // set the binding interface contract to represent the WSDL for the - // xml messages that will be sent - if (service.getInterfaceContract() != null && - !isOnMessage()) { - WebServiceBindingFactory wsFactory = registry.getExtensionPoint(WebServiceBindingFactory.class); - WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); - BindingWSDLGenerator.generateWSDL(component, service, wsBinding, registry, null); - interfaceContract = wsBinding.getBindingInterfaceContract(); - interfaceContract.getInterface().resetDataBinding(OMElement.class.getName()); - } else { - interfaceContract = service.getInterfaceContract(); - } + // create a local interface contract that is configured specifically to + // deal with the data format that this wire format is expecting to sent to + // and receive from the databinding interceptor. The request/response parts of + // this interface contract will be copied into the binding interface contract + // as required + WebServiceBindingFactory wsFactory = registry.getExtensionPoint(WebServiceBindingFactory.class); + WebServiceBinding wsBinding = wsFactory.createWebServiceBinding(); + BindingWSDLGenerator.generateWSDL(component, service, wsBinding, registry, null); + interfaceContract = wsBinding.getBindingInterfaceContract(); + interfaceContract.getInterface().resetDataBinding(OMElement.class.getName()); } protected boolean isOnMessage() { @@ -99,7 +93,24 @@ public class WireFormatJMSTextXMLServiceProvider implements WireFormatProvider { public InterfaceContract getWireFormatInterfaceContract() { return interfaceContract; } - + + public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract){ + + if (this.interfaceContract != null && + !isOnMessage()) { + if (this.binding.getRequestWireFormat() instanceof WireFormatJMSTextXML){ + // set the request data transformation + interfaceContract.getInterface().resetInterfaceInputTypes(this.interfaceContract.getInterface()); + } + if (this.binding.getResponseWireFormat() instanceof WireFormatJMSTextXML){ + // set the response data transformation + interfaceContract.getInterface().resetInterfaceOutputTypes(this.interfaceContract.getInterface()); + } + } + + return interfaceContract; + } + public Interceptor createInterceptor() { return new WireFormatJMSTextXMLServiceInterceptor((JMSBinding)binding, jmsResourceFactory, diff --git a/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java b/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java index 34576d2d72..384444800c 100644 --- a/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java +++ b/branches/sca-java-1.x/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/impl/JMSBindingProcessor.java @@ -104,6 +104,8 @@ import org.apache.tuscany.sca.policy.PolicyFactory; * <activationSpec name="xs:anyURI" create="string"?> * <property name="NMTOKEN" type="NMTOKEN">* * </activationSpec>? + * + * <wireFormat.someWireFormat/>? * </response>? * * <complexType name="SubscriptionHeaders"> @@ -124,6 +126,8 @@ import org.apache.tuscany.sca.policy.PolicyFactory; * <property name="NMTOKEN" type="NMTOKEN">* * </headers>? * </operationProperties>* + * + * <wireFormat.someWireFormat/>? * </binding.jms> * * Parsing error messages are recorded locally and reported as validation exceptions. Parsing @@ -474,7 +478,7 @@ public class JMSBindingProcessor extends BaseStAXArtifactProcessor implements St jmsBinding.getResponseActivationSpecProperties().putAll(parseBindingProperties(reader)); } - private void parseResponse(XMLStreamReader reader, JMSBinding jmsBinding) throws XMLStreamException { + private void parseResponse(XMLStreamReader reader, JMSBinding jmsBinding) throws ContributionReadException, XMLStreamException { // Read sub-elements of response while (true) { switch (reader.next()) { @@ -486,6 +490,16 @@ public class JMSBindingProcessor extends BaseStAXArtifactProcessor implements St parseResponseConnectionFactory(reader, jmsBinding); } else if ("activationSpec".equals(elementName)) { parseResponseActivationSpec(reader, jmsBinding); + } else { + Object extension = extensionProcessor.read(reader); + if (extension != null) { + if (extension instanceof WireFormat) { + jmsBinding.setResponseWireFormat((WireFormat)extension); + } else { + error("UnexpectedElement", reader, extension.toString()); + } + } + reader.next(); } //reader.next(); break; diff --git a/branches/sca-java-1.x/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java b/branches/sca-java-1.x/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java index 933534cc79..cbdeec2b4a 100644 --- a/branches/sca-java-1.x/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java +++ b/branches/sca-java-1.x/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java @@ -212,11 +212,11 @@ public class Interface2WSDLGenerator { private Map<XMLTypeHelper, List<DataType>> getDataTypes(Interface intf, boolean useWrapper, Map<String, XMLTypeHelper> helpers) { Map<XMLTypeHelper, List<DataType>> dataTypes = new HashMap<XMLTypeHelper, List<DataType>>(); for (Operation op : intf.getOperations()) { - WrapperInfo wrapper = op.getWrapper(); + WrapperInfo inputWrapper = op.getInputWrapper(); DataType dt1 = null; - boolean useInputWrapper = useWrapper & wrapper != null; + boolean useInputWrapper = useWrapper & inputWrapper != null; if (useInputWrapper) { - dt1 = wrapper.getInputWrapperType(); + dt1 = inputWrapper.getWrapperType(); useInputWrapper &= inputTypesCompatible(dt1, op.getInputType(), helpers); } if (useInputWrapper) { @@ -228,9 +228,10 @@ public class Interface2WSDLGenerator { } DataType dt2 = null; - boolean useOutputWrapper = useWrapper & wrapper != null; + WrapperInfo outputWrapper = op.getOutputWrapper(); + boolean useOutputWrapper = useWrapper & outputWrapper != null; if (useOutputWrapper) { - dt2 = wrapper.getOutputWrapperType(); + dt2 = outputWrapper.getWrapperType(); useOutputWrapper &= outputTypeCompatible(dt2, op.getOutputType(), helpers); } if (useOutputWrapper) { @@ -284,7 +285,7 @@ public class Interface2WSDLGenerator { javax.wsdl.Operation operation = generateOperation(definition, op, helpers, wrappers); portType.addOperation(operation); String action = ((JavaOperation)op).getAction(); - if ((action == null || "".equals(action)) && !op.isWrapperStyle() && op.getWrapper() == null) { + if ((action == null || "".equals(action)) && !op.isInputWrapperStyle() && op.getInputWrapper() == null) { // Bare style action = "urn:" + op.getName(); } @@ -570,7 +571,7 @@ public class Interface2WSDLGenerator { List<ElementInfo> elements = null; // FIXME: By default, java interface is mapped to doc-lit-wrapper style WSDL - if (op.getWrapper() != null) { + if (op.getInputWrapper() != null) { // Generate doc-lit-wrapper style inputMsg.addPart(generateWrapperPart(definition, op, helpers, wrappers, true)); } else { @@ -597,7 +598,7 @@ public class Interface2WSDLGenerator { outputMsg.setUndefined(false); definition.addMessage(outputMsg); - if (op.getWrapper() != null) { + if (op.getOutputWrapper() != null) { outputMsg.addPart(generateWrapperPart(definition, op, helpers, wrappers, false)); } else { DataType outputType = op.getOutputType(); @@ -677,12 +678,13 @@ public class Interface2WSDLGenerator { Part part = definition.createPart(); String partName = input ? operation.getName() : (operation.getName() + "Response"); part.setName(partName); - WrapperInfo opWrapper = operation.getWrapper(); - if (opWrapper != null) { + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + if ((inputWrapperInfo != null) && (outputWrapperInfo != null)) { ElementInfo elementInfo = - input ? opWrapper.getInputWrapperElement() : opWrapper.getOutputWrapperElement(); + input ? inputWrapperInfo.getWrapperElement() : outputWrapperInfo.getWrapperElement(); List<ElementInfo> elements = - input ? opWrapper.getInputChildElements() : opWrapper.getOutputChildElements(); + input ? inputWrapperInfo.getChildElements() : outputWrapperInfo.getChildElements(); QName wrapperName = elementInfo.getQName(); part.setElementName(wrapperName); addNamespace(definition, wrapperName); 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<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; } @@ -133,8 +133,8 @@ 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 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<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 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<Object[], Object[]> 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<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 @@ -221,10 +221,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()); @@ -236,7 +236,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().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<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/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<Object, Object> 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<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; } @@ -154,8 +154,8 @@ public class Output2OutputTransformer extends BaseTransformer<Object, Object> im try { DataType<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<Object, Object> im DataType<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<Object, Object> im if ((!sourceWrapped &&!sourceBare) && 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; // 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<Object, Object> im } else if (sourceWrapped && (!targetWrapped && !targetBare)) { // 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(), targetWrapperType, context .getMetadata()); @@ -242,7 +242,7 @@ public class Output2OutputTransformer extends BaseTransformer<Object, Object> 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; } diff --git a/branches/sca-java-1.x/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java b/branches/sca-java-1.x/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java index db38945fc1..8f15d001d2 100644 --- a/branches/sca-java-1.x/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java +++ b/branches/sca-java-1.x/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java @@ -27,10 +27,10 @@ import org.apache.tuscany.sca.invocation.Interceptor; */ public interface WireFormatProvider { - /* + /** * Return the contract that describes the interface that * is providing data to or accepting data from the - * wire format interceptor. The wire formats job + * wire format interceptor. The wire format's job * is to translate between this interface contract and the * format on the wire * @return the wire format interface contract @@ -38,6 +38,19 @@ public interface WireFormatProvider { public InterfaceContract getWireFormatInterfaceContract(); /** + * Set up the contract that describes the interface that + * is providing data to or accepting data from the + * wire format interceptor. The wire format's job + * is to translate between this interface contract and the + * format on the wire. The interface contract may be + * configured separately for request and response + * wire formats + * + * @return the wire format interface contract + */ + public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract); + + /** * Create an interceptor for the wire format * @return An interceptor that realize the policySet */ diff --git a/branches/sca-java-1.x/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java b/branches/sca-java-1.x/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java index 219c964c73..a084a666c2 100644 --- a/branches/sca-java-1.x/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java +++ b/branches/sca-java-1.x/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/JDKInvocationHandler.java @@ -234,8 +234,8 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable { Class<?>[] params = method.getParameterTypes(); DataType<List<DataType>> inputType = null; - if (operation.isWrapperStyle()) { - inputType = operation.getWrapper().getUnwrappedInputType(); + if (operation.isInputWrapperStyle()) { + inputType = operation.getInputWrapper().getUnwrappedInputType(); } else { inputType = operation.getInputType(); } diff --git a/branches/sca-java-1.x/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java b/branches/sca-java-1.x/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java index 9084f09dc0..be8d1a2ead 100644 --- a/branches/sca-java-1.x/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java +++ b/branches/sca-java-1.x/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java @@ -55,16 +55,23 @@ public class OMElementWrapperHandler implements WrapperHandler<OMElement> { } public OMElement create(Operation operation, boolean input) { - WrapperInfo wrapperInfo = operation.getWrapper(); - ElementInfo element = input ? wrapperInfo.getInputWrapperElement() : wrapperInfo.getOutputWrapperElement(); - // Class<?> wrapperClass = input ? wrapperInfo.getInputWrapperClass() : wrapperInfo.getOutputWrapperClass(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + ElementInfo element = input ? inputWrapperInfo.getWrapperElement() : + outputWrapperInfo.getWrapperElement(); + OMElement wrapper = AxiomHelper.createOMElement(factory, element.getQName()); return wrapper; } public void setChildren(OMElement wrapper, Object[] childObjects, Operation operation, boolean input) { - List<ElementInfo> childElements = - input ? operation.getWrapper().getInputChildElements() : operation.getWrapper().getOutputChildElements(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + List<ElementInfo> childElements = input? inputWrapperInfo.getChildElements(): + outputWrapperInfo.getChildElements(); + for (int i = 0; i < childElements.size(); i++) { setChild(wrapper, i, childElements.get(i), childObjects[i]); } @@ -102,8 +109,11 @@ public class OMElementWrapperHandler implements WrapperHandler<OMElement> { } public List getChildren(OMElement wrapper, Operation operation, boolean input) { - List<ElementInfo> childElements = input? operation.getWrapper().getInputChildElements(): - operation.getWrapper().getOutputChildElements(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + List<ElementInfo> childElements = input? inputWrapperInfo.getChildElements(): + outputWrapperInfo.getChildElements(); List<Object> elements = new ArrayList<Object>(); int i = 0; @@ -118,18 +128,24 @@ public class OMElementWrapperHandler implements WrapperHandler<OMElement> { * @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<XMLType> wrapperType = new DataTypeImpl<XMLType>(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(); - // List<ElementInfo> childElements = - // input ? wrapperInfo.getInputChildElements() : wrapperInfo.getOutputChildElements(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + ElementInfo element = input ? inputWrapperInfo.getWrapperElement() : + outputWrapperInfo.getWrapperElement(); + OMElement wrapper = (OMElement)wrapperObj; if (!element.getQName().equals(wrapper.getQName())) { return false; diff --git a/branches/sca-java-1.x/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java b/branches/sca-java-1.x/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java index ac544862e0..2e8a4fc385 100644 --- a/branches/sca-java-1.x/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java +++ b/branches/sca-java-1.x/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java @@ -302,13 +302,17 @@ public class JAXBContextHelper { } private static void getDataTypes(List<DataType> dataTypes, Operation op, boolean useWrapper) { - WrapperInfo wrapper = op.getWrapper(); - if (useWrapper && wrapper != null) { - DataType dt1 = wrapper.getInputWrapperType(); + WrapperInfo inputWrapperInfo = op.getInputWrapper(); + WrapperInfo outputWrapperInfo = op.getOutputWrapper(); + + if (useWrapper && (inputWrapperInfo != null)) { + DataType dt1 = inputWrapperInfo.getWrapperType(); if (dt1 != null) { dataTypes.add(dt1); } - DataType dt2 = wrapper.getOutputWrapperType(); + } + if (useWrapper && (outputWrapperInfo != null)) { + DataType dt2 = outputWrapperInfo.getWrapperType(); if (dt2 != null) { dataTypes.add(dt2); } diff --git a/branches/sca-java-1.x/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java b/branches/sca-java-1.x/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java index a1f4c12c8f..9cb781a3e1 100644 --- a/branches/sca-java-1.x/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java +++ b/branches/sca-java-1.x/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java @@ -46,9 +46,10 @@ public class JAXBWrapperHandler implements WrapperHandler<Object> { private JAXBWrapperHelper helper = new JAXBWrapperHelper(); public Object create(Operation operation, boolean input) { - WrapperInfo wrapperInfo = operation.getWrapper(); - ElementInfo element = input ? wrapperInfo.getInputWrapperElement() : wrapperInfo.getOutputWrapperElement(); - final Class<?> wrapperClass = input ? wrapperInfo.getInputWrapperClass() : wrapperInfo.getOutputWrapperClass(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + ElementInfo element = input ? inputWrapperInfo.getWrapperElement() : outputWrapperInfo.getWrapperElement(); + final Class<?> wrapperClass = input ? inputWrapperInfo.getWrapperClass() : outputWrapperInfo.getWrapperClass(); try { if (wrapperClass == null) { return null; @@ -65,7 +66,7 @@ public class JAXBWrapperHandler implements WrapperHandler<Object> { public void setChildren(Object wrapper, Object[] childObjects, Operation operation, boolean input) { List<ElementInfo> childElements = - input ? operation.getWrapper().getInputChildElements() : operation.getWrapper().getOutputChildElements(); + input ? operation.getInputWrapper().getChildElements() : operation.getOutputWrapper().getChildElements(); List<String> childNames = new ArrayList<String>(); Map<String, Object> values = new HashMap<String, Object>(); for (int i = 0; i < childElements.size(); i++) { @@ -121,8 +122,8 @@ public class JAXBWrapperHandler implements WrapperHandler<Object> { * @see org.apache.tuscany.sca.databinding.WrapperHandler#getChildren(java.lang.Object, Operation, boolean) */ public List getChildren(Object wrapper, Operation operation, boolean input) { - List<ElementInfo> childElements = input? operation.getWrapper().getInputChildElements(): - operation.getWrapper().getOutputChildElements(); + List<ElementInfo> childElements = input? operation.getInputWrapper().getChildElements(): + operation.getOutputWrapper().getChildElements(); List<String> childNames = new ArrayList<String>(); for (ElementInfo e : childElements) { @@ -135,8 +136,9 @@ public class JAXBWrapperHandler implements WrapperHandler<Object> { * @see org.apache.tuscany.sca.databinding.WrapperHandler#getWrapperType(Operation, boolean) */ public DataType getWrapperType(Operation operation, boolean input) { - WrapperInfo wrapper = operation.getWrapper(); - DataType dt = input ? wrapper.getInputWrapperType() : wrapper.getOutputWrapperType(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + DataType dt = input ? inputWrapperInfo.getWrapperType() : outputWrapperInfo.getWrapperType(); return dt; } @@ -145,7 +147,7 @@ public class JAXBWrapperHandler implements WrapperHandler<Object> { */ public boolean isInstance(Object wrapper, Operation operation, boolean input) { Class<?> wrapperClass = - input ? operation.getWrapper().getInputWrapperClass() : operation.getWrapper().getOutputWrapperClass(); + input ? operation.getInputWrapper().getWrapperClass() : operation.getOutputWrapper().getWrapperClass(); return wrapperClass == null ? false : wrapperClass.isInstance(wrapper); } } diff --git a/branches/sca-java-1.x/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandlerTestCase.java b/branches/sca-java-1.x/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandlerTestCase.java index c10a5227ce..501f5b21b7 100644 --- a/branches/sca-java-1.x/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandlerTestCase.java +++ b/branches/sca-java-1.x/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandlerTestCase.java @@ -60,10 +60,10 @@ public class JAXBWrapperHandlerTestCase extends TestCase { public void testCreate() { ElementInfo element = new ElementInfo(ELEMENT, null); Operation op = new OperationImpl(); - WrapperInfo wrapperInfo = new WrapperInfo(JAXBDataBinding.NAME, element, null, null, null); - wrapperInfo.setInputWrapperType(new DataTypeImpl<XMLType>(JAXBDataBinding.NAME, StockQuoteOffer.class, - XMLType.UNKNOWN)); - op.setWrapper(wrapperInfo); + WrapperInfo wrapperInfo = new WrapperInfo(JAXBDataBinding.NAME, element, null); + wrapperInfo.setWrapperType(new DataTypeImpl<XMLType>(JAXBDataBinding.NAME, StockQuoteOffer.class, + XMLType.UNKNOWN)); + op.setInputWrapper(wrapperInfo); Object offer = handler.create(op, true); Assert.assertTrue(offer instanceof StockQuoteOffer); } @@ -79,9 +79,9 @@ public class JAXBWrapperHandlerTestCase extends TestCase { wrapper.setInput("IBM"); List<ElementInfo> elements = new ArrayList<ElementInfo>(); elements.add(new ElementInfo(INPUT, null)); - WrapperInfo wrapperInfo = new WrapperInfo(JAXBDataBinding.NAME, null, null, elements, null); + WrapperInfo wrapperInfo = new WrapperInfo(JAXBDataBinding.NAME, null, elements); Operation op = new OperationImpl(); - op.setWrapper(wrapperInfo); + op.setInputWrapper(wrapperInfo); List children = handler.getChildren(wrapper, op, true); assertNotNull(children); assertEquals(1, children.size()); diff --git a/branches/sca-java-1.x/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java b/branches/sca-java-1.x/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java index c1978883df..93c71cce6c 100644 --- a/branches/sca-java-1.x/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java +++ b/branches/sca-java-1.x/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOTypeHelper.java @@ -185,13 +185,14 @@ public class SDOTypeHelper implements XMLTypeHelper { private static List<DataType> getDataTypes(Interface intf) { List<DataType> dataTypes = new ArrayList<DataType>(); for (Operation op : intf.getOperations()) { - WrapperInfo wrapper = op.getWrapper(); - if (wrapper != null) { - DataType dt1 = wrapper.getInputWrapperType(); + WrapperInfo inputWrapperInfo = op.getInputWrapper(); + WrapperInfo outputWrapperInfo = op.getOutputWrapper(); + if (inputWrapperInfo != null && outputWrapperInfo != null) { + DataType dt1 = inputWrapperInfo.getWrapperType(); if (dt1 != null) { dataTypes.add(dt1); } - DataType dt2 = wrapper.getOutputWrapperType(); + DataType dt2 = outputWrapperInfo.getWrapperType(); if (dt2 != null) { dataTypes.add(dt2); } diff --git a/branches/sca-java-1.x/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandler.java b/branches/sca-java-1.x/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandler.java index 8a1cd666d8..167be60640 100644 --- a/branches/sca-java-1.x/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandler.java +++ b/branches/sca-java-1.x/modules/databinding-sdo/src/main/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandler.java @@ -51,9 +51,12 @@ import commonj.sdo.helper.XSDHelper; public class SDOWrapperHandler implements WrapperHandler<Object> { public Object create(Operation operation, boolean input) { - WrapperInfo wrapperInfo = operation.getWrapper(); - ElementInfo element = input ? wrapperInfo.getInputWrapperElement() : wrapperInfo.getOutputWrapperElement(); - // Class<?> wrapperClass = input ? wrapperInfo.getInputWrapperClass() : wrapperInfo.getOutputWrapperClass(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + ElementInfo element = input ? inputWrapperInfo.getWrapperElement() : + outputWrapperInfo.getWrapperElement(); + HelperContext helperContext = SDOContextHelper.getHelperContext(operation); Type sdoType = getSDOType(helperContext, element); if (sdoType != null) { @@ -64,8 +67,12 @@ public class SDOWrapperHandler implements WrapperHandler<Object> { } public void setChildren(Object wrapper, Object[] childObjects, Operation operation, boolean input) { - List<ElementInfo> childElements = - input ? operation.getWrapper().getInputChildElements() : operation.getWrapper().getOutputChildElements(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + List<ElementInfo> childElements = input? inputWrapperInfo.getChildElements(): + outputWrapperInfo.getChildElements(); + for (int i = 0; i < childElements.size(); i++) { setChild(wrapper, i, childElements.get(i), childObjects[i]); } @@ -122,8 +129,12 @@ public class SDOWrapperHandler implements WrapperHandler<Object> { * @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(); + HelperContext helperContext = SDOContextHelper.getHelperContext(operation); Type sdoType = getSDOType(helperContext, element); if (sdoType != null) { @@ -163,8 +174,12 @@ public class SDOWrapperHandler implements WrapperHandler<Object> { * @see org.apache.tuscany.sca.databinding.WrapperHandler#isInstance(java.lang.Object, Operation, boolean) */ public boolean isInstance(Object wrapper, 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<ElementInfo> childElements = // input ? wrapperInfo.getInputChildElements() : wrapperInfo.getOutputChildElements(); HelperContext helperContext = SDOContextHelper.getHelperContext(operation); diff --git a/branches/sca-java-1.x/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandlerTestCase.java b/branches/sca-java-1.x/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandlerTestCase.java index 11d8495de8..805a1ab5ce 100644 --- a/branches/sca-java-1.x/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandlerTestCase.java +++ b/branches/sca-java-1.x/modules/databinding-sdo/src/test/java/org/apache/tuscany/sca/databinding/sdo/SDOWrapperHandlerTestCase.java @@ -74,8 +74,8 @@ public class SDOWrapperHandlerTestCase extends TestCase { xsdHelper.define(getClass().getResourceAsStream("/wrapper.xsd"), null); ElementInfo element = new ElementInfo(new QName("http://www.example.com/wrapper", "op"), null); Operation op = new OperationImpl(); - WrapperInfo wrapperInfo = new WrapperInfo(SDODataBinding.NAME, element, null, null, null); - op.setWrapper(wrapperInfo); + WrapperInfo wrapperInfo = new WrapperInfo(SDODataBinding.NAME, element, null); + op.setInputWrapper(wrapperInfo); DataObject wrapper = (DataObject) handler.create(op, true); assertNotNull(wrapper); } diff --git a/branches/sca-java-1.x/modules/databinding-xmlbeans/src/main/java/org/apache/tuscany/sca/databinding/xmlbeans/XMLBeansWrapperHandler.java b/branches/sca-java-1.x/modules/databinding-xmlbeans/src/main/java/org/apache/tuscany/sca/databinding/xmlbeans/XMLBeansWrapperHandler.java index 506c42e40f..ccf48174e6 100644 --- a/branches/sca-java-1.x/modules/databinding-xmlbeans/src/main/java/org/apache/tuscany/sca/databinding/xmlbeans/XMLBeansWrapperHandler.java +++ b/branches/sca-java-1.x/modules/databinding-xmlbeans/src/main/java/org/apache/tuscany/sca/databinding/xmlbeans/XMLBeansWrapperHandler.java @@ -41,8 +41,12 @@ public class XMLBeansWrapperHandler implements WrapperHandler<XmlObject> { * @see org.apache.tuscany.sca.databinding.WrapperHandler#create(org.apache.tuscany.sca.interfacedef.Operation, boolean) */ public XmlObject 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(); + return null; } @@ -52,8 +56,12 @@ public class XMLBeansWrapperHandler implements WrapperHandler<XmlObject> { public List getChildren(XmlObject wrapper, Operation operation, boolean input) { List<Object> children = new ArrayList<Object>(); - List<ElementInfo> childElements = - input ? operation.getWrapper().getInputChildElements() : operation.getWrapper().getOutputChildElements(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + List<ElementInfo> childElements = input? inputWrapperInfo.getChildElements(): + outputWrapperInfo.getChildElements(); + for (ElementInfo e : childElements) { XmlObject[] objects = wrapper.selectChildren(e.getQName()); if (objects != null && objects.length == 1) { @@ -80,8 +88,12 @@ public class XMLBeansWrapperHandler implements WrapperHandler<XmlObject> { * @see org.apache.tuscany.sca.databinding.WrapperHandler#isInstance(java.lang.Object, org.apache.tuscany.sca.interfacedef.Operation, boolean) */ public boolean isInstance(Object wrapper, 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(); + return true; } @@ -89,8 +101,12 @@ public class XMLBeansWrapperHandler implements WrapperHandler<XmlObject> { * @see org.apache.tuscany.sca.databinding.WrapperHandler#setChildren(java.lang.Object, java.lang.Object[], org.apache.tuscany.sca.interfacedef.Operation, boolean) */ public void setChildren(XmlObject wrapper, Object[] childObjects, Operation operation, boolean input) { - List<ElementInfo> childElements = - input ? operation.getWrapper().getInputChildElements() : operation.getWrapper().getOutputChildElements(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + + List<ElementInfo> childElements = input? inputWrapperInfo.getChildElements(): + outputWrapperInfo.getChildElements(); + int i = 0; for (ElementInfo c : childElements) { SchemaProperty property = wrapper.schemaType().getElementProperty(c.getQName()); diff --git a/branches/sca-java-1.x/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/DataTypeHelper.java b/branches/sca-java-1.x/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/DataTypeHelper.java index 1e39150f4a..ce3237a574 100644 --- a/branches/sca-java-1.x/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/DataTypeHelper.java +++ b/branches/sca-java-1.x/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/DataTypeHelper.java @@ -132,13 +132,16 @@ public class DataTypeHelper { } private static void getDataTypes(List<DataType> dataTypes, Operation op, boolean useWrapper) { - WrapperInfo wrapper = op.getWrapper(); - if (useWrapper && wrapper != null) { - DataType dt1 = wrapper.getInputWrapperType(); + + WrapperInfo inputWrapperInfo = op.getInputWrapper(); + WrapperInfo outputWrapperInfo = op.getOutputWrapper(); + + if (useWrapper && (inputWrapperInfo != null) && (outputWrapperInfo != null)) { + DataType dt1 = inputWrapperInfo.getWrapperType(); if (dt1 != null) { dataTypes.add(dt1); } - DataType dt2 = wrapper.getOutputWrapperType(); + DataType dt2 = outputWrapperInfo.getWrapperType(); if (dt2 != null) { dataTypes.add(dt2); } diff --git a/branches/sca-java-1.x/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMWrapperHandler.java b/branches/sca-java-1.x/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMWrapperHandler.java index 9e1ebb3522..19a8fe32d3 100644 --- a/branches/sca-java-1.x/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMWrapperHandler.java +++ b/branches/sca-java-1.x/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMWrapperHandler.java @@ -48,9 +48,10 @@ public class DOMWrapperHandler implements WrapperHandler<Node> { public Node create(Operation operation, boolean input) { try { - WrapperInfo wrapperInfo = operation.getWrapper(); - ElementInfo element = input ? wrapperInfo.getInputWrapperElement() : wrapperInfo.getOutputWrapperElement(); - // Class<?> wrapperClass = input ? wrapperInfo.getInputWrapperClass() : wrapperInfo.getOutputWrapperClass(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + ElementInfo element = input ? inputWrapperInfo.getWrapperElement() : outputWrapperInfo.getWrapperElement(); + Document document = DOMHelper.newDocument(); QName name = element.getQName(); return DOMHelper.createElement(document, name); @@ -62,8 +63,8 @@ public class DOMWrapperHandler implements WrapperHandler<Node> { public void setChildren(Node wrapper, Object[] childObjects, Operation operation, boolean input) { - List<ElementInfo> childElements = input? operation.getWrapper().getInputChildElements(): - operation.getWrapper().getOutputChildElements(); + List<ElementInfo> childElements = input? operation.getInputWrapper().getChildElements(): + operation.getOutputWrapper().getChildElements(); for (int i = 0; i < childElements.size(); i++) { setChild(wrapper, i, childElements.get(i), childObjects[i]); } @@ -79,8 +80,8 @@ public class DOMWrapperHandler implements WrapperHandler<Node> { public List getChildren(Node wrapper, Operation operation, boolean input) { assert wrapper != null; - List<ElementInfo> childElements = input? operation.getWrapper().getInputChildElements(): - operation.getWrapper().getOutputChildElements(); + List<ElementInfo> childElements = input? operation.getInputWrapper().getChildElements(): + operation.getOutputWrapper().getChildElements(); if (wrapper.getNodeType() == Node.DOCUMENT_NODE) { wrapper = ((Document)wrapper).getDocumentElement(); } @@ -99,8 +100,9 @@ public class DOMWrapperHandler implements WrapperHandler<Node> { * @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<XMLType> wrapperType = new DataTypeImpl<XMLType>(DOMDataBinding.NAME, Node.class, new XMLType(element)); return wrapperType; @@ -109,10 +111,13 @@ public class DOMWrapperHandler implements WrapperHandler<Node> { public boolean isInstance(Object wrapperObj, Operation operation, boolean input) { - WrapperInfo wrapperInfo = operation.getWrapper(); - ElementInfo element = input ? wrapperInfo.getInputWrapperElement() : wrapperInfo.getOutputWrapperElement(); - List<ElementInfo> childElements = - input ? wrapperInfo.getInputChildElements() : wrapperInfo.getOutputChildElements(); + WrapperInfo inputWrapperInfo = operation.getInputWrapper(); + WrapperInfo outputWrapperInfo = operation.getOutputWrapper(); + ElementInfo element = input ? inputWrapperInfo.getWrapperElement() : outputWrapperInfo.getWrapperElement(); + + List<ElementInfo> childElements = input? inputWrapperInfo.getChildElements(): + outputWrapperInfo.getChildElements(); + Node wrapper = (Node)wrapperObj; if (wrapper.getNodeType() == Node.DOCUMENT_NODE) { wrapper = ((Document)wrapper).getDocumentElement(); diff --git a/branches/sca-java-1.x/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java b/branches/sca-java-1.x/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java index ac086745c0..79a304bc2b 100644 --- a/branches/sca-java-1.x/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java +++ b/branches/sca-java-1.x/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java @@ -129,7 +129,8 @@ public class JAXWSJavaInterfaceProcessor implements JavaInterfaceVisitor { if(bare) { // For BARE parameter style, the data won't be unwrapped // The wrapper should be null - operation.setWrapperStyle(false); + operation.setInputWrapperStyle(false); + operation.setOutputWrapperStyle(false); } documentStyle = methodSOAPBinding.style() == Style.DOCUMENT; } @@ -300,14 +301,17 @@ public class JAXWSJavaInterfaceProcessor implements JavaInterfaceVisitor { } String db = inputWrapperDT != null ? inputWrapperDT.getDataBinding() : JAXB_DATABINDING; - WrapperInfo wrapperInfo = - new WrapperInfo(db, new ElementInfo(inputWrapper, null), new ElementInfo(outputWrapper, null), - inputElements, outputElements); + + WrapperInfo inputWrapperInfo = + new WrapperInfo(db, new ElementInfo(inputWrapper, null), inputElements); + WrapperInfo outputWrapperInfo = + new WrapperInfo(db, new ElementInfo(outputWrapper, null), outputElements); - wrapperInfo.setInputWrapperType(inputWrapperDT); - wrapperInfo.setOutputWrapperType(outputWrapperDT); + inputWrapperInfo.setWrapperType(inputWrapperDT); + outputWrapperInfo.setWrapperType(outputWrapperDT); - operation.setWrapper(wrapperInfo); + operation.setInputWrapper(inputWrapperInfo); + operation.setOutputWrapper(outputWrapperInfo); } } } diff --git a/branches/sca-java-1.x/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessorTestCase.java b/branches/sca-java-1.x/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessorTestCase.java index 108d283584..725f296090 100644 --- a/branches/sca-java-1.x/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessorTestCase.java +++ b/branches/sca-java-1.x/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessorTestCase.java @@ -60,9 +60,9 @@ public class JAXWSJavaInterfaceProcessorTestCase extends TestCase { interfaceProcessor.visitInterface(contract); Operation op = contract.getOperations().get(0); - Assert.assertTrue(!op.isWrapperStyle()); - Assert.assertEquals(new QName("http://www.example.com/stock", "stockQuoteOffer"), op.getWrapper().getInputWrapperElement().getQName()); - Assert.assertEquals(new QName("http://www.example.com/stock", "stockQuoteOfferResponse"), op.getWrapper().getOutputWrapperElement().getQName()); + Assert.assertTrue(!op.isInputWrapperStyle()); + Assert.assertEquals(new QName("http://www.example.com/stock", "stockQuoteOffer"), op.getInputWrapper().getWrapperElement().getQName()); + Assert.assertEquals(new QName("http://www.example.com/stock", "stockQuoteOfferResponse"), op.getOutputWrapper().getWrapperElement().getQName()); } /** @@ -90,14 +90,14 @@ public class JAXWSJavaInterfaceProcessorTestCase extends TestCase { op = op2; } - assertTrue(!op.isWrapperStyle() && op.getWrapper() == null); + assertTrue(!op.isInputWrapperStyle() && op.getInputWrapper() == null); if ("M2".equals(op2.getName())) { op = op2; } else { op = op1; } - assertTrue(!op.isWrapperStyle() && op.getWrapper() != null); + assertTrue(!op.isInputWrapperStyle() && op.getInputWrapper() != null); } diff --git a/branches/sca-java-1.x/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java b/branches/sca-java-1.x/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java index c392b92f8a..5b019b748f 100644 --- a/branches/sca-java-1.x/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java +++ b/branches/sca-java-1.x/modules/interface-wsdl-xml/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java @@ -67,13 +67,13 @@ public class WSDLOperationIntrospectorTestCase extends AbstractWSDLTestCase { outputType.getLogical().getElementName()); Assert.assertTrue(op.isWrapperStyle()); - DataType<List<DataType>> unwrappedInputType = op.getWrapper().getWrapperInfo().getUnwrappedInputType(); + DataType<List<DataType>> unwrappedInputType = op.getWrapper().getInputWrapperInfo().getUnwrappedInputType(); List<DataType> childTypes = unwrappedInputType.getLogical(); Assert.assertEquals(1, childTypes.size()); DataType<XMLType> childType = childTypes.get(0); Assert.assertEquals(new QName(null, "tickerSymbol"), childType.getLogical().getElementName()); - childType = op.getWrapper().getWrapperInfo().getUnwrappedOutputType(); + childType = op.getWrapper().getOutputWrapperInfo().getUnwrappedOutputType(); Assert.assertEquals(new QName(null, "price"), childType.getLogical().getElementName()); } diff --git a/branches/sca-java-1.x/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java b/branches/sca-java-1.x/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java index ab6467bfd7..ba2e4b6ec0 100644 --- a/branches/sca-java-1.x/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java +++ b/branches/sca-java-1.x/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java @@ -220,10 +220,11 @@ public class WSDLOperationIntrospectorImpl { operationModel.setInputType(getInputType()); operationModel.setOutputType(getOutputType()); - operationModel.setWrapperStyle(isWrapperStyle()); + operationModel.setInputWrapperStyle(isWrapperStyle()); + operationModel.setOutputWrapperStyle(isWrapperStyle()); if (isWrapperStyle()) { - WrapperInfo wrapperInfo = getWrapper().getWrapperInfo(); - operationModel.setWrapper(wrapperInfo); + operationModel.setInputWrapper(getWrapper().getInputWrapperInfo()); + operationModel.setOutputWrapper(getWrapper().getOutputWrapperInfo()); } } return operationModel; @@ -352,7 +353,8 @@ public class WSDLOperationIntrospectorImpl { // // private DataType<XMLType> unwrappedOutputType; - private transient WrapperInfo wrapperInfo; + private transient WrapperInfo inputWrapperInfo; + private transient WrapperInfo outputWrapperInfo; private List<XmlSchemaElement> getChildElements(XmlSchemaElement element) throws InvalidWSDLException { if (element == null) { @@ -553,25 +555,33 @@ public class WSDLOperationIntrospectorImpl { } */ - public WrapperInfo getWrapperInfo() throws InvalidWSDLException { - if (wrapperInfo == null) { + public WrapperInfo getInputWrapperInfo() throws InvalidWSDLException { + if (inputWrapperInfo == null) { ElementInfo in = getElementInfo(getInputWrapperElement()); - ElementInfo out = getElementInfo(getOutputWrapperElement()); List<ElementInfo> inChildren = new ArrayList<ElementInfo>(); if (in != null) { for (XmlSchemaElement e : getInputChildElements()) { inChildren.add(getElementInfo(e)); } } + + inputWrapperInfo = new WrapperInfo(dataBinding, in, inChildren); + } + return inputWrapperInfo; + } + + public WrapperInfo getOutputWrapperInfo() throws InvalidWSDLException { + if (outputWrapperInfo == null) { + ElementInfo out = getElementInfo(getOutputWrapperElement()); List<ElementInfo> outChildren = new ArrayList<ElementInfo>(); if (out != null) { for (XmlSchemaElement e : getOutputChildElements()) { outChildren.add(getElementInfo(e)); } } - wrapperInfo = new WrapperInfo(dataBinding, in, out, inChildren, outChildren); + outputWrapperInfo = new WrapperInfo(dataBinding, out, outChildren); } - return wrapperInfo; + return outputWrapperInfo; } } diff --git a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java index 1f5620c0b9..63e26ef7f7 100644 --- a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java +++ b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java @@ -27,7 +27,7 @@ import java.lang.reflect.Type; * runtime is written in Java. This may be the same form used by the application * but it may not; for example, an application that is performing stream * processing may want a physical form such as an - * {@link java.io.InputStream InputStream} to semantially operate on application + * {@link java.io.InputStream InputStream} to semantically operate on application * data such as a purchase order. The logical description is that used by the * assembly model and is an identifier into some well-known type space; examples * may be a Java type represented by its Class or an XML type represented by its diff --git a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java index f9de645a6e..1e91dc6fdb 100644 --- a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java +++ b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java @@ -79,6 +79,22 @@ public interface Interface extends Cloneable, PolicySetAttachPoint { * @param dataBinding */ void resetDataBinding(String dataBinding); + + /** + * Set the interface input types by copying those from the + * interface provided + * + * @param newInterface + */ + public void resetInterfaceInputTypes(Interface newInterface); + + /** + * Set the interface output types by copying those from the + * interface provided + * + * @param newInterface + */ + public void resetInterfaceOutputTypes(Interface newInterface); /** * Returns true if the Interface is dynamic. diff --git a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java index 4676e35f80..51b7645e57 100644 --- a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java +++ b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java @@ -132,26 +132,47 @@ public interface Operation extends Cloneable, PolicySetAttachPoint { * Set the operation to be non-blocking */ void setNonBlocking(boolean nonBlocking); + + /** + * @return the inputWrapperInfo + */ + WrapperInfo getInputWrapper(); + + /** + * @param wrapperInfo the inputWrapperInfo to set + */ + void setInputWrapper(WrapperInfo wrapperInfo); /** - * @return the wrapperInfo + * @return the outputWrapperInfo */ - WrapperInfo getWrapper(); + WrapperInfo getOutputWrapper(); /** - * @param wrapperInfo the wrapperInfo to set + * @param wrapperInfo the outputWrapperInfo to set */ - void setWrapper(WrapperInfo wrapperInfo); + // TODO - WI + void setOutputWrapper(WrapperInfo wrapperInfo); /** - * @return the wrapperStyle + * @return the inputWrapperStyle + */ + boolean isInputWrapperStyle(); + + /** + * @param inputWrapperStyle the wrapperStyle to set + */ + void setInputWrapperStyle(boolean wrapperStyle); + + /** + * @return the outputWrapperStyle */ - boolean isWrapperStyle(); + boolean isOutputWrapperStyle(); /** - * @param wrapperStyle the wrapperStyle to set + * @param outputWrapperStyle the wrapperStyle to set */ - void setWrapperStyle(boolean wrapperStyle); + void setOutputWrapperStyle(boolean wrapperStyle); /** * @deprecated This should be the WrapperInfo.getDataBinding() diff --git a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java index 9e7d6882f7..149e6306e5 100644 --- a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java +++ b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java @@ -87,14 +87,14 @@ public class InterfaceContractMapperImpl implements InterfaceContractMapper { boolean checkSourceWrapper = true; List<DataType> sourceInputType = source.getInputType().getLogical(); - if (source.isWrapperStyle() && source.getWrapper() != null) { - sourceInputType = source.getWrapper().getUnwrappedInputType().getLogical(); + if (source.isInputWrapperStyle() && source.getInputWrapper() != null) { + sourceInputType = source.getInputWrapper().getUnwrappedInputType().getLogical(); checkSourceWrapper = false; } boolean checkTargetWrapper = true; List<DataType> targetInputType = target.getInputType().getLogical(); - if (target.isWrapperStyle() && target.getWrapper() != null) { - targetInputType = target.getWrapper().getUnwrappedInputType().getLogical(); + if (target.isInputWrapperStyle() && target.getInputWrapper() != null) { + targetInputType = target.getInputWrapper().getUnwrappedInputType().getLogical(); checkTargetWrapper = false; } diff --git a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java index e2a524c5e0..23f1eec8cf 100644 --- a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java +++ b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java @@ -151,10 +151,11 @@ public class InterfaceImpl implements Interface { } } - if (op.isWrapperStyle()) { - WrapperInfo wrapper = op.getWrapper(); - if (wrapper != null) { - DataType<List<DataType>> unwrappedInputType = wrapper.getUnwrappedInputType(); + + if (op.isInputWrapperStyle()) { + WrapperInfo inputWrapperInfo = op.getInputWrapper(); + if (inputWrapperInfo != null) { + DataType<List<DataType>> unwrappedInputType = inputWrapperInfo.getUnwrappedInputType(); if (unwrappedInputType != null) { for (DataType d : unwrappedInputType.getLogical()) { if (d.getDataBinding() == null) { @@ -162,7 +163,13 @@ public class InterfaceImpl implements Interface { } } } - DataType unwrappedOutputType = wrapper.getUnwrappedOutputType(); + } + } + + if (op.isOutputWrapperStyle()) { + WrapperInfo outputWrapperInfo = op.getOutputWrapper(); + if (outputWrapperInfo != null){ + DataType unwrappedOutputType = outputWrapperInfo.getUnwrappedOutputType(); if (unwrappedOutputType != null && unwrappedOutputType.getDataBinding() == null) { unwrappedOutputType.setDataBinding(dataBinding); } @@ -179,6 +186,54 @@ public class InterfaceImpl implements Interface { dataType.setDataBinding(dataBinding); } } + + public void resetInterfaceInputTypes(Interface newInterface){ + for (int i = 0; i < getOperations().size(); i++) { + // TODO - same operation order is assumed. How to really + // find the right operation when we know that the + // data types will be different + Operation oldOperation = getOperations().get(i); + Operation newOperation = newInterface.getOperations().get(i); + + if (!oldOperation.getName().equals(newOperation.getName())){ + break; + } + + // set input types + oldOperation.setInputType(newOperation.getInputType()); + + // set wrapper + if (newOperation.isInputWrapperStyle()) { + oldOperation.setInputWrapperStyle(true); + oldOperation.setInputWrapper(newOperation.getInputWrapper()); + } + } + } + + public void resetInterfaceOutputTypes(Interface newInterface){ + for (int i = 0; i < getOperations().size(); i++) { + // TODO - same operation order is assumed. How to really + // find the right operation when we know that the + // data types will be different + Operation oldOperation = getOperations().get(i); + Operation newOperation = newInterface.getOperations().get(i); + + if (!oldOperation.getName().equals(newOperation.getName())){ + break; + } + + // set output types + oldOperation.setOutputType(newOperation.getOutputType()); + + // set fault types + oldOperation.setFaultTypes(newOperation.getFaultTypes()); + + // set wrapper + if (newOperation.isOutputWrapperStyle()) { + oldOperation.setOutputWrapper(newOperation.getOutputWrapper()); + } + } + } public void resetDataBinding(String dataBinding) { for (Operation op : getOperations()) { @@ -200,16 +255,23 @@ public class InterfaceImpl implements Interface { setDataBinding((DataType) d.getLogical(), dataBinding); } } - if (op.isWrapperStyle()) { - WrapperInfo wrapper = op.getWrapper(); - if (wrapper != null) { - DataType<List<DataType>> unwrappedInputType = wrapper.getUnwrappedInputType(); + + if (op.isInputWrapperStyle()) { + WrapperInfo inputWrapperInfo = op.getInputWrapper(); + if (inputWrapperInfo != null) { + DataType<List<DataType>> unwrappedInputType = inputWrapperInfo.getUnwrappedInputType(); if (unwrappedInputType != null) { for (DataType d : unwrappedInputType.getLogical()) { setDataBinding(d, dataBinding); } } - DataType unwrappedOutputType = wrapper.getUnwrappedOutputType(); + } + } + + if (op.isOutputWrapperStyle()) { + WrapperInfo outputWrapperInfo = op.getOutputWrapper(); + if (outputWrapperInfo != null){ + DataType unwrappedOutputType = outputWrapperInfo.getUnwrappedOutputType(); if (unwrappedOutputType != null) { setDataBinding(unwrappedOutputType, dataBinding); } diff --git a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java index 00a5dc3065..4b61dbe7ea 100644 --- a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java +++ b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java @@ -50,8 +50,12 @@ public class OperationImpl implements Operation { private Interface interfaze; private ConversationSequence conversationSequence = ConversationSequence.CONVERSATION_NONE; private boolean nonBlocking; - private boolean wrapperStyle; - private WrapperInfo wrapper; + // TODO - WI + //private WrapperInfo wrapper; + private boolean inputWrapperStyle; + private boolean outputWrapperStyle; + private WrapperInfo inputWrapper; + private WrapperInfo outputWrapper; private boolean dynamic; private Map<QName, List<DataType<XMLType>>> faultBeans; @@ -238,38 +242,76 @@ public class OperationImpl implements Operation { /** * @return the wrapperInfo */ - public WrapperInfo getWrapper() { - return wrapper; - } + // TODO - WI + //public WrapperInfo getWrapper() { + // return wrapper; + //} /** * @param wrapperInfo the wrapperInfo to set */ - public void setWrapper(WrapperInfo wrapperInfo) { - this.wrapper = wrapperInfo; + // TODO - WI + //public void setWrapper(WrapperInfo wrapperInfo) { + // this.wrapper = wrapperInfo; + //} + + public WrapperInfo getInputWrapper() { + return inputWrapper; + } + + public void setInputWrapper(WrapperInfo inputWrapper) { + this.inputWrapper = inputWrapper; + } + + public WrapperInfo getOutputWrapper() { + return outputWrapper; + } + + public void setOutputWrapper(WrapperInfo outputWrapper) { + this.outputWrapper = outputWrapper; } /** - * @return the wrapperStyle + * @return the inputWrapperStyle */ - public boolean isWrapperStyle() { - return wrapperStyle; + public boolean isInputWrapperStyle() { + return inputWrapperStyle; } /** - * @param wrapperStyle the wrapperStyle to set + * @param inputWrapperStyle the wrapperStyle to set */ - public void setWrapperStyle(boolean wrapperStyle) { - this.wrapperStyle = wrapperStyle; + public void setInputWrapperStyle(boolean wrapperStyle) { + this.inputWrapperStyle = wrapperStyle; + } + + /** + * @return the outputWrapperStyle + */ + public boolean isOutputWrapperStyle() { + return inputWrapperStyle; } + /** + * @param outputWrapperStyle the wrapperStyle to set + */ + public void setOutputWrapperStyle(boolean wrapperStyle) { + this.inputWrapperStyle = wrapperStyle; + } + + // TODO - WI + // These are deprecated and are a little awkward now that + // we split input wrapper from output wrapper public String getDataBinding() { - return wrapper != null ? wrapper.getDataBinding() : null; + return inputWrapper != null ? inputWrapper.getDataBinding() : null; } public void setDataBinding(String dataBinding) { - if (wrapper != null) { - wrapper.setDataBinding(dataBinding); + if (inputWrapper != null) { + inputWrapper.setDataBinding(dataBinding); + } + if (outputWrapper != null) { + outputWrapper.setDataBinding(dataBinding); } } diff --git a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java index 12db460959..b5a7915a11 100644 --- a/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java +++ b/branches/sca-java-1.x/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java @@ -31,7 +31,7 @@ import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl; * A WSDL operation qualifies for wrapper style mapping only if the following * criteria are met: * <ul> - * <li>(i) The operation�s input and output messages (if present) each contain + * <li>(i) The operation is input and output messages (if present) each contain * only a single part * <li>(ii) The input message part refers to a global element declaration whose * localname is equal to the operation name @@ -48,76 +48,61 @@ import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl; * @version $Rev$ $Date$ */ public class WrapperInfo { - private ElementInfo inputWrapperElement; - - private ElementInfo outputWrapperElement; - - private List<ElementInfo> inputChildElements; - - private List<ElementInfo> outputChildElements; + private String dataBinding; + private ElementInfo wrapperElement; + private List<ElementInfo> childElements; + private DataType<XMLType> wrapperType; - // The data type of the unwrapped input child elements + // A cache for the derived data type of the unwrapped + // input child elements private DataType<List<DataType>> unwrappedInputType; - // The data type of the unwrapped output child element (we only supports one child) + // A cache for the derived data type of the unwrapped + // output child element (we only support one child) private DataType<XMLType> unwrappedOutputType; - // The data for the input/output wrappers - private String dataBinding; - - // The data type for the input (request) wrapper bean - private DataType<XMLType> inputWrapperType; - // The data type for the output (response) wrapper bean - private DataType<XMLType> outputWrapperType; - public WrapperInfo(String dataBinding, - ElementInfo inputWrapperElement, - ElementInfo outputWrapperElement, - List<ElementInfo> inputElements, - List<ElementInfo> outputElements) { + ElementInfo wrapperElement, + List<ElementInfo> childElements) { super(); this.dataBinding = dataBinding; - this.inputWrapperElement = inputWrapperElement; - this.outputWrapperElement = outputWrapperElement; - this.inputChildElements = inputElements; - this.outputChildElements = outputElements; + this.wrapperElement = wrapperElement; + this.childElements = childElements; } - /** - * @return the inputElements - */ - public List<ElementInfo> getInputChildElements() { - return inputChildElements; + public List<ElementInfo> getChildElements() { + return childElements; } - /** - * @return the inputWrapperElement - */ - public ElementInfo getInputWrapperElement() { - return inputWrapperElement; + public ElementInfo getWrapperElement() { + return wrapperElement; + } + + public String getDataBinding() { + return dataBinding; + } + + public void setDataBinding(String dataBinding) { + this.dataBinding = dataBinding; } - /** - * @return the outputElements - */ - public List<ElementInfo> getOutputChildElements() { - return outputChildElements; + public DataType<XMLType> getWrapperType() { + return wrapperType; } - /** - * @return the outputWrapperElement - */ - public ElementInfo getOutputWrapperElement() { - return outputWrapperElement; + public void setWrapperType(DataType<XMLType> wrapperType) { + this.wrapperType = wrapperType; } + + public Class<?> getWrapperClass() { + return wrapperType == null ? null : wrapperType.getPhysical(); + } + - /** - * @return the unwrappedInputType - */ public DataType<List<DataType>> getUnwrappedInputType() { if (unwrappedInputType == null) { List<DataType> childTypes = new ArrayList<DataType>(); - for (ElementInfo element : getInputChildElements()) { + for (ElementInfo element : getChildElements()) { DataType type = getDataType(element); childTypes.add(type); } @@ -126,23 +111,9 @@ public class WrapperInfo { return unwrappedInputType; } - private DataType getDataType(ElementInfo element) { - DataType type = null; - if (element.isMany()) { - DataType logical = new DataTypeImpl<XMLType>(dataBinding, Object.class, new XMLType(element)); - type = new DataTypeImpl<DataType>("java:array", Object[].class, logical); - } else { - type = new DataTypeImpl<XMLType>(dataBinding, Object.class, new XMLType(element)); - } - return type; - } - - /** - * @return the unwrappedOutputType - */ public DataType getUnwrappedOutputType() { if (unwrappedOutputType == null) { - List<ElementInfo> elements = getOutputChildElements(); + List<ElementInfo> elements = getChildElements(); if (elements != null && elements.size() > 0) { if (elements.size() > 1) { // We don't support output with multiple parts @@ -155,36 +126,15 @@ public class WrapperInfo { } return unwrappedOutputType; } - - public Class<?> getInputWrapperClass() { - return inputWrapperType == null ? null : inputWrapperType.getPhysical(); - } - - public Class<?> getOutputWrapperClass() { - return outputWrapperType == null ? null : outputWrapperType.getPhysical(); - } - - public String getDataBinding() { - return dataBinding; - } - - public void setDataBinding(String dataBinding) { - this.dataBinding = dataBinding; - } - - public DataType<XMLType> getInputWrapperType() { - return inputWrapperType; - } - - public void setInputWrapperType(DataType<XMLType> inputWrapperType) { - this.inputWrapperType = inputWrapperType; - } - - public DataType<XMLType> getOutputWrapperType() { - return outputWrapperType; - } - - public void setOutputWrapperType(DataType<XMLType> outputWrapperType) { - this.outputWrapperType = outputWrapperType; - } + + private DataType getDataType(ElementInfo element) { + DataType type = null; + if (element.isMany()) { + DataType logical = new DataTypeImpl<XMLType>(dataBinding, Object.class, new XMLType(element)); + type = new DataTypeImpl<DataType>("java:array", Object[].class, logical); + } else { + type = new DataTypeImpl<XMLType>(dataBinding, Object.class, new XMLType(element)); + } + return type; + } } |