geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1001341 - in /geronimo/server/trunk/plugins/tomcat: geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/ geronimo-tomcat7-builder/src/main/xsd/ geronimo-tomcat7-builder/src/test/java/org/apache/geronimo/tomcat/depl...
Date Sun, 26 Sep 2010 02:35:01 GMT
Author: xuhaihong
Date: Sun Sep 26 02:35:01 2010
New Revision: 1001341

URL: http://svn.apache.org/viewvc?rev=1001341&view=rev
Log:
GERONIMO-5557 Add a similar context element in the schema, currently we could use this elements
for most context level attributes configurations and context parameters. (Based on the patch
from viola.lu)

Added:
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/resources/plans/plan-context.xml
  (with props)
Modified:
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/xsd/geronimo-tomcat-2.0.1.xsd
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/java/org/apache/geronimo/tomcat/deployment/MockWebServiceBuilder.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?rev=1001341&r1=1001340&r2=1001341&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
Sun Sep 26 02:35:01 2010
@@ -24,7 +24,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
 import java.net.URL;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -52,7 +51,6 @@ import org.apache.geronimo.gbean.Abstrac
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.ReferencePatterns;
 import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.gbean.annotation.ParamAttribute;
 import org.apache.geronimo.gbean.annotation.ParamReference;
@@ -96,6 +94,8 @@ import org.apache.geronimo.xbeans.geroni
 import org.apache.geronimo.xbeans.geronimo.jaspi.JaspiServerAuthConfigType;
 import org.apache.geronimo.xbeans.geronimo.jaspi.JaspiServerAuthContextType;
 import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatAuthenticationType;
+import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatContextType;
+import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatParameterType;
 import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatWebAppDocument;
 import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatWebAppType;
 import org.apache.geronimo.xbeans.geronimo.web.tomcat.config.GerTomcatDocument;
