@SuppressWarnings("unchecked")
  public void parse() {
    Map<Object, Object> data = (Map<Object, Object>) YAML.load(configReader);
    Set<FileInfo> resolvedFilesLoad = new LinkedHashSet<FileInfo>();
    Set<FileInfo> resolvedFilesExclude = new LinkedHashSet<FileInfo>();

    if (data.containsKey("load")) {
      resolvedFilesLoad.addAll(resolveFiles((List<String>) data.get("load"), false));
    }
    if (data.containsKey("exclude")) {
      resolvedFilesExclude.addAll(resolveFiles((List<String>) data.get("exclude"), false));
    }
    if (data.containsKey("server")) {
      this.server = (String) data.get("server");
    }
    if (data.containsKey("plugin")) {
      for (Map<String, String> value : (List<Map<String, String>>) data.get("plugin")) {
        plugins.add(
            new Plugin(
                value.get("name"),
                value.get("jar"),
                value.get("module"),
                createArgsList(value.get("args"))));
      }
    }
    if (data.containsKey("serve")) {
      Set<FileInfo> resolvedServeFiles = resolveFiles((List<String>) data.get("serve"), true);
      resolvedFilesLoad.addAll(resolvedServeFiles);
    }
    filesList.addAll(consolidatePatches(resolvedFilesLoad));
    filesList.removeAll(resolvedFilesExclude);
  }
Example #2
0
  @SuppressWarnings("unchecked")
  private Settings() {
    String settingsFile = System.getProperty("configFile");
    if (settingsFile == null) settingsFile = "/usr/local/octobot/octobot.yml";

    try {
      configuration =
          (HashMap<String, HashMap<String, Object>>) YAML.load(new FileReader(settingsFile));
    } catch (Exception e) {
      // Logging to Stdout here because Log4J not yet initialized.
      logger.warn("Warning: No valid config at " + settingsFile);
      logger.warn(
          "Please create this file, or set the "
              + "-DconfigFile=/foo/bar/octobot.yml JVM variable to its location.");
      logger.warn("Continuing launch with internal defaults.");
    }
  }