Class ObservableOutputStreamsProcess.Builder

java.lang.Object
org.wildfly.qa.tooling.processexecution.ObservableOutputStreamsProcess.Builder
Enclosing class:
ObservableOutputStreamsProcess

public static final class ObservableOutputStreamsProcess.Builder extends Object
Builder for ObservableOutputStreamsProcess
  • Constructor Details

    • Builder

      public Builder(org.apache.commons.exec.CommandLine commandLine)
      Create builder for ObservableOutputStreamsProcess. Sets default timeout 5 minutes in which the process is expected to end.
      Parameters:
      commandLine - command line to be started as an observable process
    • Builder

      public Builder(org.apache.commons.exec.CommandLine commandLine, long timeout, TimeUnit timeUnit)
      Creates builder for ObservableOutputStreamsProcess and allows to set custom timeout in which the process is expected to end.
      Parameters:
      commandLine - command line to be started as an observable process
      timeout - timeout in which the process is expected to end
      timeUnit - time unit for the timeout parameter
  • Method Details

    • addProcessOutputObserver

      public ObservableOutputStreamsProcess.Builder addProcessOutputObserver(ProcessOutputObserver observer)
      Add observer to the stdout of the process. This observer will see each line printed in the stdout.
      Parameters:
      observer - an observer implementation
      Returns:
      instance of this builder
    • addErrorOutputObserver

      public ObservableOutputStreamsProcess.Builder addErrorOutputObserver(ProcessOutputObserver observer)
      Add observer to the stderr of the process. This observer will see each line printed in the stderr.
      Parameters:
      observer - an observer implementation
      Returns:
      instance of this builder
    • addInteractiveProcessOutputObserver

      public ObservableOutputStreamsProcess.Builder addInteractiveProcessOutputObserver(InteractiveOutputObserver observer)
      Add interactive observer to process. This observer will see each line printed in the stdout and can act upon it according to its implementation.
      Parameters:
      observer - an observer implementation
      Returns:
      instance of this builder
      See Also:
    • addProcessControlObserver

      public ObservableOutputStreamsProcess.Builder addProcessControlObserver(ProcessControlObserver observer)
      Add process control observer to process. This observer will see each line printed in the stdout and can act upon it according to its implementation.
      Parameters:
      observer - an observer implementation
      Returns:
      instance of this builder
      See Also:
    • workDirectory

      public ObservableOutputStreamsProcess.Builder workDirectory(Path workDirectory)
      A work directory in which the execution will be done
      Parameters:
      workDirectory - a work directory
      Returns:
      instance of this builder
    • addEnvironmentProperty

      public ObservableOutputStreamsProcess.Builder addEnvironmentProperty(String name, String value)
      Add an environment property to command execution
      Parameters:
      name - name of property
      value - value of property
      Returns:
      instance of this builder
    • withTimeout

      public ObservableOutputStreamsProcess.Builder withTimeout(long timeout, TimeUnit timeoutTimeUnit)
      Set timeout for process. This will cause forcible closing of process if it won't end before timeout.
      Parameters:
      timeout - timeout
      timeoutTimeUnit - timeout unit
      Returns:
      instance of this builder
    • lineEndDelimiter

      public ObservableOutputStreamsProcess.Builder lineEndDelimiter(Pattern lineEndDelimiter)
      Set a pattern used to determine end of line in the process output
      Parameters:
      lineEndDelimiter - a pattern identifying end of line
      Returns:
      instance of this builder
    • build

      Compose new instance of ObservableOutputStreamsProcess
      Returns:
      instance of ObservableOutputStreamsProcess