Class JettyWebServer

java.lang.Object
org.springframework.boot.web.embedded.jetty.JettyWebServer
All Implemented Interfaces:
WebServer

public class JettyWebServer extends Object implements WebServer
WebServer that can be used to control a Jetty web server.
Since:
2.0.0
Author:
Phillip Webb, Dave Syer, David Liu, EddĂș MelĂ©ndez, Brian Clozel, Kristine Jetzke
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 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
    • stop

      public void stop()
      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
    • destroy

      public void destroy()
      Description copied from interface: WebServer
      Destroys the web server such that it cannot be started again.
      Specified by:
      destroy in interface WebServer
    • 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)
    • shutDownGracefully

      public void shutDownGracefully(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 WebServer
      Parameters:
      callback - the callback to invoke when the graceful shutdown completes
    • getServer

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