@@ -0,0 +1,1519 @@
+%0A/*%0A * Copyright (C) 2011 Archie L. Cobbs. All rights reserved.%0A *%0A * $Id$%0A */%0A%0Apackage org.dellroad.stuff.servlet;%0A%0Aimport java.sql.Driver;%0Aimport java.sql.DriverManager;%0Aimport java.util.Enumeration;%0A%0Aimport javax.servlet.ServletContextEvent;%0A%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0Aimport org.springframework.web.util.IntrospectorCleanupListener;%0A%0A/**%0A * Clears references that can cause container memory leaks on Web container class unloading.%0A *%0A * @see %3Ca href=%22http://opensource.atlassian.com/confluence/spring/pages/viewpage.action?pageId=2669%22%3ESpring Wiki Discussion of%0A *      ClassLoader Memory Leaks%3C/a%3E%0A */%0Apublic class ContextCleanupListener extends IntrospectorCleanupListener %7B%0A%0A    protected final Logger log = LoggerFactory.getLogger(getClass());%0A%0A    /**%0A     * Unregisters any JDBC drivers registered under the current class loader after%0A     * first invoking the superclass version of this method.%0A     */%0A    @Override%0A    public void contextDestroyed(ServletContextEvent event) %7B%0A        try %7B%0A            super.contextDestroyed(event);%0A            for (Enumeration%3CDriver%3E e = DriverManager.getDrivers(); e.hasMoreElements(); ) %7B%0A                Driver driver = e.nextElement();%0A                if (driver.getClass().getClassLoader() == getClass().getClassLoader()) %7B%0A                    DriverManager.deregisterDriver(driver);%0A                %7D%0A            %7D%0A        %7D catch (Throwable e) %7B%0A            log.error(%22exception cleaning up servlet context%22, e);%0A        %7D%0A    %7D%0A%7D%0A

Add ContextCleanupListener.