tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jboy...@apache.org
Subject svn commit: r400317 - in /incubator/tuscany/java/sca: bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/builder/JSONRPCEntryPointBuilder.java tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyHost.java
Date Sat, 06 May 2006 14:48:16 GMT
Author: jboynes
Date: Sat May  6 07:48:14 2006
New Revision: 400317

URL: http://svn.apache.org/viewcvs?rev=400317&view=rev
Log:
fix parsing of mapping url - split wrapper path from context

Modified:
    incubator/tuscany/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/builder/JSONRPCEntryPointBuilder.java
    incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyHost.java

Modified: incubator/tuscany/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/builder/JSONRPCEntryPointBuilder.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/builder/JSONRPCEntryPointBuilder.java?rev=400317&r1=400316&r2=400317&view=diff
==============================================================================
--- incubator/tuscany/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/builder/JSONRPCEntryPointBuilder.java
(original)
+++ incubator/tuscany/java/sca/bindings/binding.jsonrpc/src/main/java/org/apache/tuscany/binding/jsonrpc/builder/JSONRPCEntryPointBuilder.java
Sat May  6 07:48:14 2006
@@ -12,20 +12,51 @@
  */
 package org.apache.tuscany.binding.jsonrpc.builder;
 
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.osoa.sca.annotations.Scope;
+
 import org.apache.tuscany.binding.jsonrpc.assembly.JSONRPCBinding;
 import org.apache.tuscany.binding.jsonrpc.config.JSONEntryPointContextFactory;
 import org.apache.tuscany.core.extension.EntryPointBuilderSupport;
 import org.apache.tuscany.core.extension.EntryPointContextFactory;
 import org.apache.tuscany.core.message.MessageFactory;
+import org.apache.tuscany.core.system.annotation.Autowire;
+import org.apache.tuscany.core.webapp.ServletHost;
 import org.apache.tuscany.model.assembly.EntryPoint;
-import org.osoa.sca.annotations.Scope;
 
 @Scope("MODULE")
 public class JSONRPCEntryPointBuilder extends EntryPointBuilderSupport<JSONRPCBinding>
{
 
+    private ServletHost tomcatHost;
+
+    @Autowire
+    public void setTomcatHost(ServletHost tomcatHost) {
+        this.tomcatHost = tomcatHost;
+    }
+
+
     @Override
     protected EntryPointContextFactory createEntryPointContextFactory(EntryPoint entryPoint,
MessageFactory msgFactory) {
+        initServlet(entryPoint);
         return new JSONEntryPointContextFactory(entryPoint.getName(), msgFactory);
+    }
+
+    private void initServlet(EntryPoint entryPoint) {
+            Servlet helloservlet = new HttpServlet() {
+                public void doGet(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException {
+                    PrintWriter out = res.getWriter();
+                    out.println("Hello, world!");
+                    out.close();
+                }
+            };
+            tomcatHost.registerMapping("/helloworldjsonrpc-SNAPSHOT/foo", helloservlet);
     }
 
 }

Modified: incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyHost.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyHost.java?rev=400317&r1=400316&r2=400317&view=diff
==============================================================================
--- incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyHost.java
(original)
+++ incubator/tuscany/java/sca/tomcat/src/main/java/org/apache/tuscany/tomcat/TuscanyHost.java
Sat May  6 07:48:14 2006
@@ -139,14 +139,13 @@
     }
 
     public void registerMapping(String mapping, Servlet servlet) {
-        // strip leading "/" as Tomcat uses host-relative context names
-        if (mapping.charAt(0) == '/') {
-            mapping = mapping.substring(1);
-        }
         Context ctx = map(mapping);
         if (ctx == null) {
             throw new UnsupportedOperationException("Cannot find context for mapping " +
mapping);
         }
+        String contextPath = ctx.getPath();
+        assert mapping.startsWith(contextPath);
+        mapping = mapping.substring(contextPath.length());
         Wrapper wrapper = new TuscanyWrapper(servlet);
         ctx.addChild(wrapper);
         wrapper.addMapping(mapping);



Mime
View raw message