Author: markt
Date: Tue May 18 15:58:58 2010
New Revision: 945722
URL: http://svn.apache.org/viewvc?rev=945722&view=rev
Log:
Only register the MapperListener once per component and remove it as soon as it
is no longer required.
Modified:
tomcat/trunk/java/org/apache/catalina/connector/MapperListener.java
Modified: tomcat/trunk/java/org/apache/catalina/connector/MapperListener.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/MapperListener.java?rev=945722&r1=945721&r2=945722&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/MapperListener.java
(original)
+++ tomcat/trunk/java/org/apache/catalina/connector/MapperListener.java Tue May
18 15:58:58 2010
@@ -110,25 +110,8 @@ public class MapperListener implements C
Host host = (Host) conHost;
if (!LifecycleState.NEW.equals(host.getState())) {
host.addLifecycleListener(this);
+ // Registering the host will register the context and wrappers
registerHost(host);
-
- Container[] conContexts = host.findChildren();
- for (Container conContext : conContexts) {
- Context context = (Context) conContext;
- if (!LifecycleState.NEW.equals(context.getState())) {
- context.addLifecycleListener(this);
- registerContext(context);
-
- Container[] conWrappers = context.findChildren();
- for (Container conWrapper : conWrappers) {
- Wrapper wrapper = (Wrapper) conWrapper;
- if
(!LifecycleState.NEW.equals(wrapper.getState())) {
- wrapper.addLifecycleListener(this);
- registerWrapper(wrapper);
- }
- }
- }
- }
}
}
}
@@ -308,7 +291,7 @@ public class MapperListener implements C
*/
private void unregisterHost(Host host) {
- host.removeContainerListener(this);
+ removeListeners(host);
String hostname = host.getName();
@@ -325,7 +308,7 @@ public class MapperListener implements C
*/
private void unregisterWrapper(Wrapper wrapper) {
- wrapper.removeContainerListener(this);
+ removeListeners(wrapper);
String contextName = wrapper.getParent().getName();
if ("/".equals(contextName)) {
@@ -381,7 +364,7 @@ public class MapperListener implements C
return;
}
- context.removeContainerListener(this);
+ removeListeners(context);
String contextName = context.getName();
if ("/".equals(contextName)) {
@@ -448,4 +431,17 @@ public class MapperListener implements C
}
}
}
+
+ /**
+ * Remove this mapper from the container and all child containers
+ *
+ * @param container
+ */
+ private void removeListeners(Container container) {
+ container.removeContainerListener(this);
+ container.removeLifecycleListener(this);
+ for (Container child : container.findChildren()) {
+ removeListeners(child);
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]