geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r556217 - in /geronimo/server/trunk: configs/jetty6-deployer/src/plan/ modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/ modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/
Date Sat, 14 Jul 2007 03:39:07 GMT
Author: djencks
Date: Fri Jul 13 20:39:06 2007
New Revision: 556217

URL: http://svn.apache.org/viewvc?view=rev&rev=556217
Log:
GERONIMO-3321.  Pay attention to the weirdo jsp-property-group/url-pattern in the jetty deployer

Added:
    geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyJspServletHolder.java
  (with props)
Modified:
    geronimo/server/trunk/configs/jetty6-deployer/src/plan/plan.xml
    geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyDefaultServletHolder.java
    geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyServletHolder.java

Modified: geronimo/server/trunk/configs/jetty6-deployer/src/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/jetty6-deployer/src/plan/plan.xml?view=diff&rev=556217&r1=556216&r2=556217
==============================================================================
--- geronimo/server/trunk/configs/jetty6-deployer/src/plan/plan.xml (original)
+++ geronimo/server/trunk/configs/jetty6-deployer/src/plan/plan.xml Fri Jul 13 20:39:06 2007
@@ -24,7 +24,6 @@
         <attribute name="defaultSessionTimeoutSeconds">1800</attribute>
         <attribute name="defaultWelcomeFiles">index.html,index.htm,index.jsp</attribute>
         <attribute name="jettyContainerObjectName">?name=JettyWebContainer</attribute>
-        <attribute name="jspServletClassName">org.apache.jasper.servlet.JspServlet</attribute>
         <attribute name="defaultLocaleEncodingMappings">
 ar=ISO-8859-6
 be=ISO-8859-5
@@ -73,10 +72,10 @@
             <pattern>
                 <name>StaticContent</name>
             </pattern>
-            <pattern>
-                <name>JSPServlet</name>
-            </pattern>
         </references>
+        <reference name="JspServlet">
+            <name>JSPServlet</name>
+        </reference>
         <reference name="PojoWebServiceTemplate">
             <name>POJOTemplate</name>
         </reference>
@@ -161,7 +160,7 @@
         <attribute name="servletMappings">/</attribute>
     </gbean>
 
-    <gbean name="JSPServlet" class="org.apache.geronimo.jetty6.JettyDefaultServletHolder">
+    <gbean name="JSPServlet" class="org.apache.geronimo.jetty6.JettyJspServletHolder">
         <attribute name="servletName">jsp</attribute>
         <attribute name="servletClass">org.apache.jasper.servlet.JspServlet</attribute>
         <attribute name="loadOnStartup">0</attribute>

Modified: geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java?view=diff&rev=556217&r1=556216&r2=556217
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
Fri Jul 13 20:39:06 2007
@@ -71,6 +71,7 @@
 import org.apache.geronimo.jetty6.JettyServletHolder;
 import org.apache.geronimo.jetty6.JettyWebAppContext;
 import org.apache.geronimo.jetty6.NonAuthenticator;
+import org.apache.geronimo.jetty6.JettyJspServletHolder;
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
@@ -106,6 +107,7 @@
 import org.apache.geronimo.xbeans.javaee.WebAppDocument;
 import org.apache.geronimo.xbeans.javaee.WebAppType;
 import org.apache.geronimo.xbeans.javaee.WelcomeFileListType;
+import org.apache.geronimo.xbeans.javaee.JspPropertyGroupType;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.mortbay.jetty.security.BasicAuthenticator;
@@ -121,6 +123,7 @@
     private final static Log log = LogFactory.getLog(JettyModuleBuilder.class);
     private final Environment defaultEnvironment;
     private final AbstractNameQuery jettyContainerObjectName;
+    private final JettyJspServletHolder jspServlet;
     private final Collection defaultServlets;
     private final Collection defaultFilters;
     private final Collection defaultFilterMappings;
@@ -134,32 +137,31 @@
     private final Map<String, String> defaultMimeTypeMappings;
 
     private static final String JETTY_NAMESPACE = JettyWebAppDocument.type.getDocumentElementName().getNamespaceURI();
