接口 WebServer

所有已知实现类:
JettyWebServer, NettyWebServer, TomcatWebServer, UndertowServletWebServer, UndertowWebServer

public interface WebServer
Simple interface that represents a fully configured web server (for example Tomcat, Jetty, Netty). Allows the server to be started and stopped.
从以下版本开始:
2.0.0
作者:
Phillip Webb, Dave Syer
  • 方法概要

    修饰符和类型
    方法
    说明
    default void
    Destroys the web server such that it cannot be started again.
    int
    Return the port this server is listening on.
    default void
    Initiates a graceful shutdown of the web server.
    void
    Starts the web server.
    void
    Stops the web server.
  • 方法详细资料

    • start

      void start() throws WebServerException
      Starts the web server. Calling this method on an already started server has no effect.
      抛出:
      WebServerException - if the server cannot be started
    • stop

      void stop() throws WebServerException
      Stops the web server. Calling this method on an already stopped server has no effect.
      抛出:
      WebServerException - if the server cannot be stopped
    • getPort

      int getPort()
      Return the port this server is listening on.
      返回:
      the port (or -1 if none)
    • shutDownGracefully

      default void shutDownGracefully(GracefulShutdownCallback callback)
      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 stop(). The default implementation invokes the callback immediately with GracefulShutdownResult.IMMEDIATE, i.e. no attempt is made at a graceful shutdown.
      参数:
      callback - the callback to invoke when the graceful shutdown completes
      从以下版本开始:
      2.3.0
    • destroy

      default void destroy()
      Destroys the web server such that it cannot be started again.
      从以下版本开始:
      3.2.0