tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r573217 - in /incubator/tuscany/java/sca/modules: binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/ host-http/src/main/java/org/apache/tuscany/sca/host/http/ host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp...
Date Thu, 06 Sep 2007 11:00:43 GMT
Author: antelder
Date: Thu Sep  6 04:00:42 2007
New Revision: 573217

URL: http://svn.apache.org/viewvc?rev=573217&view=rev
Log:
Add getContextPath to ServletHost and use in axis2 binding

Modified:
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
    incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceServlet.java
    incubator/tuscany/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java
    incubator/tuscany/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java
    incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
    incubator/tuscany/java/sca/modules/http-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
    incubator/tuscany/java/sca/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java?rev=573217&r1=573216&r2=573217&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
Thu Sep  6 04:00:42 2007
@@ -97,6 +97,8 @@
             throw new RuntimeException(e); // TODO: better exception
         }
 
+        configContext.setContextRoot(servletHost.getContextPath());
+
         String uri = computeActualURI(BASE_URI, component, contract).normalize().toString();
         if (uri.endsWith("/")) {
             uri = uri.substring(0, uri.length() - 1);

Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceServlet.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceServlet.java?rev=573217&r1=573216&r2=573217&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceServlet.java
(original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceServlet.java
Thu Sep  6 04:00:42 2007
@@ -53,7 +53,6 @@
 public class Axis2ServiceServlet extends AxisServlet {
 
     protected TuscanyListingAgent agent;
-    protected boolean inited;
 
     private static final long serialVersionUID = 1L;
     private static final ServletConfig DUMMY_CONFIG = createDummyServletConfig();
@@ -220,20 +219,6 @@
             }
         };
         return sc;
-    }
-
-    @Override
-    protected void service(HttpServletRequest request, HttpServletResponse response)
-        throws ServletException, IOException {
-        // HACK: Get the correct context root which is not available during init() call
-        if (!inited) {
-            synchronized (configContext) {
-                configContext.setContextRoot(request.getContextPath());
-                inited = true;
-            }
-        }
-
-        super.service(request, response);
     }
 
     @Override

Modified: incubator/tuscany/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java?rev=573217&r1=573216&r2=573217&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java
(original)
+++ incubator/tuscany/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java
Thu Sep  6 04:00:42 2007
@@ -74,5 +74,9 @@
         // For now just select the first one
         return servletHosts.getServletHosts().get(0).getRequestDispatcher(uri);
     }
+
+    public String getContextPath() {
+        return servletHosts.getServletHosts().get(0).getContextPath();
+    }
     
 }

Modified: incubator/tuscany/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java?rev=573217&r1=573216&r2=573217&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java
(original)
+++ incubator/tuscany/java/sca/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java
Thu Sep  6 04:00:42 2007
@@ -71,4 +71,12 @@
      * @throws ServletMappingException
      */
     RequestDispatcher getRequestDispatcher(String uri) throws ServletMappingException;
+
+    /**
+     * Returns the portion of the request URI that indicates the context of the request
+     * 
+     * @return a String specifying the portion of the request URI that indicates the context
of the request
+     */
+    String getContextPath();
+
 }

Modified: incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java?rev=573217&r1=573216&r2=573217&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
(original)
+++ incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
Thu Sep  6 04:00:42 2007
@@ -20,9 +20,11 @@
 package org.apache.tuscany.sca.host.webapp;
 
 import java.io.File;
+import java.lang.reflect.Method;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.logging.Logger;
@@ -54,6 +56,8 @@
     private Map<String, Servlet> servlets;
     private SCADomain scaDomain;
 
+    private String contextPath;
+
     private WebAppServletHost() {
         servlets = new HashMap<String, Servlet>();
     }
@@ -139,9 +143,11 @@
     }
 
     void init(ServletConfig config) throws ServletException {
-        ServletContext servletContext = config.getServletContext();
+
+        initContextPath(config);
 
         // Create an SCA domain object
+        ServletContext servletContext = config.getServletContext();
         String domainURI = "http://localhost/" + servletContext.getServletContextName().replace('
', '.');
         String contributionRoot = null;
         try {
@@ -167,7 +173,32 @@
             servlet.init(config);
         }
     }
-    
+
+    /**
+     * Initializes the contextPath
+     * The 2.5 Servlet API has a getter for this, for pre 2.5 servlet
+     * containers use an init parameter.
+     */
+    @SuppressWarnings("unchecked")
+    protected void initContextPath(ServletConfig config) {
+        if (Collections.list(config.getInitParameterNames()).contains("contextPath")) {
+            contextPath = config.getInitParameter("contextPath");
+        } else {
+            Method m;
+            try {
+                m = config.getClass().getMethod("getContextPath", new Class[]{});
+                try {
+                    contextPath = (String)m.invoke(config, new Object[]{});
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+            } catch (NoSuchMethodException e) {
+                throw new IllegalStateException("'contextPath' init parameter must be set
for pre-2.5 servlet container");
+            }
+        }
+        logger.info("initContextPath: " + contextPath);
+    }
+
     void destroy() {
         
         // Destroy the registered servlets
@@ -179,6 +210,10 @@
         if (scaDomain != null) {
             scaDomain.close();
         }
+    }
+
+    public String getContextPath() {
+        return contextPath;
     }
 
 }

Modified: incubator/tuscany/java/sca/modules/http-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/http-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java?rev=573217&r1=573216&r2=573217&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/http-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
(original)
+++ incubator/tuscany/java/sca/modules/http-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
Thu Sep  6 04:00:42 2007
@@ -309,6 +309,10 @@
         return null;
     }
     
+    public String getContextPath() {
+        return ROOT;
+    }
+
     /**
      * A wrapper to enable use of a WorkScheduler with Jetty
      */

Modified: incubator/tuscany/java/sca/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java?rev=573217&r1=573216&r2=573217&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java
(original)
+++ incubator/tuscany/java/sca/modules/http-tomcat/src/main/java/org/apache/tuscany/sca/http/tomcat/TomcatServer.java
Thu Sep  6 04:00:42 2007
@@ -296,6 +296,10 @@
         return null;
     }
     
+    public String getContextPath() {
+        return "/";
+    }
+
     /**
      * A custom connector that uses our WorkScheduler to schedule
      * worker threads.



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message