<commit_before>package com.xjeffrose.xio.bootstrap;

import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import com.xjeffrose.xio.application.Application;
import com.xjeffrose.xio.application.ApplicationConfig;
import com.xjeffrose.xio.application.ApplicationState;
import com.xjeffrose.xio.bootstrap.ChannelConfiguration;
import com.xjeffrose.xio.config.Configurator;
import com.xjeffrose.xio.server.XioServer;
import com.xjeffrose.xio.server.XioServerConfig;
import com.xjeffrose.xio.server.XioServerState;

import java.util.HashMap;
import java.util.Map;
import java.util.function.UnaryOperator;

public class ApplicationBootstrap {

  private final ApplicationConfig config;

  private final ApplicationState state;

  private final Map<String, XioServerBootstrap> serverBootstraps = new HashMap<>();

  public ApplicationBootstrap(ApplicationConfig config, ApplicationState state) {
    this.config = config;
    this.state = state;
  }

  public ApplicationBootstrap(Config config) {
    this(new ApplicationConfig(config), new ApplicationState(config));
  }

  public ApplicationBootstrap(String key, Config config) {
    this(config.getConfig(key));
  }

  public ApplicationBootstrap(String application) {
    this(application, ConfigFactory.load());
  }

  public ApplicationBootstrap addServer(String server, UnaryOperator<XioServerBootstrap> configure) {
    XioServerConfig serverConfig = new XioServerConfig(config.getServer(server));
    XioServerState serverState = new XioServerState(config.getServer(server));
    XioServerBootstrap serverBootstrap = configure.apply(new XioServerBootstrap(state, serverConfig, serverState).channelConfig(state.getChannelConfiguration()));
    serverBootstraps.put(server, serverBootstrap);
    return this;
  }

  public Application build() {
    Map<String, XioServer> servers = new HashMap<>();
    serverBootstraps.forEach((k, v) -> servers.put(k, v.build()));
    Configurator configurator = Configurator.build(config.settings());
    return new Application(config, servers, state, configurator);
  }

}<commit_msg>Start configurator when application bootstrap builds<commit_after>package com.xjeffrose.xio.bootstrap;

import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import com.xjeffrose.xio.application.Application;
import com.xjeffrose.xio.application.ApplicationConfig;
import com.xjeffrose.xio.application.ApplicationState;
import com.xjeffrose.xio.bootstrap.ChannelConfiguration;
import com.xjeffrose.xio.config.Configurator;
import com.xjeffrose.xio.server.XioServer;
import com.xjeffrose.xio.server.XioServerConfig;
import com.xjeffrose.xio.server.XioServerState;

import java.util.HashMap;
import java.util.Map;
import java.util.function.UnaryOperator;

public class ApplicationBootstrap {

  private final ApplicationConfig config;

  private final ApplicationState state;

  private final Map<String, XioServerBootstrap> serverBootstraps = new HashMap<>();

  public ApplicationBootstrap(ApplicationConfig config, ApplicationState state) {
    this.config = config;
    this.state = state;
  }

  public ApplicationBootstrap(Config config) {
    this(new ApplicationConfig(config), new ApplicationState(config));
  }

  public ApplicationBootstrap(String key, Config config) {
    this(config.getConfig(key));
  }

  public ApplicationBootstrap(String application) {
    this(application, ConfigFactory.load());
  }

  public ApplicationBootstrap addServer(String server, UnaryOperator<XioServerBootstrap> configure) {
    XioServerConfig serverConfig = new XioServerConfig(config.getServer(server));
    XioServerState serverState = new XioServerState(config.getServer(server));
    XioServerBootstrap serverBootstrap = configure.apply(new XioServerBootstrap(state, serverConfig, serverState).channelConfig(state.getChannelConfiguration()));
    serverBootstraps.put(server, serverBootstrap);
    return this;
  }

  public Application build() {
    Map<String, XioServer> servers = new HashMap<>();
    serverBootstraps.forEach((k, v) -> servers.put(k, v.build()));
    Configurator configurator = Configurator.build(config.settings());
    configurator.start();
    return new Application(config, servers, state, configurator);
  }

}
{'fraction_non_alphanumeric': 0.09866102889358704, 'fraction_numerical': 0.0, 'mean_word_length': 5.889967637540453, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3109895', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1210, 'n_words': 242}