@After public void destroy() { this.contextLoader.closeWebApplicationContext(this.servletContext); }
@Test public void updateTargetUrlWithContextLoader() throws Exception { StaticWebApplicationContext wac = new StaticWebApplicationContext(); wac.registerSingleton("requestDataValueProcessor", RequestDataValueProcessorWrapper.class); MockServletContext servletContext = new MockServletContext(); ContextLoader contextLoader = new ContextLoader(wac); contextLoader.initWebApplicationContext(servletContext); try { RequestDataValueProcessor mockProcessor = mock(RequestDataValueProcessor.class); wac.getBean(RequestDataValueProcessorWrapper.class).setRequestDataValueProcessor(mockProcessor); RedirectView rv = new RedirectView(); rv.setUrl("/path"); given(mockProcessor.processUrl(request, "/path")).willReturn("/path?key=123"); rv.render(new ModelMap(), request, response); verify(mockProcessor).processUrl(request, "/path"); } finally { contextLoader.closeWebApplicationContext(servletContext); } }
/**`` * Do everything to get openmrs going. * * @param servletContext the servletContext from the filterconfig * @see Listener#startOpenmrs(ServletContext) */ private void startOpenmrs(ServletContext servletContext) throws Exception { // start spring // after this point, all errors need to also call: contextLoader.closeWebApplicationContext(event.getServletContext()) // logic copied from org.springframework.web.context.ContextLoaderListener ContextLoader contextLoader = new ContextLoader(); contextLoader.initWebApplicationContext(servletContext); try { WebDaemon.startOpenmrs(servletContext); } catch (Exception exception) { contextLoader.closeWebApplicationContext(servletContext); throw exception; } }
@Override public void closeWebApplicationContext(ServletContext servletContext) { super.closeWebApplicationContext(servletContext); }
Context.shutdown(); WebModuleUtil.shutdownModules(filterConfig.getServletContext()); contextLoader.closeWebApplicationContext(filterConfig.getServletContext()); return; Context.shutdown(); WebModuleUtil.shutdownModules(filterConfig.getServletContext()); contextLoader.closeWebApplicationContext(filterConfig.getServletContext()); reportError(ErrorMessageConstants.ERROR_COMPLETE_STARTUP, DEFAULT_PAGE, e.getMessage()); log.warn("Unable to complete the startup.", e);
public void destroy() { this.contextLoader.closeWebApplicationContext(sc); }
/** * Close the root web application context. */ public void contextDestroyed(ServletContextEvent event) { if (this.contextLoader != null) { this.contextLoader.closeWebApplicationContext(event.getServletContext()); } }
/** * Close the root web application context. */ public void destroy() { if (this.contextLoader != null) { this.contextLoader.closeWebApplicationContext(getServletContext()); } }
public synchronized void refresh() { ContextLoader loader = new BootstrappedContextLoader(); // if we have an existing spring context, ensure we close it properly ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext()); if (ctx != null) { loader.closeWebApplicationContext(getServletContext()); } loader.initWebApplicationContext(getServletContext()); if (getApplicationContext() == null) { setApplicationContext(WebApplicationContextUtils.getWebApplicationContext(getServletContext())); } contextReloaded(); } }