Class UndertowWebServer

java.lang.Object
org.springframework.boot.web.embedded.undertow.UndertowWebServer
All Implemented Interfaces:
WebServer
Direct Known Subclasses:
UndertowServletWebServer

public class UndertowWebServer extends Object implements WebServer
WebServer that can be used to control an Undertow web server. Usually this class should be created using the UndertowReactiveWebServerFactory and not directly.
Since:
2.0.0
Author:
Ivan Sopov, Andy Wilkinson, EddĂș MelĂ©ndez, Christoph Dreis, Brian Clozel
  • Constructor Details

    • UndertowWebServer

      public UndertowWebServer(io.undertow.Undertow.Builder builder, boolean autoStart)
      Create a new UndertowWebServer instance.
      Parameters:
      builder - the builder
      autoStart - if the server should be started
    • UndertowWebServer

      public UndertowWebServer(io.undertow.Undertow.Builder builder, Iterable<HttpHandlerFactory> httpHandlerFactories, boolean autoStart)
      Create a new UndertowWebServer instance.
      Parameters:
      builder - the builder
      httpHandlerFactories - the handler factories
      autoStart - if the server should be started
      Since:
      2.3.0
  • Method Details

    • start

      public void start() throws WebServerException
      Description copied from interface: WebServer
      Starts the web server. Calling this method on an already started server has no effect.
      Specified by:
      start in interface WebServer
      Throws:
      WebServerException - if the server cannot be started
    • createHttpHandler

      protected io.undertow.server.HttpHandler createHttpHandler()
    • stop

      public void stop() throws WebServerException
      Description copied from interface: WebServer
      Stops the web server. Calling this method on an already stopped server has no effect.
      Specified by:
      stop in interface WebServer
      Throws:
      WebServerException - if the server cannot be stopped
    • getPort

      public int getPort()
      Description copied from interface: WebServer
      Return the port this server is listening on.
      Specified by:
      getPort in interface WebServer
      Returns:
      the port (or -1 if none)
    • getUndertow

      public io.undertow.Undertow getUndertow()
      Returns the Undertow server. Returns null until the server has been started.
      Returns:
      the Undertow server or null if the server hasn't been started yet
      Since:
      3.3.0
    • shutDownGracefully

      public void shutDownGracefully(GracefulShutdownCallback callback)
      Description copied from interface: WebServer
      Initiates a graceful shutdown of the web server. Handling of new requests is prevented and the given callback is invoked at the end of the attempt. The attempt can be explicitly ended by invoking WebServer.stop(). The default implementation invokes the callback immediately with GracefulShutdownResult.IMMEDIATE, i.e. no attempt is made at a graceful shutdown.
      Specified by:
      shutDownGracefully in interface WebServer
      Parameters:
      callback - the callback to invoke when the graceful shutdown completes
    • getStartLogMessage

      protected String getStartLogMessage()