Beispiel #1
0
  public static void initialize(String... servers) {
    File configFile = null;

    try {
      configFile = File.createTempFile("cat-client", ".xml");
      ClientConfig config = new ClientConfig().setMode("client");

      for (String server : servers) {
        config.addServer(new Server(server));
      }

      Files.forIO().writeTo(configFile, config.toString());
    } catch (IOException e) {
      e.printStackTrace();
    }
    initialize(configFile);
  }
Beispiel #2
0
  @Override
  public void visitConfig(ClientConfig config) {
    if (!"client".equals(config.getMode())) {
      throw new RuntimeException(String.format("Attribute(%s) is required: %s", "mode", config));
    } else if (config.getServers().size() == 0) {
      config.setEnabled(false);
      log("WARN", "CAT client was disabled due to no CAT servers configured!");
    } else if (!config.isEnabled()) {
      log("WARN", "CAT client was globally disabled!");
    }

    m_config = config;
    super.visitConfig(config);

    if (m_config.isEnabled()) {
      for (Domain domain : m_config.getDomains().values()) {
        if (!domain.isEnabled()) {
          m_config.setEnabled(false);
          log("WARN", "CAT client was disabled in domain(" + domain.getId() + ") explicitly!");
        }

        break; // for first domain only
      }
    }
  }