Example usage for org.springframework.boot.web.servlet.server ServletWebServerFactory getWebServer

List of usage examples for org.springframework.boot.web.servlet.server ServletWebServerFactory getWebServer

Introduction

In this page you can find the example usage for org.springframework.boot.web.servlet.server ServletWebServerFactory getWebServer.

Prototype

WebServer getWebServer(ServletContextInitializer... initializers);

Source Link

Document

Gets a new fully configured but paused WebServer instance.

Usage

From source file:org.springframework.boot.web.servlet.server.AbstractServletWebServerFactoryTests.java

protected void assertForwardHeaderIsUsed(ServletWebServerFactory factory)
        throws IOException, URISyntaxException {
    this.webServer = factory
            .getWebServer(new ServletRegistrationBean<>(new ExampleServlet(true, false), "/hello"));
    this.webServer.start();
    assertThat(getResponse(getLocalUrl("/hello"), "X-Forwarded-For:140.211.11.130"))
            .contains("remoteaddr=140.211.11.130");
}

From source file:org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.java

private void createWebServer() {
    WebServer webServer = this.webServer;
    ServletContext servletContext = getServletContext();
    if (webServer == null && servletContext == null) {
        ServletWebServerFactory factory = getWebServerFactory();
        this.webServer = factory.getWebServer(getSelfInitializer());
    } else if (servletContext != null) {
        try {/*ww w  . ja  v  a 2 s . c  om*/
            getSelfInitializer().onStartup(servletContext);
        } catch (ServletException ex) {
            throw new ApplicationContextException("Cannot initialize servlet context", ex);
        }
    }
    initPropertySources();
}