本文整理汇总了Java中org.springframework.web.context.ContextCleanupListener类的典型用法代码示例。如果您正苦于以下问题:Java ContextCleanupListener类的具体用法?Java ContextCleanupListener怎么用?Java ContextCleanupListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContextCleanupListener类属于org.springframework.web.context包,在下文中一共展示了ContextCleanupListener类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testApplicationScope
import org.springframework.web.context.ContextCleanupListener; //导入依赖的package包/类
@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());
}
示例2: testApplicationScope
import org.springframework.web.context.ContextCleanupListener; //导入依赖的package包/类
@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());
}
示例3: onStartup
import org.springframework.web.context.ContextCleanupListener; //导入依赖的package包/类
@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.");
}