All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.walterjwhite.data.pipe.modules.event.bus.ShellSink Maven / Gradle / Ivy

The newest version!
package com.walterjwhite.data.pipe.modules.event.bus;

import com.walterjwhite.data.pipe.impl.AbstractSink;
import com.walterjwhite.data.pipe.modules.event.bus.api.model.ShellSinkConfiguration;
import com.walterjwhite.shell.api.model.ShellCommand;
import com.walterjwhite.shell.api.service.ShellExecutionService;
import javax.inject.Inject;

public class ShellSink extends AbstractSink {
  protected final ShellExecutionService shellExecutionService;

  @Inject
  public ShellSink(ShellExecutionService shellExecutionService) {
    super();
    this.shellExecutionService = shellExecutionService;
  }

  @Override
  protected void doConfigure() {}

  @Override
  public void accept(String record) {
    try {
      shellExecutionService.run(new ShellCommand().withCommandLine(record));
    } catch (Exception e) {
      throw (new RuntimeException("Error running command", e));
    }
  }

  public void close() {
    // shellExecutionService.kill(shellCommand);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy