Java 类org.springframework.boot.web.support.ServletContextApplicationContextInitializer 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringApplicationContextLoader.java   
private void addMockServletContext(
        List<ApplicationContextInitializer<?>> initializers,
        WebMergedContextConfiguration webConfiguration) {
    SpringBootMockServletContext servletContext = new SpringBootMockServletContext(
            webConfiguration.getResourceBasePath());
    initializers.add(0, new ServletContextApplicationContextInitializer(
            servletContext, true));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:SpringBootContextLoader.java   
private void addMockServletContext(
        List<ApplicationContextInitializer<?>> initializers,
        WebMergedContextConfiguration webConfiguration) {
    SpringBootMockServletContext servletContext = new SpringBootMockServletContext(
            webConfiguration.getResourceBasePath());
    initializers.add(0, new ServletContextApplicationContextInitializer(
            servletContext, true));
}
项目:spring-boot-concourse    文件:SpringApplicationContextLoader.java   
private void addMockServletContext(
        List<ApplicationContextInitializer<?>> initializers,
        WebMergedContextConfiguration webConfiguration) {
    SpringBootMockServletContext servletContext = new SpringBootMockServletContext(
            webConfiguration.getResourceBasePath());
    initializers.add(0, new ServletContextApplicationContextInitializer(
            servletContext, true));
}
项目:spring-boot-concourse    文件:SpringBootContextLoader.java   
private void addMockServletContext(
        List<ApplicationContextInitializer<?>> initializers,
        WebMergedContextConfiguration webConfiguration) {
    SpringBootMockServletContext servletContext = new SpringBootMockServletContext(
            webConfiguration.getResourceBasePath());
    initializers.add(0, new ServletContextApplicationContextInitializer(
            servletContext, true));
}
项目:para    文件:ParaServer.java   
/**
 * This is the initializing method when running ParaServer as WAR,
 * deployed to a servlet container.
 * @param sc the ServletContext instance
 * @param sources the application classes that will be scanned
 * @return the application context
 */
protected static WebApplicationContext runAsWAR(ServletContext sc, Object... sources) {
    ApplicationContext parent = null;
    Object object = sc.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
    if (object instanceof ApplicationContext) {
        logger.info("Root context already created (using as parent).");
        parent = (ApplicationContext) object;
        sc.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, null);
    }
    SpringApplicationBuilder application = new SpringApplicationBuilder(sources);
    if (parent != null) {
        application.initializers(new ParentContextApplicationContextInitializer(parent));
    }
    application.initializers(new ServletContextApplicationContextInitializer(sc));
    application.contextClass(AnnotationConfigEmbeddedWebApplicationContext.class);

    // entry point (WAR)
    application.profiles(Config.ENVIRONMENT);
    application.web(true);
    application.bannerMode(Banner.Mode.OFF);
    Para.initialize(getCoreModules());
    // Ensure error pages are registered
    application.sources(ErrorFilter.class);

    WebApplicationContext rootAppContext = (WebApplicationContext) application.run();

    if (rootAppContext != null) {
        sc.addListener(new ContextLoaderListener(rootAppContext) {
            @Override
            public void contextInitialized(ServletContextEvent event) {
                // no-op because the application context is already initialized
            }
        });
        sc.getSessionCookieConfig().setName("sess");
        sc.getSessionCookieConfig().setMaxAge(1);
        sc.getSessionCookieConfig().setHttpOnly(true);
        sc.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
    }
    return rootAppContext;
}