diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany')
-rw-r--r-- | sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java index 39881ce68d..b6dce222ca 100644 --- a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java +++ b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java @@ -22,8 +22,9 @@ package org.apache.tuscany.sca.binding.jsonrpc.provider; import java.util.ArrayList; import java.util.List; +import javax.servlet.Servlet; + import org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding; -import org.apache.tuscany.sca.databinding.json.JSONDataBinding; import org.apache.tuscany.sca.host.http.ServletHost; import org.apache.tuscany.sca.interfacedef.Interface; import org.apache.tuscany.sca.interfacedef.InterfaceContract; @@ -93,18 +94,28 @@ public class JSONRPCServiceBindingProvider implements ServiceBindingProvider { // Create and register a Servlet for this service JSONRPCServiceServlet serviceServlet = new JSONRPCServiceServlet(messageFactory, endpoint, serviceInterface, proxy); - String mapping = binding.getURI(); - if (!mapping.endsWith("/")) { - mapping += "/"; + String mapping = registerServlet(serviceServlet); + servletMappings.add(mapping); + } + + public String registerServlet(Servlet servlet) { + // Create our HTTP service listener Servlet and register it with the + // Servlet host + String servletMapping = binding.getURI(); + if (!servletMapping.endsWith("/")) { + servletMapping += "/"; } - if (!mapping.endsWith("*")) { - mapping += "*"; + if (!servletMapping.endsWith("*")) { + servletMapping += "*"; } - servletHost.addServletMapping(mapping, serviceServlet); - servletMappings.add(mapping); - servletHost.addServletMapping(binding.getURI(), serviceServlet); - servletMappings.add(binding.getURI()); + String mappedURI = servletHost.addServletMapping(servletMapping, servlet); + String deployedURI = mappedURI; + if (deployedURI.endsWith("*")) { + deployedURI = deployedURI.substring(0, deployedURI.length() - 1); + } + binding.setURI(deployedURI); + return mappedURI; } public void stop() { |