Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 39811 invoked from network); 26 Sep 2010 02:35:25 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 26 Sep 2010 02:35:25 -0000 Received: (qmail 68962 invoked by uid 500); 26 Sep 2010 02:35:25 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 68822 invoked by uid 500); 26 Sep 2010 02:35:24 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 68815 invoked by uid 99); 26 Sep 2010 02:35:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 26 Sep 2010 02:35:23 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 26 Sep 2010 02:35:21 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BAA0C23889B2; Sun, 26 Sep 2010 02:35:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: scm@geronimo.apache.org From: xuhaihong@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100926023501.BAA0C23889B2@eris.apache.org> 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 NAMESPACE_UPDATES = new HashMap(); - private static final Set INGORE_ELEMENT_NAMES = new HashSet(); + private static final Set INGORED_ELEMENT_NAMES = new HashSet(); + private static final Set INGORED_CONTEXT_ATTRIBUTE_NAMES = new HashSet(); 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 contextAttributes = new HashMap(); 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 listeners = new ArrayList(); // webModuleData.setAttribute("listenerClassNames", listeners); //Handle the role permissions and webservices on the servlets. List servletTypes = webApp.getServlet(); Map webServices = new HashMap(); - 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 @@ + + + + The context element provides the same function as used in + Tomcat, it supports context level attributes and context + parameters. + + + @@ -293,5 +302,17 @@ - + + + + + + + + + + + + + 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 @@ + + + + + /test + + 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 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 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 getListeners(); WebAppInfo getWebAppInfo(); + + Map 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 valveChain; + private final List 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 unshareableResources; + private final Set applicationManagedSecurityResources; private final TrackedConnectionAssociator trackedConnectionAssociator; private final SecurityHolder securityHolder; private final J2EEServer server; - private final Map webServices; + private final Map 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 deploymentAttributes; private ApplicationPolicyConfigurationManager applicationPolicyConfigurationManager; + private Map 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 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 listenerClassNames, @ParamAttribute(name = "deploymentAttributes") Map deploymentAttributes, @ParamAttribute(name = "webAppInfo") WebAppInfo webAppInfo, + @ParamAttribute(name = "contextAttributes") Map 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 createWebServices(Map webServiceFactoryMap, Kernel kernel) throws Exception { + if (webServiceFactoryMap == null) { + return Collections.emptyMap(); + } + Map webServices = new HashMap(); + for (Map.Entry 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 getApplicationManagedSecurityResources() { return applicationManagedSecurityResources; } @@ -417,7 +410,7 @@ public class TomcatWebAppContext impleme return trackedConnectionAssociator; } - public Set getUnshareableResources() { + public Set getUnshareableResources() { return unshareableResources; } @@ -429,11 +422,11 @@ public class TomcatWebAppContext impleme return clusteredValve; } - public List getValveChain() { + public List getValveChain() { return valveChain; } - public List getLifecycleListenerChain() { + public List 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 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 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 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 deploymentAttributes webAppInfo, //webAppinfo + new HashMap(), // Map contextAttributes; null); //kernel app.doStart(); return app;