-    private String jspServletClassName;
 
     public JettyModuleBuilder(Environment defaultEnvironment,
-            Integer defaultSessionTimeoutSeconds,
-            List<String> defaultWelcomeFiles,
-            AbstractNameQuery jettyContainerName,
-            String jspServletClassName,
-            Collection defaultServlets,
-            Collection defaultFilters,
-            Collection defaultFilterMappings,
-            Map<String, String> defaultLocaleEncodingMappings,
-            Map<String, String> defaultMimeTypeMappings,
-            Object pojoWebServiceTemplate,
-            Collection<WebServiceBuilder> webServiceBuilder,
-            Collection clusteringBuilders,
-            Collection securityBuilders,
-            Collection serviceBuilders,
-            NamingBuilder namingBuilders,
-            Collection<ModuleBuilderExtension> moduleBuilderExtensions,
-            ResourceEnvironmentSetter resourceEnvironmentSetter,
-            Kernel kernel) throws GBeanNotFoundException {
+                              Integer defaultSessionTimeoutSeconds,
+                              List<String> defaultWelcomeFiles,
+                              AbstractNameQuery jettyContainerName,
+                              JettyJspServletHolder jspServlet,
+                              Collection defaultServlets,
+                              Collection defaultFilters,
+                              Collection defaultFilterMappings,
+                              Map<String, String> defaultLocaleEncodingMappings,
+                              Map<String, String> defaultMimeTypeMappings,
+                              Object pojoWebServiceTemplate,
+                              Collection<WebServiceBuilder> webServiceBuilder,
+                              Collection clusteringBuilders,
+                              Collection securityBuilders,
+                              Collection serviceBuilders,
+                              NamingBuilder namingBuilders,
+                              Collection<ModuleBuilderExtension> moduleBuilderExtensions,
+                              ResourceEnvironmentSetter resourceEnvironmentSetter,
+                              Kernel kernel) throws GBeanNotFoundException {
         super(kernel, securityBuilders, serviceBuilders, namingBuilders, resourceEnvironmentSetter,
webServiceBuilder, moduleBuilderExtensions);
         this.defaultEnvironment = defaultEnvironment;
         this.defaultSessionTimeoutSeconds = (defaultSessionTimeoutSeconds == null) ? 30 *
60 : defaultSessionTimeoutSeconds;
         this.jettyContainerObjectName = jettyContainerName;
-        this.jspServletClassName = jspServletClassName;
+        this.jspServlet = jspServlet;
         this.defaultServlets = defaultServlets;
         this.defaultFilters = defaultFilters;
         this.defaultFilterMappings = defaultFilterMappings;
@@ -404,14 +406,18 @@
             configureErrorPages(webApp, webModuleData);
 
             // configure tag libs.
-            configureTagLibs(module, webApp, webModuleData);
+            Set<String> knownServletMappings = new HashSet<String>();
+            Map<String, Set<String>> servletMappings = new HashMap<String,
Set<String>>();
+            if (jspServlet != null) {
+                configureTagLibs(module, webApp, webModuleData, servletMappings, knownServletMappings,
jspServlet.getServletName());
+                GBeanData jspServletData = configureDefaultServlet(jspServlet, earContext,
moduleName, knownServletMappings, moduleContext);
+                jspServletData.setAttribute("servletMappings", new HashSet<String>(knownServletMappings));
+            }
 
             // configure login configs.
             configureLoginConfigs(module, webApp, jettyWebApp, webModuleData);
 
             // Make sure that servlet mappings point to available servlets and never add
a duplicate pattern.
-            Set<String> knownServletMappings = new HashSet<String>();
-            Map<String, Set<String>> servletMappings = new HashMap<String,
Set<String>>();
 
             buildServletMappings(module, webApp, servletMappings, knownServletMappings);
 
@@ -523,17 +529,22 @@
 
     private void addDefaultServletsGBeans(EARContext earContext, EARContext moduleContext,
AbstractName moduleName, Set knownServletMappings) throws GBeanNotFoundException, GBeanAlreadyExistsException
{
         for (Object defaultServlet : defaultServlets) {
-            GBeanData servletGBeanData = getGBeanData(kernel, defaultServlet);
-            AbstractName defaultServletObjectName = earContext.getNaming().createChildName(moduleName,
(String) servletGBeanData.getAttribute("servletName"), NameFactory.SERVLET);
-            servletGBeanData.setAbstractName(defaultServletObjectName);
-            servletGBeanData.setReferencePattern("JettyServletRegistration", moduleName);
-            Set<String> defaultServletMappings = new HashSet<String>((Collection<String>)
servletGBeanData.getAttribute("servletMappings"));
-            defaultServletMappings.removeAll(knownServletMappings);
-            servletGBeanData.setAttribute("servletMappings", defaultServletMappings);
-            moduleContext.addGBean(servletGBeanData);
+            configureDefaultServlet(defaultServlet, earContext, moduleName, knownServletMappings,
moduleContext);
         }
     }
 
+    private GBeanData configureDefaultServlet(Object defaultServlet, EARContext earContext,
AbstractName moduleName, Set knownServletMappings, EARContext moduleContext) throws GBeanNotFoundException,
GBeanAlreadyExistsException {
+        GBeanData servletGBeanData = getGBeanData(kernel, defaultServlet);
+        AbstractName defaultServletObjectName = earContext.getNaming().createChildName(moduleName,
(String) servletGBeanData.getAttribute("servletName"), NameFactory.SERVLET);
+        servletGBeanData.setAbstractName(defaultServletObjectName);
+        servletGBeanData.setReferencePattern("JettyServletRegistration", moduleName);
+        Set<String> defaultServletMappings = new HashSet<String>((Collection<String>)
servletGBeanData.getAttribute("servletMappings"));
+        defaultServletMappings.removeAll(knownServletMappings);
+        servletGBeanData.setAttribute("servletMappings", defaultServletMappings);
+        moduleContext.addGBean(servletGBeanData);
+        return servletGBeanData;
+    }
+
     private void addFiltersGBeans(EARContext earContext, EARContext moduleContext, AbstractName
moduleName, WebAppType webApp) throws GBeanAlreadyExistsException {
         FilterType[] filterArray = webApp.getFilterArray();
         for (FilterType filterType : filterArray) {
@@ -663,27 +674,31 @@
                         "' but no such servlet was found!");
             }
             UrlPatternType[] urlPatterns = servletMappingType.getUrlPatternArray();
-            for (UrlPatternType patternType : urlPatterns) {
-                String urlPattern = patternType.getStringValue().trim();
-                if (!urlPattern.startsWith("*") && !urlPattern.startsWith("/")) {
-                    urlPattern = "/" + urlPattern;
-                }
-                if (!knownServletMappings.contains(urlPattern)) {
-                    knownServletMappings.add(urlPattern);
-                    checkString(urlPattern);
-                    Set<String> urlsForServlet = servletMappings.get(servletName);
-                    if (urlsForServlet == null) {
-                        urlsForServlet = new HashSet<String>();
-                        servletMappings.put(servletName, urlsForServlet);
-                    }
-                    urlsForServlet.add(urlPattern);
-                }
-            }
+            addMappingsForServlet(servletName, urlPatterns, knownServletMappings, servletMappings);
         }
 
         return servletMappings;
     }
 
