Ejemplo n.º 1
0
  @Override
  @Nonnull
  public TypedYielder getSource(String args, Map<String, TypedYielder> context) {
    Yielder<JsonEvent> yielder =
        getYielderTypesafe(JsonEvent.class, ConfigReader.LAST_SOURCE, context);
    String[] dirAndCommand = args.split(" ", 2);
    if (dirAndCommand.length < 2) {
      throw new IllegalArgumentException("Working directory and command template expected.");
    }
    ArrayList<String> commandTemplate = new ArrayList<>();
    for (String commandFragment : dirAndCommand[1].split(" ")) {
      commandTemplate.add(commandFragment);
    }

    ShellQueue shellQueue = new ShellQueue(Paths.get(dirAndCommand[0]), commandTemplate);
    yielder.bind(shellQueue);

    return wrapResultingYielder(shellQueue);
  }