/** * Close Spring's web application context for the given servlet context. * <p>If overriding {@link #loadParentContext(ServletContext)}, you may have * to override this method as well. * @param servletContext the ServletContext that the WebApplicationContext runs in */ public void closeWebApplicationContext(ServletContext servletContext) { servletContext.log("Closing Spring root WebApplicationContext"); try { if (this.context instanceof ConfigurableWebApplicationContext) { ((ConfigurableWebApplicationContext) this.context).close(); } } finally { ClassLoader ccl = Thread.currentThread().getContextClassLoader(); if (ccl == ContextLoader.class.getClassLoader()) { currentContext = null; } else if (ccl != null) { currentContextPerThread.remove(ccl); } servletContext.removeAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); } }
@Override public void close() throws IOException { try { this.context.close(); } catch(Exception e) {} }
/** * Close Spring's web application context for the given servlet context. * <p>If overriding {@link #loadParentContext(ServletContext)}, you may have * to override this method as well. * @param servletContext the ServletContext that the WebApplicationContext runs in */ public void closeWebApplicationContext(ServletContext servletContext) { servletContext.log("Closing Spring root WebApplicationContext"); try { if (this.context instanceof ConfigurableWebApplicationContext) { ((ConfigurableWebApplicationContext) this.context).close(); } } finally { ClassLoader ccl = Thread.currentThread().getContextClassLoader(); if (ccl == ContextLoader.class.getClassLoader()) { currentContext = null; } else if (ccl != null) { currentContextPerThread.remove(ccl); } servletContext.removeAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); } }
@After public void close() { if (context != null) { context.close(); } }
@After public void close() { if (context != null) { context.close(); } }
applicationContext.close();
@Test public void nullMessageSource() throws JspException { PageContext pc = createPageContext(); ConfigurableWebApplicationContext ctx = (ConfigurableWebApplicationContext) RequestContextUtils.findWebApplicationContext((HttpServletRequest) pc.getRequest(), pc.getServletContext()); ctx.close(); MessageTag tag = new MessageTag(); tag.setPageContext(pc); tag.setCode("test"); tag.setVar("testvar2"); tag.doStartTag(); assertEquals("Correct doEndTag return value", Tag.EVAL_PAGE, tag.doEndTag()); }
public void setSpringProfiles(ServletContext ctx, String... springProfiles) throws ContainerInitializationException { this.springProfiles = Arrays.asList(springProfiles); applicationContext.registerShutdownHook(); applicationContext.close(); contextListeners.clear(); try { onStartup(ctx); } catch (ServletException e) { throw new ContainerInitializationException("Could not reload Spring context", e); } }
/** {@inheritDoc} */ @Override public void destroy(final WicketFilter filter) { if (webApplicationContext != null) { webApplicationContext.close(); } } }
public void sessionDestroyed(HttpSessionEvent httpSessionEvent) { sessionContext.close(); this.sessionContext = null; } }
@Override public synchronized void close() { this.appContext.close(); }
/** * Close Spring's web application context for the given servlet context. * <p>If overriding {@link #loadParentContext(ServletContext)}, you may have * to override this method as well. * @param servletContext the ServletContext that the WebApplicationContext runs in */ public void closeWebApplicationContext(ServletContext servletContext) { servletContext.log("Closing Spring root WebApplicationContext"); try { if (this.context instanceof ConfigurableWebApplicationContext) { ((ConfigurableWebApplicationContext) this.context).close(); } } finally { ClassLoader ccl = Thread.currentThread().getContextClassLoader(); if (ccl == ContextLoader.class.getClassLoader()) { currentContext = null; } else if (ccl != null) { currentContextPerThread.remove(ccl); } servletContext.removeAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); } }
@Destroy public void destroy() { if (webApplicationContext != null && webApplicationContext instanceof ConfigurableWebApplicationContext) { ((ConfigurableWebApplicationContext) webApplicationContext).close(); } }
/** * Close Spring's web application context for the given servlet context. * <p>If overriding {@link #loadParentContext(ServletContext)}, you may have * to override this method as well. * @param servletContext the ServletContext that the WebApplicationContext runs in */ public void closeWebApplicationContext(ServletContext servletContext) { servletContext.log("Closing Spring root WebApplicationContext"); try { if (this.context instanceof ConfigurableWebApplicationContext) { ((ConfigurableWebApplicationContext) this.context).close(); } } finally { ClassLoader ccl = Thread.currentThread().getContextClassLoader(); if (ccl == ContextLoader.class.getClassLoader()) { currentContext = null; } else if (ccl != null) { currentContextPerThread.remove(ccl); } servletContext.removeAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE); } }
/** * Close Spring's web application context for the given servlet context. If * the default {@link #loadParentContext(ServletContext)}implementation, * which uses ContextSingletonBeanFactoryLocator, has loaded any shared * parent context, release one reference to that shared parent context. * <p>If overriding {@link #loadParentContext(ServletContext)}, you may have * to override this method as well. */ public void closeWebApplicationContext(ServletContext servletContext) { servletContext.log("Closing Spring root WebApplicationContext"); try { if (this.context instanceof ConfigurableWebApplicationContext) { ((ConfigurableWebApplicationContext) this.context).close(); } } finally { if (this.parentContextRef != null) { this.parentContextRef.release(); } } }
public synchronized void reload() { ConfigurableWebApplicationContext newAppContext = null; try { newAppContext = BeanUtils.instantiateClass(XmlWebApplicationContext.class); } catch (BeanInstantiationException e) { throw new RuntimeException("Can't create Spring application context.", e); } newAppContext.setParent(this.appContext.getParent()); newAppContext.setServletContext(this.appContext.getServletContext()); this.appContext.close(); this.appContext = newAppContext; this.appContext.refresh(); }
appCtx.close();