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


Java ServletContextListener.contextDestroyed方法代码示例

本文整理汇总了Java中javax.servlet.ServletContextListener.contextDestroyed方法的典型用法代码示例。如果您正苦于以下问题:Java ServletContextListener.contextDestroyed方法的具体用法?Java ServletContextListener.contextDestroyed怎么用?Java ServletContextListener.contextDestroyed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.servlet.ServletContextListener的用法示例。


在下文中一共展示了ServletContextListener.contextDestroyed方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testContextLoaderListenerWithDefaultContext

import javax.servlet.ServletContextListener; //导入方法依赖的package包/类
@Test
public void testContextLoaderListenerWithDefaultContext() {
	MockServletContext sc = new MockServletContext("");
	sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
			"/org/springframework/web/context/WEB-INF/applicationContext.xml " +
			"/org/springframework/web/context/WEB-INF/context-addition.xml");
	ServletContextListener listener = new ContextLoaderListener();
	ServletContextEvent event = new ServletContextEvent(sc);
	listener.contextInitialized(event);
	WebApplicationContext context = (WebApplicationContext) sc.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
	assertTrue("Correct WebApplicationContext exposed in ServletContext", context instanceof XmlWebApplicationContext);
	assertTrue(WebApplicationContextUtils.getRequiredWebApplicationContext(sc) instanceof XmlWebApplicationContext);
	LifecycleBean lb = (LifecycleBean) context.getBean("lifecycle");
	assertTrue("Has father", context.containsBean("father"));
	assertTrue("Has rod", context.containsBean("rod"));
	assertTrue("Has kerry", context.containsBean("kerry"));
	assertTrue("Not destroyed", !lb.isDestroyed());
	assertFalse(context.containsBean("beans1.bean1"));
	assertFalse(context.containsBean("beans1.bean2"));
	listener.contextDestroyed(event);
	assertTrue("Destroyed", lb.isDestroyed());
	assertNull(sc.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE));
	assertNull(WebApplicationContextUtils.getWebApplicationContext(sc));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:25,代码来源:ContextLoaderTests.java

示例2: testServletContextListener

import javax.servlet.ServletContextListener; //导入方法依赖的package包/类
private void testServletContextListener(ServletContext servletContext) throws Exception {
    ResteasyAutoConfiguration resteasyAutoConfiguration = new ResteasyAutoConfiguration();
    BeanFactoryPostProcessor beanFactoryPostProcessor = ResteasyAutoConfiguration.springBeanProcessor();
    ServletContextListener servletContextListener = resteasyAutoConfiguration.resteasyBootstrapListener(beanFactoryPostProcessor);
    Assert.assertNotNull(servletContextListener);

    ServletContextEvent sce = new ServletContextEvent(servletContext);
    servletContextListener.contextInitialized(sce);

    ResteasyProviderFactory servletContextProviderFactory = (ResteasyProviderFactory) servletContext.getAttribute(ResteasyProviderFactory.class.getName());
    Dispatcher servletContextDispatcher = (Dispatcher) servletContext.getAttribute(Dispatcher.class.getName());
    Registry servletContextRegistry = (Registry) servletContext.getAttribute(Registry.class.getName());

    Assert.assertNotNull(servletContextProviderFactory);
    Assert.assertNotNull(servletContextDispatcher);
    Assert.assertNotNull(servletContextRegistry);

    // Exercising fully cobertura branch coverage
    servletContextListener.contextDestroyed(sce);
    ServletContextListener servletContextListener2 = resteasyAutoConfiguration.resteasyBootstrapListener(beanFactoryPostProcessor);
    servletContextListener2.contextDestroyed(sce);
}
 
开发者ID:paypal,项目名称:resteasy-spring-boot,代码行数:23,代码来源:ResteasyAutoConfigurationTest.java

示例3: contextDestroyed

