Class JettyWebServer

java.lang.Object
org.springframework.boot.jetty.JettyWebServer
All Implemented Interfaces:
org.springframework.boot.web.server.WebServer
Direct Known Subclasses:
JettyServletWebServer

public class JettyWebServer extends Object implements org.springframework.boot.web.server.WebServer
WebServer that can be used to control a Jetty web server.
Since:
4.0.0
See Also:
  • Constructor Details

    • JettyWebServer

      public JettyWebServer(org.eclipse.jetty.server.Server server)
      Create a new JettyWebServer instance.
      Parameters:
      server - the underlying Jetty server
    • JettyWebServer

      public JettyWebServer(org.eclipse.jetty.server.Server server, boolean autoStart)
      Create a new JettyWebServer instance.
      Parameters:
      server - the underlying Jetty server
      autoStart - if auto-starting the server
  • Method Details

    • start

      public void start() throws org.springframework.boot.web.server.WebServerException
      Specified by:
      start in interface org.springframework.boot.web.server.WebServer
      Throws:
      org.springframework.boot.web.server.WebServerException
    • handleDeferredInitialize

      protected void handleDeferredInitialize(org.eclipse.jetty.server.Server server) throws Exception
      Performs any necessary handling of deferred initialization.
      Parameters:
      server - the server that has been started
      Throws:
      Exception - if a failure occurs during the deferred initialization
    • stop

      public void stop()
      Specified by:
      stop in interface org.springframework.boot.web.server.WebServer
    • destroy

      public void destroy()
      Specified by:
      destroy in interface org.springframework.boot.web.server.WebServer
    • getPort

      public int getPort()
      Specified by:
      getPort in interface org.springframework.boot.web.server.WebServer
    • shutDownGracefully

      public void shutDownGracefully(org.springframework.boot.web.server.GracefulShutdownCallback callback)
      Initiates a graceful shutdown of the Jetty 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 stop().

      Once shutdown has been initiated Jetty will reject any new connections. Requests on existing connections will be accepted, however, a Connection: close header will be returned in the response.

      Specified by:
      shutDownGracefully in interface org.springframework.boot.web.server.WebServer
    • getServer

      public org.eclipse.jetty.server.Server getServer()
      Returns access to the underlying Jetty Server.
      Returns:
      the Jetty server