Search in sources :

Example 96 with WebApplicationContext

use of org.springframework.web.context.WebApplicationContext in project Activiti by Activiti.

the class WebConfigurer 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");
}
Also used : AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext) WebApplicationContext(org.springframework.web.context.WebApplicationContext) AnnotationConfigWebApplicationContext(org.springframework.web.context.support.AnnotationConfigWebApplicationContext)

Example 97 with WebApplicationContext

use of org.springframework.web.context.WebApplicationContext in project Asqatasun by Asqatasun.

the class ConfigPropertiesExposerListener method contextInitialized.

@Override
public void contextInitialized(ServletContextEvent sce) {
    // TODO add ability to configure non default values via serveltContexParams
    ServletContext servletContext = sce.getServletContext();
    WebApplicationContext context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
    ExposablePropertyPlaceholderConfigurer configurer = (ExposablePropertyPlaceholderConfigurer) context.getBean(propertiesBeanName);
    sce.getServletContext().setAttribute(contextProperty, configurer.getResolvedProps());
}
Also used : ServletContext(javax.servlet.ServletContext) WebApplicationContext(org.springframework.web.context.WebApplicationContext)

Example 98 with WebApplicationContext

use of org.springframework.web.context.WebApplicationContext in project goci by EBISPOT.

the class PussycatAwareHttpSessionListener method sessionDestroyed.

@Override
public void sessionDestroyed(HttpSessionEvent httpSessionEvent) {
    HttpSession session = httpSessionEvent.getSession();
    ServletContext servletContext = session.getServletContext();
    WebApplicationContext appContext = (WebApplicationContext) servletContext.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
    PussycatManager pussycatManager = appContext.getBean("pussycatManager", PussycatManager.class);
    getLog().debug("HttpSession '" + session.getId() + "' destroyed - attempting to unbind resources");
    boolean unbound = pussycatManager.unbindResources(session);
    getLog().debug("Unbinding resources for HttpSession '" + session.getId() + "' " + (unbound ? "ok" : "failed"));
}
Also used : PussycatManager(uk.ac.ebi.spot.goci.pussycat.manager.PussycatManager) HttpSession(javax.servlet.http.HttpSession) ServletContext(javax.servlet.ServletContext) WebApplicationContext(org.springframework.web.context.WebApplicationContext)

Example 99 with WebApplicationContext

use of org.springframework.web.context.WebApplicationContext in project symmetric-ds by JumpMind.

the class SymmetricWebServer method getRestService.

public RestService getRestService() {
    ServletContext servletContext = getServletContext();
    WebApplicationContext rootContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
    return rootContext.getBean(RestService.class);
}
Also used : ServletContext(javax.servlet.ServletContext) WebApplicationContext(org.springframework.web.context.WebApplicationContext)

Example 100 with WebApplicationContext

use of org.springframework.web.context.WebApplicationContext in project dhis2-core by dhis2.

the class StartupListener method contextInitialized.

// -------------------------------------------------------------------------
// ServletContextListener implementation
// -------------------------------------------------------------------------
@Override
public void contextInitialized(ServletContextEvent event) {
    WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
    StartupRoutineExecutor startupRoutineExecutor = (StartupRoutineExecutor) applicationContext.getBean(StartupRoutineExecutor.ID);
    try {
        startupRoutineExecutor.execute();
    } catch (Exception ex) {
        log.error(DebugUtils.getStackTrace(ex));
        throw new RuntimeException("Failed to run startup routines: " + ex.getMessage(), ex);
    }
}
Also used : SQLException(java.sql.SQLException) WebApplicationContext(org.springframework.web.context.WebApplicationContext)

Aggregations

WebApplicationContext (org.springframework.web.context.WebApplicationContext)100 Test (org.junit.Test)32 ServletContext (javax.servlet.ServletContext)17 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)15 MockHttpServletResponse (org.springframework.mock.web.test.MockHttpServletResponse)13 ApplicationContext (org.springframework.context.ApplicationContext)11 GenericWebApplicationContext (org.springframework.web.context.support.GenericWebApplicationContext)11 HashMap (java.util.HashMap)9 StaticWebApplicationContext (org.springframework.web.context.support.StaticWebApplicationContext)9 MockServletContext (org.springframework.mock.web.test.MockServletContext)8 ConfigurableWebApplicationContext (org.springframework.web.context.ConfigurableWebApplicationContext)7 Filter (javax.servlet.Filter)6 HttpServletResponse (javax.servlet.http.HttpServletResponse)6 AnnotationConfigWebApplicationContext (org.springframework.web.context.support.AnnotationConfigWebApplicationContext)6 Binding (groovy.lang.Binding)5 BeanBuilder (hudson.util.spring.BeanBuilder)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 DispatcherServlet (org.springframework.web.servlet.DispatcherServlet)5 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)4 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)4