Search in sources :

Example 1 with WebServer

use of org.springframework.boot.web.server.WebServer in project spring-boot by spring-projects.

the class ServletWebServerApplicationContext method stopAndReleaseWebServer.

private void stopAndReleaseWebServer() {
    WebServer webServer = this.webServer;
    if (webServer != null) {
        try {
            webServer.stop();
            this.webServer = null;
        } catch (Exception ex) {
            throw new IllegalStateException(ex);
        }
    }
}
Also used : WebServer(org.springframework.boot.web.server.WebServer) ServletException(javax.servlet.ServletException) ApplicationContextException(org.springframework.context.ApplicationContextException) BeansException(org.springframework.beans.BeansException)

Example 2 with WebServer

use of org.springframework.boot.web.server.WebServer in project spring-boot by spring-projects.

the class ServletWebServerApplicationContext method createWebServer.

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 {
            getSelfInitializer().onStartup(servletContext);
        } catch (ServletException ex) {
            throw new ApplicationContextException("Cannot initialize servlet context", ex);
        }
    }
    initPropertySources();
}
Also used : ServletException(javax.servlet.ServletException) ServletWebServerFactory(org.springframework.boot.web.servlet.server.ServletWebServerFactory) WebServer(org.springframework.boot.web.server.WebServer) ServletContext(javax.servlet.ServletContext) ApplicationContextException(org.springframework.context.ApplicationContextException)

Example 3 with WebServer

use of org.springframework.boot.web.server.WebServer in project spring-boot by spring-projects.

the class ReactiveWebServerApplicationContext method createWebServer.

private void createWebServer() {
    WebServer localServer = this.webServer;
    if (localServer == null) {
        this.webServer = getWebServerFactory().getWebServer(getHttpHandler());
    }
    initPropertySources();
}
Also used : WebServer(org.springframework.boot.web.server.WebServer)

Example 4 with WebServer

use of org.springframework.boot.web.server.WebServer in project spring-boot by spring-projects.

the class EmbeddedServerPortFileWriterTests method mockEvent.

private ServletWebServerInitializedEvent mockEvent(String name, int port) {
    ServletWebServerApplicationContext applicationContext = mock(ServletWebServerApplicationContext.class);
    WebServer source = mock(WebServer.class);
    given(applicationContext.getNamespace()).willReturn(name);
    given(source.getPort()).willReturn(port);
    ServletWebServerInitializedEvent event = new ServletWebServerInitializedEvent(applicationContext, source);
    return event;
}
Also used : WebServer(org.springframework.boot.web.server.WebServer) ServletWebServerApplicationContext(org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext) ServletWebServerInitializedEvent(org.springframework.boot.web.servlet.context.ServletWebServerInitializedEvent)

Example 5 with WebServer

use of org.springframework.boot.web.server.WebServer in project spring-boot by spring-projects.

the class SkipSslVerificationHttpRequestFactoryTests method getHttpsUrl.

private String getHttpsUrl() {
    TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
    factory.setSsl(getSsl("password", "classpath:test.jks"));
    WebServer webServer = factory.getWebServer(new ServletRegistrationBean<>(new ExampleServlet(), "/hello"));
    webServer.start();
    return "https://localhost:" + webServer.getPort() + "/hello";
}
Also used : TomcatServletWebServerFactory(org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory) WebServer(org.springframework.boot.web.server.WebServer) ExampleServlet(org.springframework.boot.web.servlet.server.ExampleServlet)

Aggregations

WebServer (org.springframework.boot.web.server.WebServer)10 ApplicationContextException (org.springframework.context.ApplicationContextException)3 ServletException (javax.servlet.ServletException)2 Server (org.eclipse.jetty.server.Server)2 BeansException (org.springframework.beans.BeansException)2 InetSocketAddress (java.net.InetSocketAddress)1 ServletContext (javax.servlet.ServletContext)1 AbstractConnector (org.eclipse.jetty.server.AbstractConnector)1 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)1 TomcatServletWebServerFactory (org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory)1 ServletWebServerApplicationContext (org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext)1 ServletWebServerInitializedEvent (org.springframework.boot.web.servlet.context.ServletWebServerInitializedEvent)1 ExampleServlet (org.springframework.boot.web.servlet.server.ExampleServlet)1 ServletWebServerFactory (org.springframework.boot.web.servlet.server.ServletWebServerFactory)1 JettyHttpHandlerAdapter (org.springframework.http.server.reactive.JettyHttpHandlerAdapter)1