@Override public void destroy() { webContextBuilder = container.getBean(WebContextBuilder.class); if (webContextBuilder != null) { webContextBuilder.engageThread(container, null, null); } container.destroy(); if (webContextBuilder != null) { webContextBuilder.disengageThread(); } super.destroy(); }
/** * Find all the containers that have been registered, and check all the * contained beans for ones that implement {@link ServletContextListener} * and pass the {@link ServletContextListener#contextDestroyed} event on. * @param ev The event object to pass on * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent) */ public void contextDestroyed(ServletContextEvent ev) { List<Container> containers = StartupUtil.getAllPublishedContainers(ev.getServletContext()); if (containers.isEmpty()) { log.debug("No containers to shutdown"); return; } for (Container container : containers) { WebContextBuilder webContextBuilder = container.getBean(WebContextBuilder.class); if (webContextBuilder != null) { webContextBuilder.engageThread(container, null, null); } container.destroy(); if (webContextBuilder != null) { webContextBuilder.disengageThread(); } } }