Unregisters MBean of DataSource when web application stops.
authorkfujino <kfujino@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 11 Aug 2011 07:39:44 +0000 (07:39 +0000)
committerkfujino <kfujino@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 11 Aug 2011 07:39:44 +0000 (07:39 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1156519 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/core/NamingContextListener.java

index 3f3660e..8ab2c29 100644 (file)
@@ -23,6 +23,7 @@ import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Iterator;
@@ -296,6 +297,13 @@ public class NamingContextListener
             }
 
             ContextAccessController.unsetSecurityToken(getName(), container);
+            
+            // unregister mbeans.
+            Collection<ObjectName> names = objectNames.values();
+            for (ObjectName objectName : names) {
+                Registry.getRegistry(null, null).unregisterComponent(objectName);
+            }
+            objectNames.clear();
 
             namingContext = null;
             envCtx = null;