Author: markt Date: Wed Nov 3 18:39:11 2010 New Revision: 1030602 URL: http://svn.apache.org/viewvc?rev=1030602&view=rev Log: Make sure Contexts defined in server.xml pick up any configClass setting from the parent Host.
Modified: tomcat/tc6.0.x/trunk/STATUS.txt tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/LifecycleListenerRule.java Modified: tomcat/tc6.0.x/trunk/STATUS.txt URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=1030602&r1=1030601&r2=1030602&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/STATUS.txt (original) +++ tomcat/tc6.0.x/trunk/STATUS.txt Wed Nov 3 18:39:11 2010 @@ -102,18 +102,6 @@ PATCHES PROPOSED TO BACKPORT: but from debugging it looks that it is called by Tomcat code only (JspServlet). -* Make sure Contexts defined in server.xml pick up any configClass setting from - the parent Host. - http://people.apache.org/~markt/patches/2010-09-11-configClass.patch - +1: markt, kkolinko, kfujino - -1: - kkolinko: Though 1) I do not see any documentation on configClass attribute in - the docs at all. Though it is in JavaDoc for StandardHost. - 2) It looks, formally, the patch does more than is announced. It applies to any - LifecycleListenerRule. Actually, though, for Engine's engineConfigClass attribute - and Host's hostConfigClass attribute it does not change their behaviour, - because their containers do not have those attributes. - * Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49497 Stop accepting new requests (inc keep-alive) once the BIO connector is paused and the current request has finished processing Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/LifecycleListenerRule.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/LifecycleListenerRule.java?rev=1030602&r1=1030601&r2=1030602&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/LifecycleListenerRule.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/LifecycleListenerRule.java Wed Nov 3 18:39:11 2010 @@ -19,18 +19,28 @@ package org.apache.catalina.startup; +import org.apache.catalina.Container; import org.apache.catalina.Lifecycle; import org.apache.catalina.LifecycleListener; +import org.apache.tomcat.util.IntrospectionUtils; import org.apache.tomcat.util.digester.Rule; import org.xml.sax.Attributes; /** - * <p>Rule that creates a new <code>LifecycleListener</code> instance, - * and associates it with the top object on the stack (which must - * implement <code>LifecycleListener</code>).</p> + * Rule that creates a new {...@link LifecycleListener} and associates it with the + * top object on the stack which must implement {...@link Container} and + * {...@link Lifecycle}. The implementation class to be used is determined by: + * <ol> + * <li>Does the top element on the stack specify an implementation class using + * the attribute specified when this rule was created?</li> + * <li>Does the parent {...@link Container} of the {...@link Container} on the top of + * the stack specify an implementation class using the attribute specified + * when this rule was created?</li> + * <li>Use the default implementation class specified when this rule was + * created.</li> + * </ol> */ - public class LifecycleListenerRule extends Rule { @@ -82,21 +92,43 @@ public class LifecycleListenerRule exten public void begin(String namespace, String name, Attributes attributes) throws Exception { - // Instantiate a new LifecyleListener implementation object - String className = listenerClass; + Container c = (Container) digester.peek(); + Container p = null; + Object obj = digester.peek(1); + if (obj instanceof Container) { + p = (Container) obj; + } + + String className = null; + + // Check the container for the specified attribute if (attributeName != null) { String value = attributes.getValue(attributeName); if (value != null) className = value; } - Class clazz = Class.forName(className); + + // Check the container's parent for the specified attribute + if (p != null && className == null) { + String configClass = + (String) IntrospectionUtils.getProperty(p, attributeName); + if (configClass != null && configClass.length() > 0) { + className = configClass; + } + } + + // Use the default + if (className == null) { + className = listenerClass; + } + + // Instantiate a new LifecyleListener implementation object + Class<?> clazz = Class.forName(className); LifecycleListener listener = (LifecycleListener) clazz.newInstance(); // Add this LifecycleListener to our associated component - Lifecycle lifecycle = (Lifecycle) digester.peek(); - lifecycle.addLifecycleListener(listener); - + ((Lifecycle) c).addLifecycleListener(listener); } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org