public TomcatService build() {
        // Create a temporary directory and use it if baseDir is not set.
        Path baseDir = this.baseDir;
        if (baseDir == null) {
            try {
                baseDir = Files.createTempDirectory("tomcat-armeria.");
            } catch (IOException e) {
                throw new TomcatServiceException("failed to create a temporary directory", e);
            }

            try {
                Files.setPosixFilePermissions(baseDir, EnumSet.of(PosixFilePermission.OWNER_READ,
                                                                  PosixFilePermission.OWNER_WRITE,
                                                                  PosixFilePermission.OWNER_EXECUTE));
            } catch (UnsupportedOperationException ignored) {
                // Windows?
            } catch (IOException e) {
                throw new TomcatServiceException("failed to secure a temporary directory", e);
            }
        }

        // Use a NullRealm if no Realm was specified.
        Realm realm = this.realm;
        if (realm == null) {
            realm = new NullRealm();
        }

        final Consumer<Connector> postStopTask = connector -> {
            @SuppressWarnings("UnnecessaryFullyQualifiedName")
            final org.apache.catalina.Server server = connector.getService().getServer();
            if (server.getState() == LifecycleState.STOPPED) {
                try {
                    TomcatService.logger.info("Destroying an embedded Tomcat: {}",
                                              TomcatService.toString(server));
                    server.destroy();
                } catch (Exception e) {
                    TomcatService.logger.warn("Failed to destroy an embedded Tomcat: {}",
                                              TomcatService.toString(server), e);
                }
            }
        };

        return new ManagedTomcatService(null, new ManagedConnectorFactory(new TomcatServiceConfig(
                serviceName, engineName, baseDir, realm, hostname, docBase, jarRoot,
                Collections.unmodifiableList(configurators))), postStopTask);
    }
Returns a newly-created {@link TomcatService} based on the properties of this builder.
tomcat10/src/main/java/com/linecorp/armeria/server/tomcat/TomcatServiceBuilder.java