From 4dcff7533534e4b634b349a1105c7862d1655405 Mon Sep 17 00:00:00 2001 From: rfeng Date: Fri, 13 Nov 2009 21:49:15 +0000 Subject: Replace RuntimeWire with RuntimeEnpoint/RuntimeEndpointReference as the owner of invocaiton chains (http://www.mail-archive.com/dev@tuscany.apache.org/msg07856.html) git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@836009 13f79535-47bb-0310-9956-ffa450edef68 --- .../provider/JSONRPCBindingProviderFactory.java | 8 ++++---- .../provider/JSONRPCServiceBindingProvider.java | 13 ++++++------- .../jsonrpc/provider/JSONRPCServiceServlet.java | 21 +++++++-------------- 3 files changed, 17 insertions(+), 25 deletions(-) (limited to 'java/sca/modules/binding-jsonrpc-runtime') diff --git a/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingProviderFactory.java b/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingProviderFactory.java index 4059d5a1f0..2a1fa8ba6b 100644 --- a/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingProviderFactory.java +++ b/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingProviderFactory.java @@ -19,8 +19,6 @@ package org.apache.tuscany.sca.binding.jsonrpc.provider; -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.FactoryExtensionPoint; @@ -30,6 +28,8 @@ import org.apache.tuscany.sca.invocation.MessageFactory; import org.apache.tuscany.sca.provider.BindingProviderFactory; import org.apache.tuscany.sca.provider.ReferenceBindingProvider; import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; +import org.apache.tuscany.sca.runtime.RuntimeEndpointReference; /** * JSON-RPC Provider Factory @@ -49,12 +49,12 @@ public class JSONRPCBindingProviderFactory implements BindingProviderFactory servletMappings = new ArrayList(); - public JSONRPCServiceBindingProvider(Endpoint endpoint, + public JSONRPCServiceBindingProvider(RuntimeEndpoint endpoint, MessageFactory messageFactory, ServletHost servletHost) { this.endpoint = endpoint; @@ -72,7 +71,7 @@ public class JSONRPCServiceBindingProvider implements ServiceBindingProvider { } public InterfaceContract getBindingInterfaceContract() { - return service.getInterfaceContract(); + return serviceContract; } public boolean supportsOneWayInvocation() { @@ -81,7 +80,7 @@ public class JSONRPCServiceBindingProvider implements ServiceBindingProvider { public void start() { // Set default databinding to json - serviceContract.getInterface().resetDataBinding(JSONDataBinding.NAME); + // serviceContract.getInterface().resetDataBinding(JSONDataBinding.NAME); // Determine the service business interface Class serviceInterface = getTargetJavaClass(serviceContract.getInterface()); @@ -91,7 +90,7 @@ public class JSONRPCServiceBindingProvider implements ServiceBindingProvider { // Create and register a Servlet for this service JSONRPCServiceServlet serviceServlet = - new JSONRPCServiceServlet(messageFactory, binding, service, serviceContract, serviceInterface, proxy); + new JSONRPCServiceServlet(messageFactory, endpoint, serviceInterface, proxy); String mapping = binding.getURI(); if (!mapping.endsWith("/")) { mapping += "/"; diff --git a/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java b/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java index 71d335acc8..9034e24485 100644 --- a/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java +++ b/java/sca/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java @@ -32,12 +32,10 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Message; import org.apache.tuscany.sca.invocation.MessageFactory; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.apache.tuscany.sca.runtime.RuntimeWire; +import org.apache.tuscany.sca.runtime.RuntimeEndpoint; import org.jabsorb.JSONRPCBridge; import org.jabsorb.JSONRPCResult; import org.jabsorb.JSONRPCServlet; @@ -61,21 +59,17 @@ public class JSONRPCServiceServlet extends JSONRPCServlet { transient Binding binding; transient String serviceName; transient Object serviceInstance; - transient RuntimeComponentService componentService; - transient InterfaceContract serviceContract; + transient RuntimeEndpoint endpoint; transient Class serviceInterface; public JSONRPCServiceServlet(MessageFactory messageFactory, - Binding binding, - RuntimeComponentService componentService, - InterfaceContract serviceContract, + RuntimeEndpoint endpoint, Class serviceInterface, Object serviceInstance) { + this.endpoint = endpoint; this.messageFactory = messageFactory; - this.binding = binding; + this.binding = endpoint.getBinding(); this.serviceName = binding.getName(); - this.componentService = componentService; - this.serviceContract = serviceContract; this.serviceInterface = serviceInterface; this.serviceInstance = serviceInstance; } @@ -238,7 +232,6 @@ public class JSONRPCServiceServlet extends JSONRPCServlet { } // invoke the request - RuntimeWire wire = componentService.getRuntimeWire(binding, serviceContract); Operation jsonOperation = findOperation(method); Object result = null; @@ -254,7 +247,7 @@ public class JSONRPCServiceServlet extends JSONRPCServlet { //result = wire.invoke(jsonOperation, args); Message responseMessage = null; try { - responseMessage = wire.getInvocationChain(jsonOperation).getHeadInvoker().invoke(requestMessage); + responseMessage = endpoint.getInvocationChain(jsonOperation).getHeadInvoker().invoke(requestMessage); } catch (RuntimeException re) { if (re.getCause() instanceof javax.security.auth.login.LoginException) { throw re; @@ -297,7 +290,7 @@ public class JSONRPCServiceServlet extends JSONRPCServlet { method = method.substring(method.lastIndexOf(".") + 1); } - List operations = serviceContract.getInterface().getOperations(); + List operations = endpoint.getServiceInterfaceContract().getInterface().getOperations(); //componentService.getBindingProvider(binding).getBindingInterfaceContract().getInterface().getOperations(); -- cgit v1.2.3