From d7f52b0728585d3eb436c1a858c84ff8d744415d Mon Sep 17 00:00:00 2001 From: kfujino Date: Thu, 11 Aug 2011 07:39:44 +0000 Subject: [PATCH] Unregisters MBean of DataSource when web application stops. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1156519 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/catalina/core/NamingContextListener.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/java/org/apache/catalina/core/NamingContextListener.java b/java/org/apache/catalina/core/NamingContextListener.java index 3f3660e61..8ab2c294f 100644 --- a/java/org/apache/catalina/core/NamingContextListener.java +++ b/java/org/apache/catalina/core/NamingContextListener.java @@ -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 names = objectNames.values(); + for (ObjectName objectName : names) { + Registry.getRegistry(null, null).unregisterComponent(objectName); + } + objectNames.clear(); namingContext = null; envCtx = null; -- 2.11.0