From: kfujino Date: Thu, 11 Aug 2011 07:39:44 +0000 (+0000) Subject: Unregisters MBean of DataSource when web application stops. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d7f52b0728585d3eb436c1a858c84ff8d744415d;p=tomcat7.0 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 --- 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;