Author: pero
Date: Fri May 14 15:00:06 2010
New Revision: 944304
URL: http://svn.apache.org/viewvc?rev=944304&view=rev
Log:
Fix change fragment absolute-ordering at web.xml with manager redeploy!
Modified:
tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
tomcat/trunk/java/org/apache/naming/resources/BaseDirContext.java
tomcat/trunk/test/org/apache/catalina/core/TestStandardContextResources.java
Modified: tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=944304&r1=944303&r2=944304&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ContextConfig.java Fri May 14
15:00:06 2010
@@ -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.
Modified: tomcat/trunk/java/org/apache/naming/resources/BaseDirContext.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/resources/BaseDirContext.java?rev=944304&r1=944303&r2=944304&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/naming/resources/BaseDirContext.java (original)
+++ tomcat/trunk/java/org/apache/naming/resources/BaseDirContext.java Fri May
14 15:00:06 2010
@@ -375,7 +375,16 @@ public abstract class BaseDirContext imp
* 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();
}
Modified:
tomcat/trunk/test/org/apache/catalina/core/TestStandardContextResources.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestStandardContextResources.java?rev=944304&r1=944303&r2=944304&view=diff
==============================================================================
---
tomcat/trunk/test/org/apache/catalina/core/TestStandardContextResources.java
(original)
+++
tomcat/trunk/test/org/apache/catalina/core/TestStandardContextResources.java
Fri May 14 15:00:06 2010
@@ -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 TestStandardContextResource
"<p>resourceE.jsp in the web application</p>");
}
- 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",
+ "<p>resourceF.jsp in resources2.jar</p>");
+ assertPageContains("/test/getresource?path=/resourceB.jsp",
+ "<p>resourceB.jsp in resources.jar</p>");
+
+ 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",
+ "<p>resourceF.jsp in resources2.jar</p>");
+ assertPageContains("/test/getresource?path=/resourceB.jsp",
+ "<p>resourceB.jsp in resources2.jar</p>");
+
+ }
+
+ 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");
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]