@Override
    public WebServer getWebServer(HttpHandler httpHandler) {
        final ArmeriaWebServer armeriaWebServerBean = findBean(ArmeriaWebServer.class);
        if (armeriaWebServerBean != null) {
            return armeriaWebServerBean;
        }

        final Http2 http2 = getHttp2();
        if (http2 != null && !http2.isEnabled()) {
            logger.warn("Cannot disable HTTP/2 protocol for Armeria server. It will be enabled automatically.");
        }

        final ServerBuilder sb = Server.builder();
        sb.disableServerHeader();
        sb.disableDateHeader();

        final ArmeriaSettings armeriaSettings = findBean(ArmeriaSettings.class);
        if (!isArmeriaCompressionEnabled(armeriaSettings)) {
            final Compression compression = getCompression();
            if (compression != null && compression.getEnabled()) {
                final long minResponseSize = compression.getMinResponseSize().toBytes();
                sb.decorator(contentEncodingDecorator(compression.getMimeTypes(),
                                                      compression.getExcludedUserAgents(),
                                                      Ints.saturatedCast(minResponseSize)));
            }
        }

        if (armeriaSettings != null) {
            final MeterRegistry meterRegistry = firstNonNull(findBean(MeterRegistry.class),
                                                             Flags.meterRegistry());
            final InternalServices internalServices = findBean(InternalServices.class);
            assert internalServices != null;
            configureServerWithArmeriaSettings(sb, armeriaSettings,
                                               internalServices,
                                               findBeans(ArmeriaServerConfigurator.class),
                                               findBeans(Consumer.class, ServerBuilder.class),
                                               meterRegistry,
                                               meterIdPrefixFunctionOrDefault(),
                                               findBeans(MetricCollectingServiceConfigurator.class),
                                               findBeans(DependencyInjector.class),
                                               findBeans(ServerErrorHandler.class),
                                               beanFactory);
        }

        // In the property file, both Spring and Armeria port configuration can coexist.
        // We use following to define primaryAddress, primaryLocalPort and primarySessionProtocol:
        // (we consider Spring port is not specified when it's 0.)
        // 1) Both Armeria and Spring port were specified:
        //    - primaryAddress = Spring address
        //    - primaryLocalPort = Spring port
        //    - primarySessionProtocol = depends on the springSsl.isEnabled()
        // 2) Only Spring port was specified:
        //    - primaryAddress = Spring address
        //    - primaryLocalPort = Spring port
        //    - primarySessionProtocol = depends on the springSsl.isEnabled()
        // 3) Only Armeria port was specified:
        //    - primaryAddress = null;
        //    - primaryLocalPort = the port of the first Armeria Port
        //    - primarySessionProtocol = the session protocol of the first Armeria Port
        // 4) No port was specified:
        //    a) The port is configured by other ways (e.g. ArmeriaServerConfigurator)
        //       - primaryAddress = null
        //       - primaryLocalPort = the port of the first Armeria Port
        //       - primarySessionProtocol = the session protocol of the first Armeria Port
        //    b) The port is not specified.
        //       - primaryAddress = Spring address
        //       - primaryLocalPort = Spring port
        //       - primarySessionProtocol = depends on the armeriaSsl.isEnabled().
        //                               If armeriaSsl is null use SpringSsl
        //
        // Please note that Armeria TLS configuration has precedence over Spring SSL.

        final boolean armeriaSslEnabled = isArmeriaSslEnabled(armeriaSettings);
        final Ssl springSsl = getSsl();
        final SessionProtocol springSessionProtocol;
        if (springSsl != null && springSsl.isEnabled()) {
            if (armeriaSslEnabled) {
                // TLS will be applied in configureServerWithArmeriaSettings.
                logger.warn("Both Armeria and Spring TLS configuration exist. " +
                            "Armeria TLS configuration is used.");
            } else {
                TlsUtil.configureTls(sb, toArmeriaSslConfiguration(springSsl), this);
            }
            springSessionProtocol = SessionProtocol.HTTPS;
        } else {
            springSessionProtocol = SessionProtocol.HTTP;
        }

        final int springPort = ensureValidPort(getPort());
        final List<ServerPort> armeriaPorts = armeriaPorts(sb);
        final InetAddress primaryAddress;
        final int primaryLocalPort;
        final SessionProtocol primarySessionProtocol;
        if (springPort > 0 || armeriaPorts.isEmpty()) {
            // The cases of 1, 2, 4.b
            primaryAddress = getAddress();
            primaryLocalPort = springPort;
            if (springPort == 0) {
                // case 4.b
                primarySessionProtocol = armeriaSslEnabled ? SessionProtocol.HTTPS : springSessionProtocol;
            } else {
                // cases 1, 2
                primarySessionProtocol = springSessionProtocol;
            }
            if (primaryAddress != null) {
                sb.port(new InetSocketAddress(primaryAddress, primaryLocalPort), primarySessionProtocol);
            } else {
                sb.port(primaryLocalPort, primarySessionProtocol);
            }
        } else {
            // The cases of 3, 4.a
            final ServerPort armeriaFirstPort = armeriaPorts.get(0);
            final InetSocketAddress inetSocketAddress = armeriaFirstPort.localAddress();
            primaryAddress = null;
            primaryLocalPort = inetSocketAddress.getPort();
            primarySessionProtocol = armeriaFirstPort.hasTls() ? SessionProtocol.HTTPS : SessionProtocol.HTTP;
        }

        final DataBufferFactoryWrapper<?> factoryWrapper =
                firstNonNull(findBean(DataBufferFactoryWrapper.class), DataBufferFactoryWrapper.DEFAULT);

        final Server server = configureService(sb, httpHandler, factoryWrapper, getServerHeader()).build();
        final ArmeriaWebServer armeriaWebServer = new ArmeriaWebServer(server, primarySessionProtocol,
                                                                       primaryAddress,
                                                                       primaryLocalPort, beanFactory);
        if (!isManagementPortEqualsToServerPort()) {
            // The management port is set to the Server in ArmeriaSpringActuatorAutoConfiguration.
            // Since this method will be called twice, need to reuse ArmeriaWebServer.
            beanFactory.registerSingleton("armeriaWebServer", armeriaWebServer);
        }

        return armeriaWebServer;
    }
Creates a new factory instance with the specified {@link ConfigurableListableBeanFactory}.
spring/boot3-webflux-autoconfigure/src/main/java/com/linecorp/armeria/spring/web/reactive/ArmeriaReactiveWebServerFactory.java