Class ObservableOutputStreamsProcess.Builder
java.lang.Object
org.wildfly.qa.tooling.processexecution.ObservableOutputStreamsProcess.Builder
- Enclosing class:
ObservableOutputStreamsProcess
Builder for ObservableOutputStreamsProcess
-
Constructor Summary
ConstructorsConstructorDescriptionBuilder(org.apache.commons.exec.CommandLine commandLine) Create builder for ObservableOutputStreamsProcess.Creates builder for ObservableOutputStreamsProcess and allows to set custom timeout in which the process is expected to end. -
Method Summary
Modifier and TypeMethodDescriptionaddEnvironmentProperty(String name, String value) Add an environment property to command executionaddErrorOutputObserver(ProcessOutputObserver observer) Add observer to the stderr of the process.Add interactive observer to process.Add process control observer to process.Add observer to the stdout of the process.build()Compose new instance of ObservableOutputStreamsProcesslineEndDelimiter(Pattern lineEndDelimiter) Set a pattern used to determine end of line in the process outputwithTimeout(long timeout, TimeUnit timeoutTimeUnit) Set timeout for process.workDirectory(Path workDirectory) A work directory in which the execution will be done
-
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
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 processtimeout- timeout in which the process is expected to endtimeUnit- 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
A work directory in which the execution will be done- Parameters:
workDirectory- a work directory- Returns:
- instance of this builder
-
addEnvironmentProperty
Add an environment property to command execution- Parameters:
name- name of propertyvalue- value of property- Returns:
- instance of this builder
-
withTimeout
Set timeout for process. This will cause forcible closing of process if it won't end before timeout.- Parameters:
timeout- timeouttimeoutTimeUnit- timeout unit- Returns:
- instance of this builder
-
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
-