From 99356bb73f6291ad798dfb579809c355c6db71e4 Mon Sep 17 00:00:00 2001 From: rfeng Date: Fri, 10 Sep 2010 01:12:21 +0000 Subject: Fix the self reference with explicit bindings git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@995627 13f79535-47bb-0310-9956-ffa450edef68 --- .../rest/provider/RESTServiceBindingProvider.java | 27 +++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'sca-java-2.x/trunk/modules/binding-rest-runtime/src') diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java index 9a9e5a108e..eaf830ceb5 100644 --- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java +++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/main/java/org/apache/tuscany/sca/binding/rest/provider/RESTServiceBindingProvider.java @@ -211,9 +211,13 @@ public class RESTServiceBindingProvider implements EndpointProvider { throw new IllegalStateException("No get or service method found on the service"); } + servletMapping = registerServlet(servlet); + } + + public String registerServlet(Servlet servlet) { // Create our HTTP service listener Servlet and register it with the // Servlet host - servletMapping = binding.getURI(); + String servletMapping = binding.getURI(); if (!servletMapping.endsWith("/")) { servletMapping += "/"; } @@ -221,7 +225,13 @@ public class RESTServiceBindingProvider implements EndpointProvider { servletMapping += "*"; } - servletHost.addServletMapping(servletMapping, servlet); + 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() { @@ -258,17 +268,8 @@ public class RESTServiceBindingProvider implements EndpointProvider { TuscanyRESTServlet restServlet = new TuscanyRESTServlet(extensionPoints, application.resourceClass); - // Create our HTTP service listener Servlet and register it with the - // Servlet host - servletMapping = binding.getURI(); - if (!servletMapping.endsWith("/")) { - servletMapping += "/"; - } - if (!servletMapping.endsWith("*")) { - servletMapping += "*"; - } - - servletHost.addServletMapping(servletMapping, restServlet); + servletMapping = registerServlet(restServlet); + RegistrationUtils.registerApplication(application, restServlet.getServletContext()); return application; } else { -- cgit v1.2.3