当前位置: 首页>>代码示例>>Java>>正文


Java ContextCleanupListener类代码示例

本文整理汇总了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());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:PortletApplicationContextScopeTests.java

示例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());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:WebApplicationContextScopeTests.java

示例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.");
}
 
开发者ID:mpostelnicu,项目名称:wicket-spring-jpa-bootstrap-boilerplate,代码行数:25,代码来源:WebAppInitializer.java


注:本文中的org.springframework.web.context.ContextCleanupListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。