Author: markt
Date: Tue May 11 10:18:55 2010
New Revision: 943073

URL: http://svn.apache.org/viewvc?rev=943073&view=rev
Log:
ContainerListener != LifecycleListener. Use the correct one.

Modified:
    tomcat/trunk/java/org/apache/catalina/connector/LocalStrings.properties
    tomcat/trunk/java/org/apache/catalina/connector/MapperListener.java
    tomcat/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml

Modified: 
tomcat/trunk/java/org/apache/catalina/connector/LocalStrings.properties
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/LocalStrings.properties?rev=943073&r1=943072&r2=943073&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/LocalStrings.properties 
(original)
+++ tomcat/trunk/java/org/apache/catalina/connector/LocalStrings.properties Tue 
May 11 10:18:55 2010
@@ -82,6 +82,6 @@ mapperListener.unregisterContext=Unregis
 mapperListener.registerWrapper=Register Wrapper {0} in Context {1}
 mapperListener.addMBeanListenerFail=Failed to add MBean notification listener 
for connector [{0}] in domain [{1}]. Adding Hosts, Contexts and Wrappers will 
not be visible to the connector.
 mapperListener.removeMBeanListenerFail=Failed to remove MBean notification 
listener for connector [{0}] in domain [{1}]. This may result in a memory leak.
-mapperLister.containerListenerFail=Failed to call method [{0}] on object 
[{1}]. Changes in the object state may not be correctly reflected in the mapper 
for connector [{2}] in domain [{3}].
+mapperLister.lifecycleListenerFail=Failed to call method [{0}] on object 
[{1}]. Changes in the object state may not be correctly reflected in the mapper 
for connector [{2}] in domain [{3}].
 
 inputBuffer.streamClosed=Stream closed

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=943073&r1=943072&r2=943073&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/MapperListener.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/connector/MapperListener.java Tue May 
11 10:18:55 2010
@@ -34,6 +34,8 @@ import org.apache.catalina.Context;
 import org.apache.catalina.Engine;
 import org.apache.catalina.Host;
 import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleEvent;
+import org.apache.catalina.LifecycleListener;
 import org.apache.catalina.LifecycleState;
 import org.apache.catalina.Wrapper;
 import org.apache.juli.logging.Log;
@@ -53,8 +55,7 @@ import org.apache.tomcat.util.res.String
  * @author Costin Manolache
  */
 public class MapperListener
-    implements NotificationListener, ContainerListener
- {
+        implements NotificationListener, ContainerListener, LifecycleListener {
 
 
     private static final Log log = LogFactory.getLog(MapperListener.class);
@@ -206,10 +207,10 @@ public class MapperListener
         String methodName = null;
         if (notification.getType().equals
                 (MBeanServerNotification.REGISTRATION_NOTIFICATION)) {
-            methodName = "addContainerListener";
+            methodName = "addLifecycleListener";
         } else if (notification.getType().equals
                 (MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
-            methodName = "removeContainerListener";
+            methodName = "removeLifecycleListener";
         } else {
             return;
         }
@@ -231,18 +232,18 @@ public class MapperListener
                 try {
                     mBeanServer.invoke(objectName, methodName,
                             new Object[] {this},
-                            new String[] 
{"org.apache.catalinaContainerListener"});
+                            new String[] 
{"org.apache.catalina.LifecycleListener"});
                 } catch (ReflectionException e) {
                     log.error(sm.getString(
-                            "mapperLister.containerListenerFail", methodName,
+                            "mapperLister.lifecycleListenerFail", methodName,
                             objectName, connector, domain), e);
                 } catch (MBeanException e) {
                     log.error(sm.getString(
-                            "mapperLister.containerListenerFail", methodName,
+                            "mapperLister.lifecycleListenerFail", methodName,
                             objectName, connector, domain), e);
                 } catch (InstanceNotFoundException e) {
                     log.error(sm.getString(
-                            "mapperLister.containerListenerFail", methodName,
+                            "mapperLister.lifecycleListenerFail", methodName,
                             objectName, connector, domain), e);
                 }
             }
@@ -254,25 +255,7 @@ public class MapperListener
 
     public void containerEvent(ContainerEvent event) {
 
-        if (event.getType() == Lifecycle.AFTER_START_EVENT) {
-            Object obj = event.getSource();
-            if (obj instanceof Wrapper) {
-                registerWrapper((Wrapper) obj);
-            } else if (obj instanceof Context) {
-                registerContext((Context) obj);
-            } else if (obj instanceof Host) {
-                registerHost((Host) obj);
-            }
-        } else if (event.getType() == Lifecycle.AFTER_STOP_EVENT) {
-            Object obj = event.getSource();
-            if (obj instanceof Wrapper) {
-                unregisterWrapper((Wrapper) obj);
-            } else if (obj instanceof Context) {
-                unregisterContext((Context) obj);
-            } else if (obj instanceof Host) {
-                unregisterHost((Host) obj);
-            }
-        } else if (event.getType() == Host.ADD_ALIAS_EVENT) {
+        if (event.getType() == Host.ADD_ALIAS_EVENT) {
             mapper.addHostAlias(((Host) event.getSource()).getName(),
                     event.getData().toString());
         } else if (event.getType() == Host.REMOVE_ALIAS_EVENT) {
@@ -441,4 +424,28 @@ public class MapperListener
                     wrapperName, contextName));
         }
     }
+
+
+    @Override
+    public void lifecycleEvent(LifecycleEvent event) {
+        if (event.getType() == Lifecycle.AFTER_START_EVENT) {
+            Object obj = event.getSource();
+            if (obj instanceof Wrapper) {
+                registerWrapper((Wrapper) obj);
+            } else if (obj instanceof Context) {
+                registerContext((Context) obj);
+            } else if (obj instanceof Host) {
+                registerHost((Host) obj);
+            }
+        } else if (event.getType() == Lifecycle.AFTER_STOP_EVENT) {
+            Object obj = event.getSource();
+            if (obj instanceof Wrapper) {
+                unregisterWrapper((Wrapper) obj);
+            } else if (obj instanceof Context) {
+                unregisterContext((Context) obj);
+            } else if (obj instanceof Host) {
+                unregisterHost((Host) obj);
+            }
+        }
+    }
 }

Modified: tomcat/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml?rev=943073&r1=943072&r2=943073&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml (original)
+++ tomcat/trunk/java/org/apache/catalina/core/mbeans-descriptors.xml Tue May 
11 10:18:55 2010
@@ -1021,6 +1021,23 @@
                returnType="org.apache.catalina.Wrapper">
     </operation>
     
+        <operation name="addLifecycleListener"
+               description="Add a lifecycle listener to this Context"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="listener"
+                 description="New lifecycle listener to be added"
+                 type="org.apache.catalina.LifecycleListener"/>
+    </operation>
+    
+    <operation name="removeLifecycleListener"
+               description="Remove a lifecycle listener from this Context"
+               impact="ACTION"
+               returnType="void">
+      <parameter name="listener"
+                 description="New lifecycle listener to be removed"
+                 type="org.apache.catalina.LifecycleListener"/>
+    </operation>
   </mbean>
   
   <mbean name="StandardWrapperValve"



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to