craigmcc 02/02/19 14:16:00 Modified: catalina/src/share/org/apache/catalina/mbeans MBeanUtils.java ServerLifecycleListener.java catalina/src/share/org/apache/catalina/startup ContextConfig.java Log: Correct the mechanism by which MBean names were generated for Valves. The previous algorithm did not support repeated generation of the same name for the same Valve instance, which manifested itself as failure to find the appropriate MBeans at shutdown time (so that shutdown could complete). Fix a couple of places in ContextConfig where new valves were being added, but the appropriate event listener notifications were not getting sent. This causes some Valve MBeans to not get created at startup time. PR: 4639432 Revision Changes Path 1.27 +13 -30 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanUtils.java Index: MBeanUtils.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanUtils.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- MBeanUtils.java 19 Feb 2002 02:15:27 -0000 1.26 +++ MBeanUtils.java 19 Feb 2002 22:16:00 -0000 1.27 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanUtils.java,v 1.26 2002/02/19 02:15:27 craigmcc Exp $ - * $Revision: 1.26 $ - * $Date: 2002/02/19 02:15:27 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/MBeanUtils.java,v 1.27 2002/02/19 22:16:00 craigmcc Exp $ + * $Revision: 1.27 $ + * $Date: 2002/02/19 22:16:00 $ * * ==================================================================== * @@ -109,7 +109,7 @@ * * @author Craig R. McClanahan * @author Amy Roh - * @version $Revision: 1.26 $ $Date: 2002/02/19 02:15:27 $ + * @version $Revision: 1.27 $ $Date: 2002/02/19 22:16:00 $ */ public class MBeanUtils { @@ -159,14 +159,6 @@ private static MBeanServer mserver = createServer(); - /** - * The sequence number for Valve - */ - private static int contextValveSequence = 0; - private static int hostValveSequence = 0; - private static int engineValveSequence = 0; - - // --------------------------------------------------------- Static Methods @@ -1172,21 +1164,15 @@ if (container instanceof Engine) { Service service = ((Engine)container).getService(); - Integer sequenceInt = new Integer(engineValveSequence); - String sequenceStr = sequenceInt.toString(); name = new ObjectName(domain + ":type=Valve,sequence=" + - sequenceStr + ",service=" + - service.getName()); - engineValveSequence++; + valve.hashCode() + ",service=" + + service.getName()); } else if (container instanceof Host) { Service service = ((Engine)container.getParent()).getService(); - Integer sequenceInt = new Integer(hostValveSequence); - String sequenceStr = sequenceInt.toString(); name = new ObjectName(domain + ":type=Valve,sequence=" + - sequenceStr + ",host=" + - container.getName() + ",service=" + - service.getName()); - hostValveSequence++; + valve.hashCode() + ",host=" + + container.getName() + ",service=" + + service.getName()); } else if (container instanceof Context) { String path = ((Context)container).getPath(); if (path.length() < 1) { @@ -1194,14 +1180,11 @@ } Host host = (Host) container.getParent(); Service service = ((Engine) host.getParent()).getService(); - Integer sequenceInt = new Integer(contextValveSequence); - String sequenceStr = sequenceInt.toString(); name = new ObjectName(domain + ":type=Valve,sequence=" + - sequenceStr + ",path=" + - path + ",host=" + - host.getName() + ",service=" + - service.getName()); - contextValveSequence++; + valve.hashCode() + ",path=" + + path + ",host=" + + host.getName() + ",service=" + + service.getName()); } return (name); 1.20 +11 -4 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/ServerLifecycleListener.java Index: ServerLifecycleListener.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/ServerLifecycleListener.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- ServerLifecycleListener.java 4 Feb 2002 20:28:49 -0000 1.19 +++ ServerLifecycleListener.java 19 Feb 2002 22:16:00 -0000 1.20 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/ServerLifecycleListener.java,v 1.19 2002/02/04 20:28:49 amyroh Exp $ - * $Revision: 1.19 $ - * $Date: 2002/02/04 20:28:49 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/ServerLifecycleListener.java,v 1.20 2002/02/19 22:16:00 craigmcc Exp $ + * $Revision: 1.20 $ + * $Date: 2002/02/19 22:16:00 $ * * ==================================================================== * @@ -105,7 +105,7 @@ * * @author Craig R. McClanahan * @author Amy Roh - * @version $Revision: 1.19 $ $Date: 2002/02/04 20:28:49 $ + * @version $Revision: 1.20 $ $Date: 2002/02/19 22:16:00 $ */ public class ServerLifecycleListener @@ -270,6 +270,7 @@ if (debug >= 4) log("Creating MBean for Context " + context); MBeanUtils.createMBean(context); + context.addContainerListener(this); if (context instanceof StandardContext) { ((StandardContext) context).addPropertyChangeListener(this); ((StandardContext) context).addLifecycleListener(this); @@ -581,6 +582,9 @@ } + // Deregister ourselves as a ContainerListener + context.removeContainerListener(this); + } @@ -630,6 +634,9 @@ for (int k = 0; k < contexts.length; k++) { destroyMBeans((Context) contexts[k]); } + + // Deregister ourselves as a ContainerListener + host.removeContainerListener(this); } 1.57 +6 -6 jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java Index: ContextConfig.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v retrieving revision 1.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 --- ContextConfig.java 10 Nov 2001 00:01:55 -0000 1.56 +++ ContextConfig.java 19 Feb 2002 22:16:00 -0000 1.57 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v 1.56 2001/11/10 00:01:55 craigmcc Exp $ - * $Revision: 1.56 $ - * $Date: 2001/11/10 00:01:55 $ + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/startup/ContextConfig.java,v 1.57 2002/02/19 22:16:00 craigmcc Exp $ + * $Revision: 1.57 $ + * $Date: 2002/02/19 22:16:00 $ * * ==================================================================== * @@ -127,7 +127,7 @@ * of that Context, and the associated defined servlets. * * @author Craig R. McClanahan - * @version $Revision: 1.56 $ $Date: 2001/11/10 00:01:55 $ + * @version $Revision: 1.57 $ $Date: 2002/02/19 22:16:00 $ */ public final class ContextConfig @@ -367,7 +367,7 @@ if (context instanceof ContainerBase) { Pipeline pipeline = ((ContainerBase) context).getPipeline(); if (pipeline != null) { - pipeline.addValve(authenticator); + ((ContainerBase) context).addValve(authenticator); log(sm.getString("contextConfig.authenticatorConfigured", loginConfig.getAuthMethod())); } @@ -413,7 +413,7 @@ if (context instanceof ContainerBase) { Pipeline pipeline = ((ContainerBase) context).getPipeline(); if (pipeline != null) { - pipeline.addValve(certificates); + ((ContainerBase) context).addValve(certificates); log(sm.getString ("contextConfig.certificatesConfig.added")); }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>