From: pero Date: Fri, 14 May 2010 15:00:06 +0000 (+0000) Subject: Fix change fragment absolute-ordering at web.xml with manager redeploy! X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=baab2a70436806a24c67e22f74cebaab6c34ea89;p=tomcat7.0 Fix change fragment absolute-ordering at web.xml with manager redeploy! git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@944304 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/startup/ContextConfig.java b/java/org/apache/catalina/startup/ContextConfig.java index 1c6c6af81..2e2b9cae4 100644 --- a/java/org/apache/catalina/startup/ContextConfig.java +++ b/java/org/apache/catalina/startup/ContextConfig.java @@ -1171,7 +1171,7 @@ public class ContextConfig * web.xml file. */ protected void webConfig() { - WebXml webXml = new WebXml(); + WebXml webXml = createWebXml(); // Parse global web.xml if present InputSource globalWebXml = getGlobalWebXmlSource(); @@ -1281,7 +1281,10 @@ public class ContextConfig } } - + protected WebXml createWebXml() { + return new WebXml(); + } + /** * Scan JARs for ServletContainerInitializer implementations. * Implementations will be added in web-fragment.xml priority order. diff --git a/java/org/apache/naming/resources/BaseDirContext.java b/java/org/apache/naming/resources/BaseDirContext.java index 5e72fa669..e8fe554d1 100644 --- a/java/org/apache/naming/resources/BaseDirContext.java +++ b/java/org/apache/naming/resources/BaseDirContext.java @@ -375,7 +375,16 @@ public abstract class BaseDirContext implements DirContext { * Release any resources allocated for this directory context. */ public void release() { - // No action taken by the default implementation + for(BaseDirContext bcontext: this.aliases.values()) { + bcontext.release(); + } + this.aliases.clear(); + for(DirContext dcontext: this.altDirContexts) { + if(dcontext instanceof BaseDirContext) { + ((BaseDirContext)dcontext).release(); + } + } + this.altDirContexts.clear(); } diff --git a/test/org/apache/catalina/core/TestStandardContextResources.java b/test/org/apache/catalina/core/TestStandardContextResources.java index 6a1fde1c3..d2fd31e42 100644 --- a/test/org/apache/catalina/core/TestStandardContextResources.java +++ b/test/org/apache/catalina/core/TestStandardContextResources.java @@ -29,8 +29,12 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.catalina.LifecycleListener; +import org.apache.catalina.deploy.WebXml; +import org.apache.catalina.startup.ContextConfig; import org.apache.catalina.startup.Tomcat; import org.apache.catalina.startup.TomcatBaseTest; +import org.apache.catalina.startup.Tomcat.DefaultWebXmlListener; import org.apache.tomcat.util.buf.ByteChunk; public class TestStandardContextResources extends TomcatBaseTest { @@ -70,14 +74,69 @@ public class TestStandardContextResources extends TomcatBaseTest { "

resourceE.jsp in the web application

"); } - public void testResources2() throws Exception { + public void testResourcesAbsoluteOrdering() throws Exception { Tomcat tomcat = getTomcatInstance(); File appDir = new File("test/webapp-3.0-fragments"); // app dir is relative to server home StandardContext ctx = (StandardContext) tomcat.addWebapp(null, "/test", appDir.getAbsolutePath()); + LifecycleListener[] listener = ctx.findLifecycleListeners(); + assertEquals(3,listener.length); + assertTrue(listener[1] instanceof ContextConfig); + ContextConfig config = new ContextConfig() { + protected WebXml createWebXml() { + WebXml wxml = new WebXml(); + wxml.addAbsoluteOrdering("resources"); + wxml.addAbsoluteOrdering("resources2"); + return wxml; + } + }; + // prevent it from looking ( if it finds one - it'll have dup error ) + config.setDefaultWebXml("org/apache/catalin/startup/NO_DEFAULT_XML"); + listener[1] = config; + Tomcat.addServlet(ctx, "getresource", new GetResourceServlet()); + ctx.addServletMapping("/getresource", "getresource"); + + tomcat.start(); + assertPageContains("/test/getresource?path=/resourceF.jsp", + "

resourceF.jsp in resources2.jar

"); + assertPageContains("/test/getresource?path=/resourceB.jsp", + "

resourceB.jsp in resources.jar

"); + + ctx.stop(); + + LifecycleListener[] listener1 = ctx.findLifecycleListeners(); + // change ordering and reload + ContextConfig config1 = new ContextConfig() { + protected WebXml createWebXml() { + WebXml wxml = new WebXml(); + wxml.addAbsoluteOrdering("resources2"); + wxml.addAbsoluteOrdering("resources"); + return wxml; + } + }; + // prevent it from looking ( if it finds one - it'll have dup error ) + config1.setDefaultWebXml("org/apache/catalin/startup/NO_DEFAULT_XML"); + listener1[1] = config1; + ctx.start(); + + assertPageContains("/test/getresource?path=/resourceF.jsp", + "

resourceF.jsp in resources2.jar

"); + assertPageContains("/test/getresource?path=/resourceB.jsp", + "

resourceB.jsp in resources2.jar

"); + + } + + public void testResources2() throws Exception { + Tomcat tomcat = getTomcatInstance(); + + File appDir = new File("test/webapp-3.0-fragments"); + // app dir is relative to server home + StandardContext ctx = (StandardContext) tomcat.addWebapp(null, "/test", + appDir.getAbsolutePath()); + Tomcat.addServlet(ctx, "getresource", new GetResourceServlet()); ctx.addServletMapping("/getresource", "getresource");