Examples of ContextLoaderListener


Examples of org.springframework.web.context.ContextLoaderListener

        MongoDbRepositoryConfig.class
        //GemfireRepositoryConfig.class,
        //Neo4jRepositoryConfig.class
    );

    servletContext.addListener(new ContextLoaderListener(rootCtx));
    //    servletContext.addFilter("springSecurity", DelegatingFilterProxy.class);
    //    servletContext.getFilterRegistration("springSecurity").addMappingForUrlPatterns(
    //        EnumSet.of(DispatcherType.REQUEST),
    //        false,
    //        "/*"
 
View Full Code Here

Examples of org.springframework.web.context.ContextLoaderListener

        ServletRegistration.Dynamic dispatcher = servletContext.addServlet(DISPATCHER_SERVLET_NAME, new DispatcherServlet(rootContext));
        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping(DISPATCHER_SERVLET_MAPPING);

        servletContext.addListener(new ContextLoaderListener(rootContext));
    }
View Full Code Here

Examples of org.springframework.web.context.ContextLoaderListener

    }
   
    public void test() throws Exception {
        ContextHandler context = new ContextHandler();
        context.setContextPath("/test");
        context.setEventListeners(new EventListener[] { new ContextLoaderListener() });
        Map initParams = new HashMap();
        initParams.put("contextConfigLocation", "classpath:org/apache/servicemix/http/spring-web.xml");
        initParams.put("contextClass", XmlWebApplicationContext.class.getName());
        context.setInitParams(initParams);
        ServletHolder holder = new ServletHolder();
View Full Code Here

Examples of org.springframework.web.context.ContextLoaderListener

  @Test
  public void abstractRefreshableWAC_respectsProgrammaticConfigLocations() {
    XmlWebApplicationContext ctx = new XmlWebApplicationContext();
    ctx.setConfigLocation("programmatic.xml");
    ContextLoaderListener cll = new ContextLoaderListener(ctx);

    MockServletContext sc = new MockServletContext();

    try {
      cll.contextInitialized(new ServletContextEvent(sc));
      fail("expected exception");
    } catch (Throwable t) {
      // assert that an attempt was made to load the correct XML
      assertTrue(t.getMessage(), t.getMessage().endsWith(
          "Could not open ServletContext resource [/programmatic.xml]"));
View Full Code Here

Examples of org.springframework.web.context.ContextLoaderListener

   */
  @Test
  public void abstractRefreshableWAC_respectsInitParam_overProgrammaticConfigLocations() {
    XmlWebApplicationContext ctx = new XmlWebApplicationContext();
    ctx.setConfigLocation("programmatic.xml");
    ContextLoaderListener cll = new ContextLoaderListener(ctx);

    MockServletContext sc = new MockServletContext();
    sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, "from-init-param.xml");

    try {
      cll.contextInitialized(new ServletContextEvent(sc));
      fail("expected exception");
    } catch (Throwable t) {
      // assert that an attempt was made to load the correct XML
      assertTrue(t.getMessage(), t.getMessage().endsWith(
          "Could not open ServletContext resource [/from-init-param.xml]"));
View Full Code Here

Examples of org.springframework.web.context.ContextLoaderListener

   */
  @Test
  public void abstractRefreshableWAC_fallsBackToInitParam() {
    XmlWebApplicationContext ctx = new XmlWebApplicationContext();
    //ctx.setConfigLocation("programmatic.xml"); // nothing set programmatically
    ContextLoaderListener cll = new ContextLoaderListener(ctx);

    MockServletContext sc = new MockServletContext();
    sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, "from-init-param.xml");

    try {
      cll.contextInitialized(new ServletContextEvent(sc));
      fail("expected exception");
    } catch (Throwable t) {
      // assert that an attempt was made to load the correct XML
      assertTrue(t.getMessage().endsWith(
          "Could not open ServletContext resource [/from-init-param.xml]"));
View Full Code Here

Examples of org.springframework.web.context.ContextLoaderListener

      protected String[] getDefaultConfigLocations() {
        return new String[] { "/WEB-INF/custom.xml" };
      }
    };
    //ctx.setConfigLocation("programmatic.xml"); // nothing set programmatically
    ContextLoaderListener cll = new ContextLoaderListener(ctx);

    MockServletContext sc = new MockServletContext();
    sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, "from-init-param.xml");

    try {
      cll.contextInitialized(new ServletContextEvent(sc));
      fail("expected exception");
    } catch (Throwable t) {
      // assert that an attempt was made to load the correct XML
      System.out.println(t.getMessage());
      assertTrue(t.getMessage().endsWith(
View Full Code Here

Examples of org.springframework.web.context.ContextLoaderListener

   */
  @Test
  public void abstractRefreshableWAC_fallsBackToConventionBasedNaming() {
    XmlWebApplicationContext ctx = new XmlWebApplicationContext();
    //ctx.setConfigLocation("programmatic.xml"); // nothing set programmatically
    ContextLoaderListener cll = new ContextLoaderListener(ctx);

    MockServletContext sc = new MockServletContext();
    // no init-param set
    //sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, "from-init-param.xml");

    try {
      cll.contextInitialized(new ServletContextEvent(sc));
      fail("expected exception");
    } catch (Throwable t) {
      // assert that an attempt was made to load the correct XML
      System.out.println(t.getMessage());
      assertTrue(t.getMessage().endsWith(
View Full Code Here

Examples of org.springframework.web.context.ContextLoaderListener

   * Ensure that ContextLoaderListener and GenericWebApplicationContext interact nicely.
   */
  @Test
  public void genericWAC() {
    GenericWebApplicationContext ctx = new GenericWebApplicationContext();
    ContextLoaderListener cll = new ContextLoaderListener(ctx);

    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(ctx);
    scanner.scan("bogus.pkg");

    cll.contextInitialized(new ServletContextEvent(new MockServletContext()));
  }
View Full Code Here

Examples of org.springframework.web.context.ContextLoaderListener

  public void annotationConfigWAC() {
    AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();

    ctx.scan("does.not.matter");

    ContextLoaderListener cll = new ContextLoaderListener(ctx);
    cll.contextInitialized(new ServletContextEvent(new MockServletContext()));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.