+    private void addMappingsForServlet(String servletName, UrlPatternType[] urlPatterns,
Set<String> knownServletMappings, Map<String, Set<String>> servletMappings)
throws DeploymentException {
+        for (UrlPatternType patternType : urlPatterns) {
+            String urlPattern = patternType.getStringValue().trim();
+            if (!urlPattern.startsWith("*") && !urlPattern.startsWith("/")) {
+                urlPattern = "/" + urlPattern;
+            }
+            if (!knownServletMappings.contains(urlPattern)) {
+                knownServletMappings.add(urlPattern);
+                checkString(urlPattern);
+                Set<String> urlsForServlet = servletMappings.get(servletName);
+                if (urlsForServlet == null) {
+                    urlsForServlet = new HashSet<String>();
+                    servletMappings.put(servletName, urlsForServlet);
+                }
+                urlsForServlet.add(urlPattern);
+            }
+        }
+    }
+
     private void configureLoginConfigs(Module module, WebAppType webApp, JettyWebAppType
jettyWebApp, GBeanData webModuleData) throws DeploymentException {
         LoginConfigType[] loginConfigArray = webApp.getLoginConfigArray();
         if (loginConfigArray.length > 1) {
@@ -719,7 +734,7 @@
         }
     }
 
-    private void configureTagLibs(Module module, WebAppType webApp, GBeanData webModuleData)
throws DeploymentException {
+    private void configureTagLibs(Module module, WebAppType webApp, GBeanData webModuleData,
Map<String, Set<String>> servletMappings, Set<String> knownServletMappings,
String jspServletName) throws DeploymentException {
         JspConfigType[] jspConfigArray = webApp.getJspConfigArray();
         if (jspConfigArray.length > 1) {
             throw new DeploymentException("Web app " + module.getName() + " cannot have more
than one jsp-config element.  Currently has " + jspConfigArray.length + " jsp-config elements.");
@@ -730,6 +745,10 @@
             for (TaglibType taglib : tagLibArray) {
                 tagLibMap.put(taglib.getTaglibUri().getStringValue().trim(), taglib.getTaglibLocation().getStringValue().trim());
             }
+            for (JspPropertyGroupType propertyGroup: aJspConfigArray.getJspPropertyGroupArray())
{
+                UrlPatternType[] urlPatterns = propertyGroup.getUrlPatternArray();
+                addMappingsForServlet(jspServletName, urlPatterns, knownServletMappings,
servletMappings);
+            }
         }
         webModuleData.setAttribute("tagLibMap", tagLibMap);
     }
@@ -940,8 +959,7 @@
         } else if (servletType.isSetJspFile()) {
             servletData = new GBeanData(servletAbstractName, JettyServletHolder.GBEAN_INFO);
             servletData.setAttribute("jspFile", servletType.getJspFile().getStringValue().trim());
-            //TODO MAKE THIS CONFIGURABLE!!! Jetty uses the servlet mapping set up from the
default-web.xml
-            servletData.setAttribute("servletClass", jspServletClassName);
+            servletData.setAttribute("servletClass", jspServlet.getServletClassName());
             initParams.put("development", "false");
         } else {
             throw new DeploymentException("Neither servlet class nor jsp file is set for
" + servletName); // TODO identify web app in message
@@ -996,7 +1014,7 @@
         infoBuilder.addAttribute("defaultLocaleEncodingMappings", Map.class, true, true);
         infoBuilder.addAttribute("defaultMimeTypeMappings", Map.class, true, true);
         infoBuilder.addAttribute("jettyContainerObjectName", AbstractNameQuery.class, true,
true);
-        infoBuilder.addAttribute("jspServletClassName", String.class, true, true);
+        infoBuilder.addReference("JspServlet", JettyJspServletHolder.class, NameFactory.SERVLET_TEMPLATE);
         infoBuilder.addReference("DefaultServlets", JettyDefaultServletHolder.class, NameFactory.SERVLET_TEMPLATE);
         infoBuilder.addReference("DefaultFilters", Object.class);
         infoBuilder.addReference("DefaultFilterMappings", Object.class);
@@ -1016,7 +1034,7 @@
                 "defaultSessionTimeoutSeconds",
                 "defaultWelcomeFiles",
                 "jettyContainerObjectName",
-                "jspServletClassName",
+                "JspServlet",
                 "DefaultServlets",
                 "DefaultFilters",
                 "DefaultFilterMappings",

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyDefaultServletHolder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyDefaultServletHolder.java?view=diff&rev=556217&r1=556216&r2=556217
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyDefaultServletHolder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyDefaultServletHolder.java
Fri Jul 13 20:39:06 2007
@@ -36,7 +36,7 @@
     public JettyDefaultServletHolder() {
     }
 
-    public JettyDefaultServletHolder(String objectName, String servletName, String servletClassName,
String jspFile, Map initParams, Integer loadOnStartup, Set servletMappings, String runAsRole,
JettyServletRegistration context) throws Exception {
+    public JettyDefaultServletHolder(String objectName, String servletName, String servletClassName,
String jspFile, Map initParams, Integer loadOnStartup, Set<String> servletMappings,
String runAsRole, JettyServletRegistration context) throws Exception {
         super(objectName, servletName, servletClassName, jspFile, initParams, loadOnStartup,
servletMappings, runAsRole, context);
     }
 

Added: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyJspServletHolder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyJspServletHolder.java?view=auto&rev=556217
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyJspServletHolder.java
(added)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyJspServletHolder.java
Fri Jul 13 20:39:06 2007
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.jetty6;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JettyJspServletHolder extends JettyServletHolder {
+
+    public JettyJspServletHolder() {
+    }
+
+    public JettyJspServletHolder(String objectName, String servletName, String servletClassName,
String jspFile, Map initParams, Integer loadOnStartup, Set servletMappings, String runAsRole,
JettyServletRegistration context) throws Exception {
+        super(objectName, servletName, servletClassName, jspFile, initParams, loadOnStartup,
servletMappings, runAsRole, context);
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(JettyJspServletHolder.class,
JettyServletHolder.GBEAN_INFO, NameFactory.SERVLET_TEMPLATE);
+
+        GBEAN_INFO = infoBuilder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+
+}

Propchange: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyJspServletHolder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyJspServletHolder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyJspServletHolder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyServletHolder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyServletHolder.java?view=diff&rev=556217&r1=556216&r2=556217
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyServletHolder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyServletHolder.java
Fri Jul 13 20:39:06 2007
@@ -86,6 +86,10 @@
         return servletHolder.getName();
     }
 
+    public String getServletClassName() {
+        return servletHolder.getClassName();
+    }
+
     public String getObjectName() {
         return objectName;
     }



Mime
View raw message