import javax.servlet.ServletContextListener; //导入方法依赖的package包/类
public void contextDestroyed(ServletContextEvent sce) {
    if (ctx == null) {
        logger.warn("cannot find applicationContext");

        return;
    }

    Collection<ServletContextListener> servletContextListeners = ctx
            .getBeansOfType(ServletContextListener.class).values();

    for (ServletContextListener servletContextListener : servletContextListeners) {
        servletContextListener.contextDestroyed(sce);
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:15,代码来源:ProxyServletListener.java

示例4: listenerStop

import javax.servlet.ServletContextListener; //导入方法依赖的package包/类
/**
 * Send an application stop event to all interested listeners.
 * Return <code>true</code> if all events were sent successfully,
 * or <code>false</code> otherwise.
 */
public boolean listenerStop() {

    if (debug >= 1)
        log("Sending application stop events");

    boolean ok = true;
    Object listeners[] = getApplicationListeners();
    if (listeners == null)
        return (ok);
    ServletContextEvent event =
      new ServletContextEvent(getServletContext());
    for (int i = 0; i < listeners.length; i++) {
        int j = (listeners.length - 1) - i;
        if (listeners[j] == null)
            continue;
        if (!(listeners[j] instanceof ServletContextListener))
            continue;
        ServletContextListener listener =
            (ServletContextListener) listeners[j];
        try {
            fireContainerEvent("beforeContextDestroyed", listener);
            listener.contextDestroyed(event);
            fireContainerEvent("beforeContextDestroyed", listener);
        } catch (Throwable t) {
            fireContainerEvent("beforeContextDestroyed", listener);
            log(sm.getString("standardContext.listenerStop",
                             listeners[j].getClass().getName()), t);
            ok = false;
        }
    }
    setApplicationListeners(null);
    return (ok);

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:40,代码来源:StandardContext.java

示例5: testContextLoaderWithDefaultContextAndParent

import javax.servlet.ServletContextListener; //导入方法依赖的package包/类
@Test
public void testContextLoaderWithDefaultContextAndParent() throws Exception {
	MockServletContext sc = new MockServletContext("");
	sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM,
			"/org/springframework/web/context/WEB-INF/applicationContext.xml "
					+ "/org/springframework/web/context/WEB-INF/context-addition.xml");
	sc.addInitParameter(ContextLoader.LOCATOR_FACTORY_SELECTOR_PARAM,
			"classpath:org/springframework/web/context/ref1.xml");
	sc.addInitParameter(ContextLoader.LOCATOR_FACTORY_KEY_PARAM, "a.qualified.name.of.some.sort");
	ServletContextListener listener = new ContextLoaderListener();
	ServletContextEvent event = new ServletContextEvent(sc);
	listener.contextInitialized(event);
	WebApplicationContext context = (WebApplicationContext) sc.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
	assertTrue("Correct WebApplicationContext exposed in ServletContext",
			context instanceof XmlWebApplicationContext);
	LifecycleBean lb = (LifecycleBean) context.getBean("lifecycle");
	assertTrue("Has father", context.containsBean("father"));
	assertTrue("Has rod", context.containsBean("rod"));
	assertTrue("Has kerry", context.containsBean("kerry"));
	assertTrue("Not destroyed", !lb.isDestroyed());
	assertTrue(context.containsBean("beans1.bean1"));
	assertTrue(context.isTypeMatch("beans1.bean1", org.springframework.beans.factory.access.TestBean.class));
	assertTrue(context.containsBean("beans1.bean2"));
	assertTrue(context.isTypeMatch("beans1.bean2", org.springframework.beans.factory.access.TestBean.class));
	listener.contextDestroyed(event);
	assertTrue("Destroyed", lb.isDestroyed());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:28,代码来源:ContextLoaderTests.java

示例6: destroy

import javax.servlet.ServletContextListener; //导入方法依赖的package包/类
@Override
public void destroy() {
    // Call registered WebContextListeners
    for (ServletContextListener contextListener : HANDLER.contextListeners) {
        contextListener.contextDestroyed(new ServletContextEvent(getServletContext()));
    }
    super.destroy();
}
 
开发者ID:jefalbino,项目名称:jsmart-web,代码行数:9,代码来源:ServletControl.java

示例7: removeListeners

import javax.servlet.ServletContextListener; //导入方法依赖的package包/类
/**Removes and destroys all registered {@link ServletContextListener}. */
public MockServletContext removeListeners() {
    ServletContextEvent e = new ServletContextEvent(this);
    for (ServletContextListener l : listeners) {
        l.contextDestroyed(e);
    }
    listeners.clear();
    return this;
}
 
开发者ID:scarcher2,项目名称:stripes,代码行数:10,代码来源:MockServletContext.java

示例8: contextDestroyed

import javax.servlet.ServletContextListener; //导入方法依赖的package包/类
public void contextDestroyed(ServletContextEvent sce) {
  for (ServletContextListener listener : listeners) {
    listener.contextDestroyed(sce);
  }
}
 
开发者ID:bboypscmylife,项目名称:opengse,代码行数:6,代码来源:ServletContextListenerList.java

示例9: removedService

import javax.servlet.ServletContextListener; //导入方法依赖的package包/类
@Override
public void removedService(ServiceReference<ServletContextListener> reference, ServletContextListener service) {
  service.contextDestroyed(new ServletContextEvent(servletContext));
  super.removedService(reference, service);
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:6,代码来源:ListenerTracker.java

示例10: contextDestroyed

import javax.servlet.ServletContextListener; //导入方法依赖的package包/类
void contextDestroyed(ServletContextEvent sce) {
	for (ServletContextListener listeners : bootables) {
		listeners.contextDestroyed(sce);
	}
}
 
开发者ID:tamerman,项目名称:mobile-starting-framework,代码行数:6,代码来源:Bootables.java


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