@@ -108,6 +108,8 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
 
 /**
  * @version $Rev:385659 $ $Date$
@@ -119,7 +121,8 @@ public class TomcatModuleBuilder extends
 
     private static final String TOMCAT_NAMESPACE = TomcatWebAppDocument.type.getDocumentElementName().getNamespaceURI();
     private static final Map<String, String> NAMESPACE_UPDATES = new HashMap<String,
String>();
-    private static final Set<String> INGORE_ELEMENT_NAMES = new HashSet<String>();
+    private static final Set<String> INGORED_ELEMENT_NAMES = new HashSet<String>();
+    private static final Set<String> INGORED_CONTEXT_ATTRIBUTE_NAMES = new HashSet<String>();
     static {
         NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/web", "http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1");
         NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/j2ee/web-1.1", "http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1");
@@ -131,9 +134,24 @@ public class TomcatModuleBuilder extends
         NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-2.0", "http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-2.0.1");
         NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/web/tomcat/config", "http://geronimo.apache.org/xml/ns/j2ee/web/tomcat/config-1.0");
 
-        INGORE_ELEMENT_NAMES.add("context-priority-classloader");
-        INGORE_ELEMENT_NAMES.add("configId");
-        INGORE_ELEMENT_NAMES.add("parentId");
+        INGORED_ELEMENT_NAMES.add("context-priority-classloader");
+        INGORED_ELEMENT_NAMES.add("configId");
+        INGORED_ELEMENT_NAMES.add("parentId");
+
+        INGORED_CONTEXT_ATTRIBUTE_NAMES.add("className".toLowerCase());
+        INGORED_CONTEXT_ATTRIBUTE_NAMES.add("xmlNamespaceAware".toLowerCase());
+        INGORED_CONTEXT_ATTRIBUTE_NAMES.add("processTlds".toLowerCase());
+        INGORED_CONTEXT_ATTRIBUTE_NAMES.add("unpackWAR".toLowerCase());
+        INGORED_CONTEXT_ATTRIBUTE_NAMES.add("xmlValidation".toLowerCase());
+        INGORED_CONTEXT_ATTRIBUTE_NAMES.add("path");
+        INGORED_CONTEXT_ATTRIBUTE_NAMES.add("useNaming".toLowerCase());
+        INGORED_CONTEXT_ATTRIBUTE_NAMES.add("javaVMs".toLowerCase());
+        INGORED_CONTEXT_ATTRIBUTE_NAMES.add("server");
+        INGORED_CONTEXT_ATTRIBUTE_NAMES.add("j2EEApplication".toLowerCase());
+        INGORED_CONTEXT_ATTRIBUTE_NAMES.add("j2EEServer".toLowerCase());
+        INGORED_CONTEXT_ATTRIBUTE_NAMES.add("path");
+        INGORED_CONTEXT_ATTRIBUTE_NAMES.add("delegate");
+        INGORED_CONTEXT_ATTRIBUTE_NAMES.add("docBase".toLowerCase());
     }
 
     private final Environment defaultEnvironment;
@@ -395,7 +413,7 @@ public class TomcatModuleBuilder extends
                 XmlObject webPlan = new GenericToSpecificPlanConverter(GerTomcatDocument.type.getDocumentElementName().getNamespaceURI(),
                         TomcatWebAppDocument.type.getDocumentElementName().getNamespaceURI(),
"tomcat").convertToSpecificPlan(rawPlan);
                 tomcatWebApp = (TomcatWebAppType) webPlan.changeType(TomcatWebAppType.type);
-                XmlBeansUtil.validateDD(tomcatWebApp, INGORE_ELEMENT_NAMES);
+                XmlBeansUtil.validateDD(tomcatWebApp, INGORED_ELEMENT_NAMES);
             } else {
                 tomcatWebApp = createDefaultPlan();
             }
@@ -441,6 +459,7 @@ public class TomcatModuleBuilder extends
         }
         try {
             moduleContext.addGBean(webModuleData);
+            Map<String, String> contextAttributes = new HashMap<String, String>();
             webModuleData.setAttribute("contextPath", contextPath);
             // unsharableResources, applicationManagedSecurityResources
             GBeanResourceEnvironmentBuilder rebuilder = new GBeanResourceEnvironmentBuilder(webModuleData);
@@ -464,16 +483,23 @@ public class TomcatModuleBuilder extends
                 String virtualServer = tomcatWebApp.getHost().trim();
                 webModuleData.setAttribute("virtualServer", virtualServer);
             }
+
             if (tomcatWebApp.isSetCrossContext()) {
-                webModuleData.setAttribute("crossContext", Boolean.TRUE);
+                //webModuleData.setAttribute("crossContext", Boolean.TRUE);
+                contextAttributes.put("crossContext", "true");
             }
+
             if (tomcatWebApp.isSetWorkDir()) {
                 String workDir = tomcatWebApp.getWorkDir();
-                webModuleData.setAttribute("workDir", workDir);
+                //webModuleData.setAttribute("workDir", workDir);
+                contextAttributes.put("workDir", workDir);
             }
+
             if (tomcatWebApp.isSetDisableCookies()) {
-                webModuleData.setAttribute("disableCookies", Boolean.TRUE);
+                //webModuleData.setAttribute("disableCookies", Boolean.TRUE);
+                contextAttributes.put("cookies", "false");
             }
+
             if (tomcatWebApp.isSetTomcatRealm()) {
                 String tomcatRealm = tomcatWebApp.getTomcatRealm().trim();
                 AbstractName realmName = earContext.getNaming().createChildName(moduleName,
tomcatRealm, RealmGBean.GBEAN_INFO.getJ2eeType());
@@ -518,13 +544,53 @@ public class TomcatModuleBuilder extends
 
             webModule.getSharedContext().put(WebModule.WEB_APP_INFO, webAppInfoBuilder);
 
+            //Add context attributes and parameters
+            if (tomcatWebApp.isSetContext()) {
+                TomcatContextType context = tomcatWebApp.getContext();
+                NamedNodeMap namedNodeMap = context.getDomNode().getAttributes();
+                for (int i = 0; i < namedNodeMap.getLength(); i++) {
+                    Node node = namedNodeMap.item(i);
+                    String attributeName = node.getNodeName();
+                    if (INGORED_CONTEXT_ATTRIBUTE_NAMES.contains(attributeName.toLowerCase()))
{
+                        if (log.isWarnEnabled()) {
+                            log.warn("Context attribute " + attributeName + " in the geronimo-web.xml
is ignored, as it is not support or Geronimo has already configured it");
+                        }
+                        continue;
+                    }
+                    if (contextAttributes.containsKey(attributeName)) {
+                        if (log.isWarnEnabled()) {
+                            log.warn("Context attribute " + attributeName
+                                    + " on the context element in geronimo-web.xml is ignored,
as it has been explicitly configured with other elements in the geronimo-web.xml file");
+                        }
+                        continue;
+                    }
+                    contextAttributes.put(node.getNodeName(), node.getNodeValue());
+                }
+                for (TomcatParameterType parameterType : context.getParameterArray()) {
+                    if (webAppInfo.contextParams.containsKey(parameterType.getName()) &&
!parameterType.getOverride()) {
+                        if (log.isWarnEnabled()) {
+                            log.warn("Context parameter from geronimo-web.xml is ignored,
as a same name context paramter " + parameterType.getName() + " = "
+                                    + webAppInfo.contextParams.get(parameterType.getName())
+ " in web.xml, configure override with true to make the value take effect.");
+                        }
+                        continue;
+                    }
+                    webAppInfo.contextParams.put(parameterType.getName(), parameterType.getValue());
+                }
+            }
+            /**
+             * The old geronimo-web.xml also support to configure some context attributes
individually,
+             * let's override them in the contextAttributes
+             */
+
+            webModuleData.setAttribute("contextAttributes", contextAttributes);
+
 //            Collection<String> listeners = new ArrayList<String>();
 //            webModuleData.setAttribute("listenerClassNames", listeners);
 
             //Handle the role permissions and webservices on the servlets.
             List<org.apache.openejb.jee.Servlet> servletTypes = webApp.getServlet();
             Map<String, AbstractName> webServices = new HashMap<String, AbstractName>();
