Search in sources :

Example 6 with WebServer

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

the class JettyReactiveWebServerFactory method getWebServer.

@Override
public WebServer getWebServer(HttpHandler httpHandler) {
    JettyHttpHandlerAdapter servlet = new JettyHttpHandlerAdapter(httpHandler);
    Server server = createJettyServer(servlet);
    return new JettyWebServer(server, getPort() >= 0);
}
Also used : WebServer(org.springframework.boot.web.server.WebServer) Server(org.eclipse.jetty.server.Server) JettyHttpHandlerAdapter(org.springframework.http.server.reactive.JettyHttpHandlerAdapter)

Example 7 with WebServer

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

the class JettyServletWebServerFactory method getWebServer.

@Override
public WebServer getWebServer(ServletContextInitializer... initializers) {
    JettyEmbeddedWebAppContext context = new JettyEmbeddedWebAppContext();
    int port = (getPort() >= 0 ? getPort() : 0);
    InetSocketAddress address = new InetSocketAddress(getAddress(), port);
    Server server = createServer(address);
    configureWebAppContext(context, initializers);
    server.setHandler(addHandlerWrappers(context));
    this.logger.info("Server initialized with port: " + port);
    if (getSsl() != null && getSsl().isEnabled()) {
        SslContextFactory sslContextFactory = new SslContextFactory();
        configureSsl(sslContextFactory, getSsl());
        AbstractConnector connector = createSslConnector(server, sslContextFactory, port);
        server.setConnectors(new Connector[] { connector });
    }
    for (JettyServerCustomizer customizer : getServerCustomizers()) {
        customizer.customize(server);
    }
    if (this.useForwardHeaders) {
        new ForwardHeadersCustomizer().customize(server);
    }
    return getJettyWebServer(server);
}
Also used : SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) Server(org.eclipse.jetty.server.Server) WebServer(org.springframework.boot.web.server.WebServer) InetSocketAddress(java.net.InetSocketAddress) AbstractConnector(org.eclipse.jetty.server.AbstractConnector)

Example 8 with WebServer

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

the class ReactiveWebServerApplicationContext method finishRefresh.

@Override
protected void finishRefresh() {
    super.finishRefresh();
    WebServer localServer = startReactiveWebServer();
    if (localServer != null) {
        publishEvent(new ReactiveWebServerInitializedEvent(localServer, this));
    }
}
Also used : WebServer(org.springframework.boot.web.server.WebServer)

Example 9 with WebServer

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

the class ReactiveWebServerApplicationContext method stopAndReleaseReactiveWebServer.

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

Example 10 with WebServer

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

the class ServletWebServerApplicationContext method finishRefresh.

@Override
protected void finishRefresh() {
    super.finishRefresh();
    WebServer webServer = startWebServer();
    if (webServer != null) {
        publishEvent(new ServletWebServerInitializedEvent(this, webServer));
    }
}
Also used : WebServer(org.springframework.boot.web.server.WebServer)

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