List of usage examples for org.springframework.web.context.support GenericWebApplicationContext registerShutdownHook
@Override public void registerShutdownHook()
From source file:com.example.springsecurity.web.controllers.GenericWebContextLoader.java
protected void loadBeanDefinitions(GenericWebApplicationContext context, String[] locations) { new XmlBeanDefinitionReader(context).loadBeanDefinitions(locations); AnnotationConfigUtils.registerAnnotationConfigProcessors(context); context.refresh();// ww w . jav a2s. c o m context.registerShutdownHook(); }
From source file:fr.letitzen.demo.web.GenericWebXmlContextLoader.java
public ApplicationContext loadContext(String... locations) throws Exception { GenericWebApplicationContext context = new GenericWebApplicationContext(); prepareContext(context);//from w ww . ja v a 2 s . co m new XmlBeanDefinitionReader(context).loadBeanDefinitions(locations); AnnotationConfigUtils.registerAnnotationConfigProcessors(context); context.refresh(); context.registerShutdownHook(); return context; }
From source file:mx.edu.um.mateo.general.test.GenericWebXmlContextLoader.java
@Override public ApplicationContext loadContext(String... locations) throws Exception { GenericWebApplicationContext context = new GenericWebApplicationContext(); prepareContext(context);//from w ww .ja v a 2 s .co m new XmlBeanDefinitionReader(context).loadBeanDefinitions(locations); AnnotationConfigUtils.registerAnnotationConfigProcessors(context); context.refresh(); context.registerShutdownHook(); return context; }
From source file:com.autentia.wuija.spring.TestContextLoader.java
@Override public final ConfigurableApplicationContext loadContext(String... locations) throws Exception { if (log.isDebugEnabled()) { log.debug("Loading ApplicationContext for locations [" + StringUtils.arrayToCommaDelimitedString(locations) + "]."); }//from ww w .j av a 2 s . c o m final GenericWebApplicationContext context = new GenericWebApplicationContext(); customizeBeanFactory(context.getDefaultListableBeanFactory()); createBeanDefinitionReader(context).loadBeanDefinitions(locations); AnnotationConfigUtils.registerAnnotationConfigProcessors(context); customizeContext(context); context.refresh(); context.registerShutdownHook(); return context; }
From source file:fr.letitzen.demo.web.GenericWebXmlContextLoader.java
public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception { GenericWebApplicationContext context = new GenericWebApplicationContext(); context.getEnvironment().setActiveProfiles(mergedConfig.getActiveProfiles()); prepareContext(context);//from w w w . j ava 2 s. c om new XmlBeanDefinitionReader(context).loadBeanDefinitions(mergedConfig.getLocations()); AnnotationConfigUtils.registerAnnotationConfigProcessors(context); context.refresh(); context.registerShutdownHook(); return context; }
From source file:mx.edu.um.mateo.general.test.GenericWebXmlContextLoader.java
@Override public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception { GenericWebApplicationContext context = new GenericWebApplicationContext(); context.getEnvironment().setActiveProfiles(mergedConfig.getActiveProfiles()); prepareContext(context);// ww w . ja v a2s. c om new XmlBeanDefinitionReader(context).loadBeanDefinitions(mergedConfig.getLocations()); AnnotationConfigUtils.registerAnnotationConfigProcessors(context); context.refresh(); context.registerShutdownHook(); return context; }
From source file:com.wbss.mycoffee.in.helper.spring.WebContextLoader.java
@Override public ApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception { final GenericWebApplicationContext webContext = new GenericWebApplicationContext(); SERVLET_CONTEXT.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, webContext); webContext.setServletContext(SERVLET_CONTEXT); createBeanDefinitionReader(webContext).loadBeanDefinitions(mergedConfig.getLocations()); AnnotationConfigUtils.registerAnnotationConfigProcessors(webContext); webContext.refresh();//w ww. j av a 2s . co m webContext.registerShutdownHook(); return webContext; }
From source file:org.parancoe.web.test.junit4.WebXmlContextLoader.java
/** * Loads a Spring ApplicationContext from the supplied * <code>locations</code>. and creates a standard {@link GenericWebApplicationContext} instance. * * @return a new application context//ww w . jav a2 s. c o m * @see org.springframework.test.context.ContextLoader#loadContext * @see GenericWebApplicationContext * @see #createBeanDefinitionReader(GenericApplicationContext) * @see BeanDefinitionReader */ @Override public final ConfigurableApplicationContext loadContext(String... locations) throws Exception { if (logger.isDebugEnabled()) { logger.debug("Loading ApplicationContext for locations [{}].", StringUtils.arrayToCommaDelimitedString(locations)); } GenericWebApplicationContext context = new GenericWebApplicationContext(); createBeanDefinitionReader(context).loadBeanDefinitions(locations); MockServletContext servletContext = new MockServletContext(); servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context); context.setServletContext(servletContext); AnnotationConfigUtils.registerAnnotationConfigProcessors(context); context.refresh(); context.registerShutdownHook(); return context; }
From source file:org.springframework.test.context.support.AbstractGenericWebContextLoader.java
/** * TODO [SPR-9864] Document overridden loadContext(MergedContextConfiguration). * * @see org.springframework.test.context.SmartContextLoader#loadContext(org.springframework.test.context.MergedContextConfiguration) *//*from www .j a v a 2 s . c om*/ public final ConfigurableApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws Exception { if (!(mergedConfig instanceof WebMergedContextConfiguration)) { throw new IllegalArgumentException( String.format( "Cannot load WebApplicationContext from non-web merged context configuration %s. " + "Consider annotating your test class with @WebAppConfiguration.", mergedConfig)); } WebMergedContextConfiguration webMergedConfig = (WebMergedContextConfiguration) mergedConfig; if (logger.isDebugEnabled()) { logger.debug(String.format("Loading WebApplicationContext for merged context configuration %s.", webMergedConfig)); } GenericWebApplicationContext context = new GenericWebApplicationContext(); configureWebResources(context, webMergedConfig); prepareContext(context, webMergedConfig); customizeBeanFactory(context.getDefaultListableBeanFactory(), webMergedConfig); loadBeanDefinitions(context, webMergedConfig); AnnotationConfigUtils.registerAnnotationConfigProcessors(context); customizeContext(context, webMergedConfig); context.refresh(); context.registerShutdownHook(); return context; }
From source file:org.springframework.test.context.support.WebApplicationContextLoader.java
public ApplicationContext loadContext(String... locations) throws Exception { if (logger.isDebugEnabled()) { logger.debug("Loading ApplicationContext for locations [" + StringUtils.arrayToCommaDelimitedString(locations) + "]."); }//from w ww .j ava 2s. c o m GenericWebApplicationContext context = new GenericWebApplicationContext(); prepareContext(context); customizeBeanFactory(context.getDefaultListableBeanFactory()); createBeanDefinitionReader(context).loadBeanDefinitions(locations); AnnotationConfigUtils.registerAnnotationConfigProcessors(context); customizeContext(context); context.refresh(); context.registerShutdownHook(); return context; }