-            Class baseServletClass;
+            Class<?> baseServletClass;
             try {
                 baseServletClass = webBundle.loadClass(Servlet.class.getName());
             } catch (ClassNotFoundException e) {

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/xsd/geronimo-tomcat-2.0.1.xsd
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/xsd/geronimo-tomcat-2.0.1.xsd?rev=1001341&r1=1001340&r2=1001341&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/xsd/geronimo-tomcat-2.0.1.xsd
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/xsd/geronimo-tomcat-2.0.1.xsd
Sun Sep 26 02:35:01 2010
@@ -178,6 +178,15 @@
                     </xs:documentation>
                 </xs:annotation>
             </xs:element>
+            <xs:element name="context" type="tomcat:contextType" minOccurs="0">
+                <xs:annotation>
+                    <xs:documentation>
+                        The context element provides the same function as used in
+                        Tomcat, it supports context level attributes and context
+                        parameters.
+                    </xs:documentation>
+                </xs:annotation>
+            </xs:element>
             <xs:element name="valve-chain" type="xs:string" minOccurs="0">
                 <xs:annotation>
                     <xs:documentation>
@@ -293,5 +302,17 @@
             <xs:element ref="jaspi:serverAuthModule"/>
         </xs:choice>
     </xs:complexType>
-
+    
+    <xs:complexType name="contextType">        
+        <xs:sequence>
+            <xs:element name="parameter" type="tomcat:parameterType" minOccurs="0" maxOccurs="unbounded"/>
+        </xs:sequence>
+        <xs:anyAttribute processContents="skip"/>
+    </xs:complexType>
+    
+    <xs:complexType name="parameterType">        
+        <xs:attribute name="name" type="xs:string" />
+        <xs:attribute name="value" type="xs:string" />
+        <xs:attribute name="override" type="xs:boolean" default="false"/>
+    </xs:complexType>
 </xs:schema>

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/java/org/apache/geronimo/tomcat/deployment/MockWebServiceBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/java/org/apache/geronimo/tomcat/deployment/MockWebServiceBuilder.java?rev=1001341&r1=1001340&r2=1001341&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/java/org/apache/geronimo/tomcat/deployment/MockWebServiceBuilder.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/java/org/apache/geronimo/tomcat/deployment/MockWebServiceBuilder.java
Sun Sep 26 02:35:01 2010
@@ -22,14 +22,12 @@ import org.apache.geronimo.common.Deploy
 import org.apache.geronimo.deployment.DeploymentContext;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
-import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.webservices.SerializableWebServiceContainerFactoryGBean;
-
 import org.osgi.framework.Bundle;
 
 /**

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java?rev=1001341&r1=1001340&r2=1001341&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java
Sun Sep 26 02:35:01 2010
@@ -22,7 +22,7 @@ import java.util.Arrays;
 import java.util.Collections;
 
 import junit.framework.TestCase;
-import org.apache.geronimo.deployment.NamespaceDrivenBuilder;
+
 import org.apache.geronimo.deployment.service.GBeanBuilder;
 import org.apache.geronimo.deployment.xbeans.ArtifactType;
 import org.apache.geronimo.deployment.xbeans.EnvironmentType;
@@ -50,6 +50,7 @@ import org.osgi.framework.Bundle;
 import org.osgi.service.packageadmin.ExportedPackage;
 import org.osgi.service.packageadmin.PackageAdmin;
 import org.osgi.service.packageadmin.RequiredBundle;
+import org.w3c.dom.NamedNodeMap;
 
 /**
  */
@@ -180,4 +181,12 @@ public class PlanParsingTest extends Tes
         XmlBeansUtil.validateDD(tomcatWebAppType);
     }
 
