@Override
    public final HttpResponse serve(ServiceRequestContext ctx, HttpRequest req) throws Exception {
        final Connector connector = connector();
        if (connector == null || !isConnectorAvailable(connector.getState())) {
            return HttpResponse.of(HttpStatus.SERVICE_UNAVAILABLE);
        }
        final Adapter coyoteAdapter = connector.getProtocolHandler().getAdapter();
        if (coyoteAdapter == null) {
            return HttpResponse.of(HttpStatus.SERVICE_UNAVAILABLE);
        }

        final String mappedPath = mappedPath(ctx);
        if (mappedPath == null) {
            return HttpResponse.of(HttpStatus.BAD_REQUEST, MediaType.PLAIN_TEXT_UTF_8,
                                   "Invalid matrix variable: " +
                                   ctx.routingContext().requestTarget().maybePathWithMatrixVariables());
        }

        final HttpResponseWriter res = HttpResponse.streaming();
        req.aggregate().handle((aReq, cause) -> {
            try {
                if (cause != null) {
                    cause = Exceptions.peel(cause);
                    logger.warn("{} Failed to aggregate a request:", ctx, cause);
                    if (cause instanceof HttpStatusException || cause instanceof HttpResponseException) {
                        res.close(cause);
                    } else if (res.tryWrite(ResponseHeaders.of(HttpStatus.INTERNAL_SERVER_ERROR))) {
                        res.close();
                    }
                    return null;
                }
                if (!isConnectorAvailable(connector.getState())) {
                    if (res.tryWrite(ResponseHeaders.of(HttpStatus.SERVICE_UNAVAILABLE))) {
                        res.close();
                    }
                    return null;
                }

                final ArmeriaProcessor processor = createProcessor(coyoteAdapter);
                final Request coyoteReq = convertRequest(ctx, mappedPath, aReq, processor.getRequest());
                if (coyoteReq == null) {
                    if (res.tryWrite(INVALID_AUTHORITY_HEADERS)) {
                        if (res.tryWrite(INVALID_AUTHORITY_DATA)) {
                            res.close();
                        }
                    }
                    return null;
                }
                final Response coyoteRes = coyoteReq.getResponse();
                coyoteReq.setResponse(coyoteRes);
                coyoteRes.setRequest(coyoteReq);

                ServletTlsAttributes.fill(ctx.sslSession(), coyoteReq::setAttribute);

                final Queue<HttpData> data = new ArrayDeque<>();
                coyoteRes.setOutputBuffer((OutputBuffer) OUTPUT_BUFFER_CONSTRUCTOR.invoke(data));

                ctx.blockingTaskExecutor().execute(() -> {
                    if (!res.isOpen()) {
                        return;
                    }

                    if (!isConnectorAvailable(connector.getState())) {
                        if (res.tryWrite(ResponseHeaders.of(HttpStatus.SERVICE_UNAVAILABLE))) {
                            res.close();
                        }
                        return;
                    }

                    try {
                        coyoteAdapter.service(coyoteReq, coyoteRes);
                        final HttpHeaders headers = convertResponse(coyoteRes);
                        if (res.tryWrite(headers)) {
                            for (;;) {
                                final HttpData d = data.poll();
                                if (d == null || !res.tryWrite(d)) {
                                    break;
                                }
                            }
                        }
                        res.close();
                    } catch (Throwable t) {
                        res.abort(new IllegalStateException("Failed to produce a response", t));
                    }
                });
            } catch (Throwable t) {
                res.abort(new IllegalStateException("Failed to invoke Tomcat", t));
            }
            return null;
        });

        return res;
    }
Returns Tomcat {@link Connector}.

@return the Tomcat {@link Connector}, or {@code null} if the {@link Connector} is not available yet.
tomcat10/src/main/java/com/linecorp/armeria/server/tomcat/TomcatService.java