summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-05-05 23:07:02 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-05-05 23:07:02 +0000
commit08c90a78989469f04feaa242e33f719ddc3cd25a (patch)
tree3b7a2db33c3787f8fe92f2ba00796fc42a1ea6f1
parentd97fd3b777dcde26ae37b94ef698d6e3c1a95993 (diff)
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
-rw-r--r--branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/provider/JSONRPCWireFormatInterceptor.java30
-rw-r--r--branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/provider/JSONRPCWireFormatServiceProvider.java14
-rw-r--r--branches/sca-java-1.x/modules/binding-http-new-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java57
3 files changed, 43 insertions, 58 deletions
diff --git a/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/provider/JSONRPCWireFormatInterceptor.java b/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/provider/JSONRPCWireFormatInterceptor.java
index 756f90eca4..6bd0298923 100644
--- a/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/provider/JSONRPCWireFormatInterceptor.java
+++ b/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/provider/JSONRPCWireFormatInterceptor.java
@@ -60,13 +60,6 @@ public class JSONRPCWireFormatInterceptor implements Interceptor {
}
public Message invoke(Message msg) {
-
- // Configure JSON Databding
- setDataBinding(runtimeWire.getTarget().getInterfaceContract().getInterface());
-
- // Set default databinding to json
- runtimeWire.getTarget().getInterfaceContract().getInterface().resetDataBinding(JSONDataBinding.NAME);
-
JSONObject jsonReq = (JSONObject) msg.getBody();
String method = null;
Object[] args = null;
@@ -131,27 +124,4 @@ public class JSONRPCWireFormatInterceptor implements Interceptor {
return responseMessage;
}
-
-
- private void setDataBinding(Interface interfaze) {
- List<Operation> operations = interfaze.getOperations();
- for (Operation operation : operations) {
- operation.setDataBinding(JSONDataBinding.NAME);
- DataType<List<DataType>> inputType = operation.getInputType();
- if (inputType != null) {
- List<DataType> logical = inputType.getLogical();
- for (DataType inArg : logical) {
- if (!SimpleJavaDataBinding.NAME.equals(inArg.getDataBinding())) {
- inArg.setDataBinding(JSONDataBinding.NAME);
- }
- }
- }
- DataType outputType = operation.getOutputType();
- if (outputType != null) {
- if (!SimpleJavaDataBinding.NAME.equals(outputType.getDataBinding())) {
- outputType.setDataBinding(JSONDataBinding.NAME);
- }
- }
- }
- }
}
diff --git a/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/provider/JSONRPCWireFormatServiceProvider.java b/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/provider/JSONRPCWireFormatServiceProvider.java
index 8522d00f73..89c43c0510 100644
--- a/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/provider/JSONRPCWireFormatServiceProvider.java
+++ b/branches/sca-java-1.x/modules/binding-http-new-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/http/wireformat/jsonrpc/provider/JSONRPCWireFormatServiceProvider.java
@@ -45,6 +45,7 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentService;
public class JSONRPCWireFormatServiceProvider implements WireFormatProvider {
private RuntimeComponent component;
private RuntimeComponentService service;
+ private InterfaceContract serviceContract;
private Binding binding;
public JSONRPCWireFormatServiceProvider(ExtensionPointRegistry extensionPoints,
@@ -55,22 +56,17 @@ public class JSONRPCWireFormatServiceProvider implements WireFormatProvider {
super();
this.component = component;
this.service = service;
+ this.serviceContract = service.getInterfaceContract();
this.binding = binding;
}
public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract) {
- InterfaceContract configuredContract = null;
- //clone the service contract to avoid databinding issues
- try {
- configuredContract = (InterfaceContract) interfaceContract.clone();
- } catch(CloneNotSupportedException e) {
- configuredContract = interfaceContract;
- }
+ this.serviceContract = interfaceContract;
- setDataBinding(configuredContract.getInterface());
+ setDataBinding(serviceContract.getInterface());
// Set default databinding to json
- configuredContract.getInterface().resetDataBinding(JSONDataBinding.NAME);
+ serviceContract.getInterface().resetDataBinding(JSONDataBinding.NAME);
return interfaceContract;
}
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());
}