+    public void testContextAttributes() throws Exception {
+        URL resourceURL = classLoader.getResource("plans/plan-context.xml");
+        File resourcePlan = new File(resourceURL.getFile());
+        assertTrue(resourcePlan.exists());
+        TomcatWebAppType tomcatWebApp = builder.getTomcatWebApp(resourcePlan, null, true,
null, null);
+        NamedNodeMap  namedNodeMap = tomcatWebApp.getContext().getDomNode().getAttributes();
+        assertEquals(2, namedNodeMap.getLength());
+    }
 }

Added: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/resources/plans/plan-context.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/resources/plans/plan-context.xml?rev=1001341&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/resources/plans/plan-context.xml
(added)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/resources/plans/plan-context.xml
Sun Sep 26 02:35:01 2010
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+-->
+
+<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web/tomcat-2.0.1">
+    <context-root>/test</context-root>
+    <context a="b" c="d"></context>
+</web-app>

Propchange: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/resources/plans/plan-context.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/resources/plans/plan-context.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/test/resources/plans/plan-context.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java?rev=1001341&r1=1001340&r2=1001341&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
Sun Sep 26 02:35:01 2010
@@ -30,6 +30,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.Map.Entry;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
 
@@ -84,6 +85,7 @@ import org.apache.geronimo.webservices.W
 import org.apache.geronimo.webservices.WebServiceContainerInvoker;
 import org.apache.naming.resources.FileDirContext;
 import org.apache.tomcat.InstanceManager;
+import org.apache.tomcat.util.IntrospectionUtils;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceRegistration;
 
@@ -287,13 +289,20 @@ public class GeronimoStandardContext ext
         pipelineInitialized = true;
         this.webServiceMap = ctx.getWebServices();
 
