Author: jsdelfino
Date: Wed Aug 15 19:33:51 2007
New Revision: 566470
URL: http://svn.apache.org/viewvc?view=rev&rev=566470
Log:
The JSON and Ajax ServiceBindingProviders were incorrectly calling
componentContext.createSelfReference() to get a proxy to the target
ComponentService, and this was not working (NPE) with bindings declared on
component services (although it was working by chance for bindings declared on
composite services if you had no other binding declared on your first component
service...). Since a self reference is configured to use the binding from its
corresponding service for outgoing calls, it shoulnd't be used to dispatch
incoming calls to the component service, unless you want to go back out to the
network :). I fixed the ServiceBindingProviders to use the correct runtime
wires from the target service to create a proxy instead of using a self
reference.
Modified:
incubator/tuscany/java/sca/modules/binding-ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxService.java
incubator/tuscany/java/sca/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCService.java
Modified:
incubator/tuscany/java/sca/modules/binding-ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxService.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxService.java?view=diff&rev=566470&r1=566469&r2=566470
==============================================================================
---
incubator/tuscany/java/sca/modules/binding-ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxService.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-ajax/src/main/java/org/apache/tuscany/sca/binding/ajax/AjaxService.java
Wed Aug 15 19:33:51 2007
@@ -20,6 +20,8 @@
package org.apache.tuscany.sca.binding.ajax;
import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.core.invocation.JDKProxyService;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
import org.apache.tuscany.sca.http.ServletHost;
import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -52,9 +54,12 @@
}
Class<?> type =
((JavaInterface)rcs.getInterfaceContract().getInterface()).getJavaClass();
- Object instance = rc.createSelfReference(type).getService();
- servlet.addService(binding.getName(), type, instance);
+ // Create a Java proxy to the target service
+ ProxyFactory proxyFactory = new JDKProxyService();
+ Object proxy = proxyFactory.createProxy(type,
rcs.getRuntimeWire(binding));
+
+ servlet.addService(binding.getName(), type, proxy);
servletHost.addServletMapping(SERVLET_PATH, servlet);
}
Modified:
incubator/tuscany/java/sca/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCService.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCService.java?view=diff&rev=566470&r1=566469&r2=566470
==============================================================================
---
incubator/tuscany/java/sca/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCService.java
(original)
+++
incubator/tuscany/java/sca/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCService.java
Wed Aug 15 19:33:51 2007
@@ -22,11 +22,14 @@
import java.net.URI;
import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.core.invocation.JDKProxyService;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
import org.apache.tuscany.sca.http.ServletHost;
import org.apache.tuscany.sca.interfacedef.Interface;
import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
import org.apache.tuscany.sca.spi.ComponentLifecycle;
/**
@@ -66,10 +69,15 @@
public void start() {
- // Create and register a servlet for this service
+ // Determine the service business interface
Class<?> serviceInterface =
getTargetJavaClass(service.getInterfaceContract().getInterface());
- Object instance =
component.createSelfReference(serviceInterface).getService();
- JSONRPCServiceServlet serviceServlet = new
JSONRPCServiceServlet(binding.getName(), serviceInterface, instance);
+
+ // Create a Java proxy to the target service
+ ProxyFactory proxyFactory = new JDKProxyService();
+ Object proxy = proxyFactory.createProxy(serviceInterface,
service.getRuntimeWire(binding));
+
+ // Create and register a servlet for this service
+ JSONRPCServiceServlet serviceServlet = new
JSONRPCServiceServlet(binding.getName(), serviceInterface, proxy);
int port;
servletHost.addServletMapping(binding.getURI(), serviceServlet);
URI uri = URI.create(binding.getURI());
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]