use of org.springframework.web.context.support.AnnotationConfigWebApplicationContext in project Activiti by Activiti.
the class JPAWebConfigurer method contextDestroyed.
@Override
public void contextDestroyed(ServletContextEvent sce) {
log.info("Destroying Web application");
WebApplicationContext ac = WebApplicationContextUtils.getRequiredWebApplicationContext(sce.getServletContext());
AnnotationConfigWebApplicationContext gwac = (AnnotationConfigWebApplicationContext) ac;
gwac.close();
log.debug("Web application destroyed");
}
use of org.springframework.web.context.support.AnnotationConfigWebApplicationContext in project Activiti by Activiti.
the class WebConfigurer method contextInitialized.
@Override
public void contextInitialized(ServletContextEvent sce) {
ServletContext servletContext = sce.getServletContext();
log.debug("Configuring Spring root application context");
AnnotationConfigWebApplicationContext rootContext = null;
if (context == null) {
rootContext = new AnnotationConfigWebApplicationContext();
rootContext.register(ApplicationConfiguration.class);
rootContext.refresh();
} else {
rootContext = context;
}
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, rootContext);
EnumSet<DispatcherType> disps = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC);
initSpring(servletContext, rootContext);
initSpringSecurity(servletContext, disps);
log.debug("Web application fully configured");
}
use of org.springframework.web.context.support.AnnotationConfigWebApplicationContext in project spring-boot by spring-projects.
the class WebServicesAutoConfigurationTests method load.
private void load(Class<?> config, String... environment) {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.setServletContext(new MockServletContext());
EnvironmentTestUtils.addEnvironment(context, environment);
context.register(config);
context.refresh();
this.context = context;
}
use of org.springframework.web.context.support.AnnotationConfigWebApplicationContext in project spring-boot by spring-projects.
the class ConditionalOnNotWebApplicationTests method testNotWebApplicationWithServletContext.
@Test
public void testNotWebApplicationWithServletContext() {
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
ctx.register(NotWebApplicationConfiguration.class);
ctx.setServletContext(new MockServletContext());
ctx.refresh();
this.context = ctx;
assertThat(this.context.getBeansOfType(String.class)).isEmpty();
}
use of org.springframework.web.context.support.AnnotationConfigWebApplicationContext in project spring-boot by spring-projects.
the class SpringDataWebAutoConfigurationTests method webSupportIsAutoConfiguredInWebApplicationContexts.
@Test
public void webSupportIsAutoConfiguredInWebApplicationContexts() {
this.context = new AnnotationConfigWebApplicationContext();
((AnnotationConfigWebApplicationContext) this.context).register(SpringDataWebAutoConfiguration.class);
this.context.refresh();
((AnnotationConfigWebApplicationContext) this.context).setServletContext(new MockServletContext());
Map<String, PageableHandlerMethodArgumentResolver> beans = this.context.getBeansOfType(PageableHandlerMethodArgumentResolver.class);
assertThat(beans).hasSize(1);
}
Aggregations