From 08c90a78989469f04feaa242e33f719ddc3cd25a Mon Sep 17 00:00:00 2001 From: lresende Date: Tue, 5 May 2009 23:07:02 +0000 Subject: TUSCANY-2968 - Fixing data binding related issues to properly transform to/from json format as needed git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@772003 13f79535-47bb-0310-9956-ffa450edef68 --- .../http/provider/HTTPServiceBindingProvider.java | 57 ++++++++++++++-------- 1 file changed, 38 insertions(+), 19 deletions(-) (limited to 'branches/sca-java-1.x/modules/binding-http-new-runtime/src') diff --git a/branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java b/branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java index bd1c1737bb..9d474e6d71 100644 --- a/branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java +++ b/branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java @@ -58,12 +58,17 @@ public class HTTPServiceBindingProvider implements ServiceBindingProviderRRB { private static final QName AUTEHTICATION_INTENT = new QName("http://www.osoa.org/xmlns/sca/1.0","authentication"); private static final QName CONFIDENTIALITY_INTENT = new QName("http://www.osoa.org/xmlns/sca/1.0","confidentiality"); + private ExtensionPointRegistry extensionPoints; + private RuntimeComponent component; private RuntimeComponentService service; + private InterfaceContract serviceContract; private HTTPBinding binding; private MessageFactory messageFactory; - private ExtensionPointRegistry extensionPoints; + private OperationSelectorProvider osProvider; + private WireFormatProvider wfProvider; + private ServletHost servletHost; private String servletMapping; private HTTPBindingListenerServlet bindingListenerServlet; @@ -76,10 +81,41 @@ public class HTTPServiceBindingProvider implements ServiceBindingProviderRRB { ServletHost servletHost) { this.component = component; this.service = service; + this.binding = binding; this.extensionPoints = extensionPoints; this.messageFactory = messageFactory; this.servletHost = servletHost; + + // retrieve operation selector and wire format service providers + + ProviderFactoryExtensionPoint providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class); + + // Configure the interceptors for operation selection + OperationSelectorProviderFactory osProviderFactory = (OperationSelectorProviderFactory) providerFactories.getProviderFactory(binding.getOperationSelector().getClass()); + if (osProviderFactory != null) { + this.osProvider = osProviderFactory.createServiceOperationSelectorProvider(component, service, binding); + } + + // Configure the interceptors for wire format + WireFormatProviderFactory wfProviderFactory = (WireFormatProviderFactory) providerFactories.getProviderFactory(binding.getRequestWireFormat().getClass()); + if (wfProviderFactory != null) { + this.wfProvider = wfProviderFactory.createServiceWireFormatProvider(component, service, binding); + } + + + //clone the service contract to avoid databinding issues + try { + this.serviceContract = (InterfaceContract) service.getInterfaceContract().clone(); + + // configure data binding + if (this.wfProvider != null) { + wfProvider.configureWireFormatInterfaceContract(service.getInterfaceContract()); + } + } catch(CloneNotSupportedException e) { + this.serviceContract = service.getInterfaceContract(); + } + } public void start() { @@ -195,7 +231,7 @@ public class HTTPServiceBindingProvider implements ServiceBindingProviderRRB { } public InterfaceContract getBindingInterfaceContract() { - return null; + return service.getInterfaceContract(); } public boolean supportsOneWayInvocation() { @@ -210,27 +246,10 @@ public class HTTPServiceBindingProvider implements ServiceBindingProviderRRB { InvocationChain bindingChain = runtimeWire.getBindingInvocationChain(); - ProviderFactoryExtensionPoint providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class); - - // Configure the interceptors for operation selection - OperationSelectorProviderFactory osProviderFactory = (OperationSelectorProviderFactory) providerFactories.getProviderFactory(binding.getOperationSelector().getClass()); - OperationSelectorProvider osProvider = null; - if (osProviderFactory != null) { - osProvider = osProviderFactory.createServiceOperationSelectorProvider(component, service, binding); - } - if(osProvider != null) { bindingChain.addInterceptor(Phase.SERVICE_BINDING_OPERATION_SELECTOR, osProvider.createInterceptor()); } - - // Configure the interceptors for wire format - WireFormatProviderFactory wfProviderFactory = (WireFormatProviderFactory) providerFactories.getProviderFactory(binding.getRequestWireFormat().getClass()); - WireFormatProvider wfProvider = null; - if (wfProviderFactory != null) { - wfProvider = wfProviderFactory.createServiceWireFormatProvider(component, service, binding); - } - if (wfProvider != null) { bindingChain.addInterceptor(Phase.SERVICE_BINDING_WIREFORMAT, wfProvider.createInterceptor()); } -- cgit v1.2.3