List of usage examples for org.springframework.web.context ConfigurableWebApplicationContext registerShutdownHook
void registerShutdownHook();
From source file:com.xinlv.test.MockContextLoader.java
@Override public ConfigurableApplicationContext loadContext(String... locations) throws Exception { ConfigurableWebApplicationContext context = new XmlWebApplicationContext(); MockServletContext servletContext = new MockServletContext("") { @Override//ww w . j a va2s. co m public String getRealPath(String arg0) { return System.getProperty("java.io.tmpdir"); } }; servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context); context.setServletContext(servletContext); String configLocation = "/xinlv-test-context.xml"; context.setConfigLocation(configLocation); /*String[] configLocations = PortalContextLoaderListener.locateConfigLocations(locations); context.setConfigLocations(configLocations);*/ context.refresh(); context.registerShutdownHook(); return context; }
From source file:org.devproof.portal.test.MockContextLoader.java
@Override public ConfigurableApplicationContext loadContext(String... locations) throws Exception { registerResource(CommonConstants.JNDI_MAIL_SESSION, Session.getDefaultInstance(new Properties())); registerResource(CommonConstants.JNDI_PROP_EMAIL_DISABLED, "true"); registerResource(CommonConstants.JNDI_PROP_HIBERNATE_DIALECT, "org.hibernate.dialect.H2Dialect"); registerResource(CommonConstants.JNDI_PROP_HIBERNATE_SECOND_LEVEL_CACHE, "false"); registerResource(CommonConstants.JNDI_PROP_HIBERNATE_QUERY_CACHE, "false"); ConfigurableWebApplicationContext context = new XmlWebApplicationContext(); MockServletContext servletContext = new MockServletContext("") { @Override//from w ww.j a v a2 s. com public String getRealPath(String arg0) { return System.getProperty("java.io.tmpdir"); } }; servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context); context.setServletContext(servletContext); String[] configLocations = PortalContextLoaderListener.locateConfigLocations(locations); context.setConfigLocations(configLocations); context.refresh(); context.registerShutdownHook(); return context; }
From source file:ubic.gemma.web.util.WebContextLoader.java
@Override public ApplicationContext loadContext(String... locations) { if (WebContextLoader.logger.isDebugEnabled()) { WebContextLoader.logger.debug("Loading WebApplicationContext for locations [" + StringUtils.arrayToCommaDelimitedString(locations) + "]."); }// w ww . ja v a 2 s . co m ConfigurableWebApplicationContext context = new XmlWebApplicationContext(); context.setConfigLocations(locations); context.setServletContext(new MockServletContext("")); context.refresh(); AnnotationConfigUtils.registerAnnotationConfigProcessors((BeanDefinitionRegistry) context.getBeanFactory()); context.registerShutdownHook(); return context; }