Example usage for org.springframework.web.context ContextLoaderListener contextInitialized

List of usage examples for org.springframework.web.context ContextLoaderListener contextInitialized

Introduction

In this page you can find the example usage for org.springframework.web.context ContextLoaderListener contextInitialized.

Prototype

@Override
public void contextInitialized(ServletContextEvent event) 

Source Link

Document

Initialize the root web application context.

Usage

From source file:base.StripesWithoutMockTestFixture.java

private static void initServlet() {
    CTX.addInitParameter("contextConfigLocation", SPRING_APPLICATION_CONTEXT_XML);

    ContextLoaderListener springContextListener = new ContextLoaderListener();
    springContextListener.contextInitialized(new ServletContextEvent(CTX));

    CTX.setServlet(DispatcherServlet.class, "StripesDispatcher", null);
}

From source file:org.parancoe.web.plugin.PluginHelper.java

/**
 * invokes contextInitialized for every registered plugin
 *
 * @param evt/*from  w  ww  .ja v  a2s  . c o m*/
 */
public void invokePluginContextInitialized(ServletContextEvent evt) {
    for (ApplicationContextPlugin plugin : getApplicationContextPlugins()) {
        for (ContextLoaderListener listener : plugin.getContextLoaderListeners()) {
            try {
                listener.contextInitialized(evt);
            } catch (Exception e) {
                log.error("error in contextInitialized for plugin '" + plugin.getName() + "'", e);
            }
        }
    }
}

From source file:org.jasig.springframework.web.portlet.context.PortletContextLoaderTests.java

@Test
public void testContextLoaderWithCustomContextAndParent() throws Exception {
    MockServletContext sc = new MockServletContext("");
    sc.addInitParameter(ContextLoader.CONTEXT_CLASS_PARAM, StaticWebApplicationContext.class.getName());
    sc.addInitParameter(PortletContextLoader.CONTEXT_CLASS_PARAM,
            SimplePortletApplicationContext.class.getName());
    ContextLoaderListener servletListener = new ContextLoaderListener();
    ServletContextListener listener = new PortletContextLoaderListener();
    ServletContextEvent event = new ServletContextEvent(sc);

    servletListener.contextInitialized(event);
    listener.contextInitialized(event);/*from  www .  j a v a2 s .  c  o  m*/

    //initialize the portlet application context, needed because PortletContextLoaderListener.contextInitialized doesn't actually create
    //the portlet app context due to lack of PortletContext reference
    MockPortletContext pc = new MockPortletContext(sc);
    PortletApplicationContextUtils2.getPortletApplicationContext(pc);

    PortletApplicationContext wc = (PortletApplicationContext) pc
            .getAttribute(PortletApplicationContext.ROOT_PORTLET_APPLICATION_CONTEXT_ATTRIBUTE);
    assertTrue("Correct PortletApplicationContext exposed in PortletContext",
            wc instanceof SimplePortletApplicationContext);
}