public MqttHTTPServer build()

in mqtt-exporter/src/main/java/org/apache/rocketmq/mqtt/exporter/http/MqttHTTPServer.java [463:498]


        public MqttHTTPServer build() throws IOException {
            if (sampleNameFilter != null) {
                assertNull(sampleNameFilterSupplier, "cannot configure 'sampleNameFilter' and 'sampleNameFilterSupplier' at the same time");
                sampleNameFilterSupplier = SampleNameFilterSupplier.of(sampleNameFilter);
            }

            if (httpServer != null) {
                assertZero(port, "cannot configure 'httpServer' and 'port' at the same time");
                assertNull(hostname, "cannot configure 'httpServer' and 'hostname' at the same time");
                assertNull(inetAddress, "cannot configure 'httpServer' and 'inetAddress' at the same time");
                assertNull(inetSocketAddress, "cannot configure 'httpServer' and 'inetSocketAddress' at the same time");
                assertNull(httpsConfigurator, "cannot configure 'httpServer' and 'httpsConfigurator' at the same time");
                return new MqttHTTPServer(httpServer, registry, daemon, sampleNameFilterSupplier, authenticator);
            } else if (inetSocketAddress != null) {
                assertZero(port, "cannot configure 'inetSocketAddress' and 'port' at the same time");
                assertNull(hostname, "cannot configure 'inetSocketAddress' and 'hostname' at the same time");
                assertNull(inetAddress, "cannot configure 'inetSocketAddress' and 'inetAddress' at the same time");
            } else if (inetAddress != null) {
                assertNull(hostname, "cannot configure 'inetAddress' and 'hostname' at the same time");
                inetSocketAddress = new InetSocketAddress(inetAddress, port);
            } else if (hostname != null) {
                inetSocketAddress = new InetSocketAddress(hostname, port);
            } else {
                inetSocketAddress = new InetSocketAddress(port);
            }

            HttpServer httpServer = null;
            if (httpsConfigurator != null) {
                httpServer = HttpsServer.create(inetSocketAddress, 3);
                ((HttpsServer)httpServer).setHttpsConfigurator(httpsConfigurator);
            } else {
                httpServer = HttpServer.create(inetSocketAddress, 3);
            }

            return new MqttHTTPServer(httpServer, registry, daemon, sampleNameFilterSupplier, authenticator);
        }