tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r656539 - in /incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp: WebAppServletHost.java jsp/ReferenceTag.java
Date Thu, 15 May 2008 08:18:10 GMT
Author: antelder
Date: Thu May 15 01:18:10 2008
New Revision: 656539

URL: http://svn.apache.org/viewvc?rev=656539&view=rev
Log:
TUSCANY-2320, interim context path fix while waiting for feedback from user

Modified:
    incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
    incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/jsp/ReferenceTag.java

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=656539&r1=656538&r2=656539&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 May 15 01:18:10 2008
@@ -26,6 +26,7 @@
 import java.net.URI;
 import java.net.URL;
 import java.net.UnknownHostException;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.logging.Logger;
@@ -206,19 +207,10 @@
     }
 
     public void init(ServletConfig config) throws ServletException {
-        ServletContext servletContext = config.getServletContext();
-
-        init(servletContext);
-
-        // Initialize the registered Servlets
-        for (Servlet servlet : servlets.values()) {
-            servlet.init(config);
-        }
-    }
 
-    public void init(ServletContext servletContext) throws ServletException {
+        ServletContext servletContext = config.getServletContext();
         if (servletContext.getAttribute(SCA_DOMAIN_ATTRIBUTE) == null) {
-            initContextPath(servletContext);
+            initContextPath(config);
             String domainURI = "http://localhost/" + contextPath;
             contributionRoot = getContributionRoot(servletContext);
             // logger.info("Contribution: " + contributionRoot);
@@ -226,6 +218,11 @@
             this.scaDomain = SCADomain.newInstance(domainURI, contributionRoot);
             servletContext.setAttribute(SCA_DOMAIN_ATTRIBUTE, scaDomain);
         }
+
+        // Initialize the registered Servlets
+        for (Servlet servlet : servlets.values()) {
+            servlet.init(config);
+        }
     }
 
     protected String getContributionRoot(ServletContext servletContext) {
@@ -271,19 +268,20 @@
      * containers use an init parameter.
      */
     @SuppressWarnings("unchecked")
-    public void initContextPath(ServletContext context) {
-        // The getContextPath() is introduced since Servlet 2.5
-        Method m;
-        try {
-            // Try to get the method anyway since some ServletContext impl has this method
even before 2.5
-            m = context.getClass().getMethod("getContextPath", new Class[] {});
-            contextPath = (String)m.invoke(context, new Object[] {});
-        } catch (Exception e) {
-            contextPath = context.getInitParameter("contextPath");
-            if (contextPath == null) {
+    public void initContextPath(ServletConfig config) {
+        
+        if (Collections.list(config.getInitParameterNames()).contains("contextPath")) {
+            contextPath = config.getInitParameter("contextPath");
+        } else {
+            // The getContextPath() is introduced since Servlet 2.5
+            ServletContext context = config.getServletContext();
+            try {
+                // Try to get the method anyway since some ServletContext impl has this method
even before 2.5
+                Method m = context.getClass().getMethod("getContextPath", new Class[] {});
+                contextPath = (String)m.invoke(context, new Object[] {});
+            } catch (Exception e) {
                 logger.warning("Servlet level is: " + context.getMajorVersion() + "." + context.getMinorVersion());
-                throw new IllegalStateException(
-                                                "'contextPath' init parameter must be set
for pre-2.5 servlet container");
+                throw new IllegalStateException("'contextPath' init parameter must be set
for pre-2.5 servlet container");
             }
         }
 

Modified: incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/jsp/ReferenceTag.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/jsp/ReferenceTag.java?rev=656539&r1=656538&r2=656539&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/jsp/ReferenceTag.java
(original)
+++ incubator/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/jsp/ReferenceTag.java
Thu May 15 01:18:10 2008
@@ -47,13 +47,13 @@
 
     public int doEndTag() throws JspException {
 
-        ServletContext servletContext = pageContext.getServletContext();
         try {
-            WebAppServletHost.getInstance().init(servletContext);
+            WebAppServletHost.getInstance().init(pageContext.getServletConfig());
         } catch (ServletException e) {
             throw new JspException("Exception initializing Tuscany webapp: " + e, e);
         }
  
+        ServletContext servletContext = pageContext.getServletContext();
         SCADomain scaDomain = (SCADomain)servletContext.getAttribute(WebAppServletHost.SCA_DOMAIN_ATTRIBUTE);
         if (scaDomain == null) {
             throw new JspException("SCADomain is null. Check Tuscany configuration in web.xml");



Mime
View raw message