server.onDispose().block() 是什么意思?

what's the meaning of server.onDispose().block()?

网上关于reactor-netty的网页很少。而且我不明白下面某些代码的含义。下面这些代码只是 reactor-netty 的基础知识。但我真的无法在互联网上找到更多信息。所以只好求助了

import reactor.netty.DisposableServer;
import reactor.netty.tcp.TcpServer;

public class Application {

    public static void main(String[] args) {
        DisposableServer server =
                TcpServer.create()
                         .host("localhost")
                         .port(8080)       
                         .bindNow();

        server.onDispose()  // <1> what's the meaning?
              .block();     // <2> what's the meaning when combined with server.onDispose()?
    }
}
import reactor.netty.Connection;
import reactor.netty.tcp.TcpClient;

public class Application {

    public static void main(String[] args) {
        Connection connection =
                TcpClient.create()
                         .host("example.com") 
                         .port(80)            
                         .connectNow();

        connection.onDispose()   // <3> what's the meaning?
                  .block();      // <4> what's the meaning when combined with connection.onDispose()? It has connectNow invoked already. Does it wait for connectNow function to return and stop?
    }
}
import io.netty.handler.ssl.util.SelfSignedCertificate;
import reactor.netty.tcp.TcpServer;
import reactor.netty.tcp.TcpSslContextSpec;

/**
 * A TCP server that sends back the received content.
 *
 * @author Violeta Georgieva
 */
public final class EchoServer {

    static final boolean SECURE = System.getProperty("secure") != null;
    static final int PORT = Integer.parseInt(System.getProperty("port", SECURE ? "8443" : "8080"));
    static final boolean WIRETAP = System.getProperty("wiretap") != null;

    public static void main(String[] args) throws Exception {
        TcpServer server =
                TcpServer.create()
                         .port(PORT)
                         .wiretap(WIRETAP)
                         .handle((in, out) -> out.send(in.receive().retain())); // <5> When is it executed? And how?

        if (SECURE) {
            SelfSignedCertificate ssc = new SelfSignedCertificate();
            server = server.secure(
                    spec -> spec.sslContext(TcpSslContextSpec.forServer(ssc.certificate(), ssc.privateKey())));
        }

        server.bindNow()
              .onDispose()
              .block();
    }
}

请帮我解决上面代码中的五个地方。谢谢。

<2>阻塞:它只是阻塞应用程序线程,直到服务器关闭。如果没有阻塞,应用程序将在没有服务器监听的情况下简单地终止。它的 javadoc 指出

Subscribe to this Mono and block indefinitely 

<1>onDispose :当底层 netty 通道关闭时,未来将收到其成功或失败的通知。它的 Mono 类型仅仅意味着没有 onNext 因为没有发射,它要么成功要么失败。

/**
 * Returns an observing {@link Mono} terminating with success when shutdown
 * successfully or error.
 *
 * @return a {@link Mono} terminating with success if shutdown successfully or error
 */
default Mono<Void> onDispose() {
    return FutureMono.from(channel().closeFuture());
}

3 和 4 从客户端 connection/channel 的角度来看是相同的行为。