-        this.setCrossContext(ctx.isCrossContext());
+        Map<String, String> contextAttributes = ctx.getContextAttributes();
 
-        this.setWorkDir(ctx.getWorkDir());
-
-        super.setAllowLinking(allowLinking);
+        if (!ctx.getContextAttributes().containsKey("allowLinking")) {
+            contextAttributes.put("allowLinking", String.valueOf(allowLinking));
+        }
 
-        this.setCookies(!ctx.isDisableCookies());
+        //Set context attributes via reflection
+        for (Map.Entry<String, String> entry : contextAttributes.entrySet()) {
+            if (!IntrospectionUtils.setProperty(this, entry.getKey(), entry.getValue()))
{
+                if (logger.isWarnEnabled()) {
+                    logger.warn("Fail to configure attribute " + entry.getKey() + " with
value " + entry.getValue() + ", please check whether the attribute exists or is typo correctly");
+                }
+            }
+        }
 
         //Set the Dispatch listener
         this.addInstanceListener(DispatchListener.class.getName());

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java?rev=1001341&r1=1001340&r2=1001341&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java
Sun Sep 26 02:35:01 2010
@@ -23,8 +23,6 @@ import java.util.Set;
 
 import javax.transaction.UserTransaction;
 
-import org.apache.geronimo.web.info.WebAppInfo;
-import org.apache.tomcat.InstanceManager;
 import org.apache.catalina.Context;
 import org.apache.catalina.Manager;
 import org.apache.catalina.Realm;
@@ -33,6 +31,8 @@ import org.apache.catalina.ha.CatalinaCl
 import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.tomcat.util.SecurityHolder;
+import org.apache.geronimo.web.info.WebAppInfo;
+import org.apache.tomcat.InstanceManager;
 import org.osgi.framework.Bundle;
 
 /**
@@ -70,7 +70,7 @@ public interface TomcatContext {
     Valve getClusteredValve();
 
     List getValveChain();
-    
+
     List getLifecycleListenerChain();
 
     CatalinaCluster getCluster();
@@ -90,10 +90,12 @@ public interface TomcatContext {
     Bundle getBundle();
 
     String getModulePath();
-    
+
     String getDeploymentDescriptor();
-    
+
     Collection<String> getListeners();
 
     WebAppInfo getWebAppInfo();
+
+    Map<String, String> getContextAttributes();
 }

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java?rev=1001341&r1=1001340&r2=1001341&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
Sun Sep 26 02:35:01 2010
@@ -19,9 +19,9 @@ package org.apache.geronimo.tomcat;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Hashtable;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -98,22 +98,19 @@ public class TomcatWebAppContext impleme
     private String docBase = null;
     private String virtualServer = null;
     private final Realm realm;
-    private final List valveChain;
-    private final List listenerChain;
+    private final List<Valve> valveChain;
+    private final List<LifecycleListener> listenerChain;
     private final CatalinaCluster catalinaCluster;
     private final Manager manager;
-    private final boolean crossContext;
-    private final String workDir;
-    private final boolean disableCookies;
     private final UserTransaction userTransaction;
     private final javax.naming.Context componentContext;
     private final Kernel kernel;
-    private final Set unshareableResources;
-    private final Set applicationManagedSecurityResources;
+    private final Set<String> unshareableResources;
+    private final Set<String> applicationManagedSecurityResources;
     private final TrackedConnectionAssociator trackedConnectionAssociator;
     private final SecurityHolder securityHolder;
     private final J2EEServer server;
-    private final Map webServices;
+    private final Map<String, WebServiceContainer> webServices;
     private final String objectName;
     private final String originalSpecDD;
     private final String modulePath;
@@ -123,6 +120,7 @@ public class TomcatWebAppContext impleme
     private String displayName;
     private Map<String, Object> deploymentAttributes;
     private ApplicationPolicyConfigurationManager applicationPolicyConfigurationManager;
+    private Map<String,String> contextAttributes;
 
     // JSR 77
     private final String j2EEServer;
@@ -157,11 +155,8 @@ public class TomcatWebAppContext impleme
             @ParamReference(name = "LifecycleListenerChain") LifecycleListenerGBean lifecycleListenerChain,
             @ParamReference(name = "Cluster") CatalinaClusterGBean cluster,
             @ParamReference(name = GBEAN_REF_MANAGER_RETRIEVER) ObjectRetriever managerRetriever,
-            @ParamAttribute(name = "crossContext") boolean crossContext,
-            @ParamAttribute(name = "workDir") String workDir,
-            @ParamAttribute(name = "disableCookies") boolean disableCookies,
             @ParamAttribute(name = "displayName") String displayName,
-            @ParamAttribute(name = "webServices") Map webServices,
+            @ParamAttribute(name = "webServices") Map<String, AbstractName> webServices,
             @ParamAttribute(name = "holder") Holder holder,
             @ParamReference(name = "ContextCustomizer") RuntimeCustomizer contextCustomizer,
             @ParamReference(name = "J2EEServer") J2EEServer server,
@@ -171,6 +166,7 @@ public class TomcatWebAppContext impleme
             @ParamAttribute(name = "listenerClassNames") Collection<String> listenerClassNames,
             @ParamAttribute(name = "deploymentAttributes") Map<String, Object> deploymentAttributes,
             @ParamAttribute(name = "webAppInfo") WebAppInfo webAppInfo,
+            @ParamAttribute(name = "contextAttributes") Map<String, String> contextAttributes,
             @ParamSpecial(type = SpecialAttributeType.kernel) Kernel kernel)
             throws Exception {
         assert classLoader != null;
@@ -214,6 +210,8 @@ public class TomcatWebAppContext impleme
         this.trackedConnectionAssociator = trackedConnectionAssociator;
         this.applicationPolicyConfigurationManager = applicationPolicyConfigurationManager;
 
+        this.contextAttributes = contextAttributes;
+
         this.server = server;
         if (securityHolder != null) {
             securityHolder.setRunAsSource(runAsSource == null ? RunAsSource.NULL : runAsSource);
@@ -276,12 +274,6 @@ public class TomcatWebAppContext impleme
             this.manager = null;
         }
 
-        this.crossContext = crossContext;
-
-        this.workDir = workDir;
-
-        this.disableCookies = disableCookies;
-
         this.webServices = createWebServices(webServices, kernel);
 
         this.classLoader = classLoader;
@@ -300,17 +292,17 @@ public class TomcatWebAppContext impleme
         }
     }
 
-    private Map createWebServices(Map webServiceFactoryMap, Kernel kernel) throws Exception
{
-        Map webServices = new HashMap();
-        if (webServiceFactoryMap != null) {
-            for (Iterator iterator = webServiceFactoryMap.entrySet().iterator(); iterator.hasNext();)
{
-                Map.Entry entry = (Map.Entry) iterator.next();
-                String servletName = (String) entry.getKey();
-                AbstractName factoryName = (AbstractName) entry.getValue();
-                WebServiceContainerFactory webServiceContainerFactory = (WebServiceContainerFactory)
kernel.getGBean(factoryName);
-                WebServiceContainer webServiceContainer = webServiceContainerFactory.getWebServiceContainer();
-                webServices.put(servletName, webServiceContainer);
-            }
+    private Map<String, WebServiceContainer> createWebServices(Map<String, AbstractName>
webServiceFactoryMap, Kernel kernel) throws Exception {
+        if (webServiceFactoryMap == null) {
+            return Collections.<String, WebServiceContainer>emptyMap();
+        }
+        Map<String, WebServiceContainer> webServices = new HashMap<String, WebServiceContainer>();
+        for (Map.Entry<String, AbstractName> entry : webServiceFactoryMap.entrySet())
{
+            String servletName = entry.getKey();
+            AbstractName factoryName = entry.getValue();
+            WebServiceContainerFactory webServiceContainerFactory = (WebServiceContainerFactory)
kernel.getGBean(factoryName);
+            WebServiceContainer webServiceContainer = webServiceContainerFactory.getWebServiceContainer();
+            webServices.put(servletName, webServiceContainer);
         }
         return webServices;
     }
@@ -389,7 +381,8 @@ public class TomcatWebAppContext impleme
     }
 
     public boolean isDisableCookies() {
-        return disableCookies;
+        String cookies = contextAttributes.get("cookies");
+        return cookies == null ? false : !Boolean.parseBoolean(cookies);
     }
 
     public Context getContext() {
@@ -409,7 +402,7 @@ public class TomcatWebAppContext impleme
     }
 
 
-    public Set getApplicationManagedSecurityResources() {
+    public Set<String> getApplicationManagedSecurityResources() {
         return applicationManagedSecurityResources;
     }
 
@@ -417,7 +410,7 @@ public class TomcatWebAppContext impleme
         return trackedConnectionAssociator;
     }
 
-    public Set getUnshareableResources() {
+    public Set<String> getUnshareableResources() {
         return unshareableResources;
     }
 
@@ -429,11 +422,11 @@ public class TomcatWebAppContext impleme
         return clusteredValve;
     }
 
-    public List getValveChain() {
+    public List<Valve> getValveChain() {
         return valveChain;
     }
 
-    public List getLifecycleListenerChain() {
+    public List<LifecycleListener> getLifecycleListenerChain() {
         return listenerChain;
     }
 
@@ -446,14 +439,15 @@ public class TomcatWebAppContext impleme
     }
 
     public boolean isCrossContext() {
-        return crossContext;
+        String crossContext = contextAttributes.get("crossContext");
+        return crossContext == null ? false : Boolean.parseBoolean(crossContext);
     }
 
     public String getWorkDir() {
-        return workDir;
+        return contextAttributes.get("workDir");
     }
 
-    public Map getWebServices() {
+    public Map<String, WebServiceContainer> getWebServices() {
         return webServices;
     }
 
@@ -512,7 +506,7 @@ public class TomcatWebAppContext impleme
             throw new InvalidObjectNameException(
                     "ObjectName can not be a pattern", objectName);
         }
-        Hashtable keyPropertyList = objectName.getKeyPropertyList();
+        Hashtable<String, String> keyPropertyList = objectName.getKeyPropertyList();
         if (!NameFactory.WEB_MODULE.equals(keyPropertyList.get("j2eeType"))) {
             throw new InvalidObjectNameException(
                     "WebModule object name j2eeType property must be 'WebModule'",
@@ -560,6 +554,11 @@ public class TomcatWebAppContext impleme
         reset = true;
     }
 
+    @Override
+    public Map<String, String> getContextAttributes() {
+        return contextAttributes;
+    }
+
     public void doStart() throws Exception {
         ClassLoader cl = Thread.currentThread().getContextClassLoader();
         try {

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java?rev=1001341&r1=1001340&r2=1001341&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
Sun Sep 26 02:35:01 2010
@@ -127,9 +127,6 @@ public abstract class AbstractWebModuleT
                 null,   //lifecycleListenerChain
                 null,   //cluster
                 null,   //managerRetriever
-                false,  //crossContext
-                null,   //workDir
-                false,  //disableCookies
                 null,   //displayName
                 null,   //webServices
                 null,   //holder
@@ -141,6 +138,7 @@ public abstract class AbstractWebModuleT
                 null,   //listenerClassNames
                 deploymentAttributes, //Map<String, String> deploymentAttributes
                 webAppInfo, //webAppinfo
+                new HashMap<String, String>(), // Map<String,String> contextAttributes;
                 null);  //kernel
         app.doStart();
         return app;



Mime
View raw message