geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1367846 - /geronimo/server/branches/3.0/plugins/wab/geronimo-wab/src/main/java/org/apache/geronimo/osgi/web/WebApplicationUtils.java
Date Wed, 01 Aug 2012 02:37:02 GMT
Author: gawor
Date: Wed Aug  1 02:37:02 2012
New Revision: 1367846

URL: http://svn.apache.org/viewvc?rev=1367846&view=rev
Log:
ensure that contextPath is / or always starts with /

Modified:
    geronimo/server/branches/3.0/plugins/wab/geronimo-wab/src/main/java/org/apache/geronimo/osgi/web/WebApplicationUtils.java

Modified: geronimo/server/branches/3.0/plugins/wab/geronimo-wab/src/main/java/org/apache/geronimo/osgi/web/WebApplicationUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/3.0/plugins/wab/geronimo-wab/src/main/java/org/apache/geronimo/osgi/web/WebApplicationUtils.java?rev=1367846&r1=1367845&r2=1367846&view=diff
==============================================================================
--- geronimo/server/branches/3.0/plugins/wab/geronimo-wab/src/main/java/org/apache/geronimo/osgi/web/WebApplicationUtils.java
(original)
+++ geronimo/server/branches/3.0/plugins/wab/geronimo-wab/src/main/java/org/apache/geronimo/osgi/web/WebApplicationUtils.java
Wed Aug  1 02:37:02 2012
@@ -44,8 +44,22 @@ public class WebApplicationUtils {
         if (version != null) {
             properties.put(WABApplicationConstants.WEB_VERSION, version);
         }
-        properties.put(WABApplicationConstants.WEB_CONTEXT_PATH, context.getContextPath());
+        properties.put(WABApplicationConstants.WEB_CONTEXT_PATH, getContextPath(context.getContextPath()));
         return bundle.getBundleContext().registerService(ServletContext.class.getName(),
context, properties);
     }
     
+    private static String getContextPath(String contextPath) {
+        if (contextPath == null) {
+            return "/";
+        }
+        contextPath = contextPath.trim();
+        if (contextPath.length() == 0) {
+            return "/";
+        } else if (!contextPath.startsWith("/")) {
+            return "/" + contextPath;
+        } else {
+            return contextPath;
+        }
+    }
+    
 }



Mime
View raw message