Java 类org.springframework.web.context.ContextCleanupListener 实例源码

项目:spring4-understanding    文件:PortletApplicationContextScopeTests.java   
@Test
public void testApplicationScope() {
    ConfigurablePortletApplicationContext ac = initApplicationContext(WebApplicationContext.SCOPE_APPLICATION);
    assertNull(ac.getPortletContext().getAttribute(NAME));
    DerivedTestBean bean = ac.getBean(NAME, DerivedTestBean.class);
    assertSame(bean, ac.getPortletContext().getAttribute(NAME));
    assertSame(bean, ac.getBean(NAME));
    new ContextCleanupListener().contextDestroyed(new ServletContextEvent(ac.getServletContext()));
    assertTrue(bean.wasDestroyed());
}
项目:spring4-understanding    文件:WebApplicationContextScopeTests.java   
@Test
public void testApplicationScope() {
    WebApplicationContext ac = initApplicationContext(WebApplicationContext.SCOPE_APPLICATION);
    assertNull(ac.getServletContext().getAttribute(NAME));
    DerivedTestBean bean = ac.getBean(NAME, DerivedTestBean.class);
    assertSame(bean, ac.getServletContext().getAttribute(NAME));
    assertSame(bean, ac.getBean(NAME));
    new ContextCleanupListener().contextDestroyed(new ServletContextEvent(ac.getServletContext()));
    assertTrue(bean.wasDestroyed());
}
项目:class-guard    文件:PortletApplicationContextScopeTests.java   
@Test
public void testApplicationScope() {
    ConfigurablePortletApplicationContext ac = initApplicationContext(WebApplicationContext.SCOPE_APPLICATION);
    assertNull(ac.getPortletContext().getAttribute(NAME));
    DerivedTestBean bean = ac.getBean(NAME, DerivedTestBean.class);
    assertSame(bean, ac.getPortletContext().getAttribute(NAME));
    assertSame(bean, ac.getBean(NAME));
    new ContextCleanupListener().contextDestroyed(new ServletContextEvent(ac.getServletContext()));
    assertTrue(bean.wasDestroyed());
}
项目:class-guard    文件:WebApplicationContextScopeTests.java   
@Test
public void testApplicationScope() {
    WebApplicationContext ac = initApplicationContext(WebApplicationContext.SCOPE_APPLICATION);
    assertNull(ac.getServletContext().getAttribute(NAME));
    DerivedTestBean bean = ac.getBean(NAME, DerivedTestBean.class);
    assertSame(bean, ac.getServletContext().getAttribute(NAME));
    assertSame(bean, ac.getBean(NAME));
    new ContextCleanupListener().contextDestroyed(new ServletContextEvent(ac.getServletContext()));
    assertTrue(bean.wasDestroyed());
}
项目:wicket-spring-jpa-bootstrap-boilerplate    文件:WebAppInitializer.java   
@Override
public void onStartup(ServletContext sc) throws ServletException {

  log.debug("web starting up...");

  // Create the 'root' Spring application context
  AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
  ctx.register(SpringConfiguration.class);
  ctx.refresh();

  // Register the Spring Context in the ServletContext
  sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ctx);

  // Request Listener
  sc.addListener(new RequestContextListener());

  // Manages the lifecycle
  sc.addListener(new ContextCleanupListener());

  sc.addListener(new HttpSessionEventPublisher());


  log.info("web initialized.");
}