public class SimpleProcessExecutor extends Object
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
isService |
protected Consumer<String> |
outputSink |
protected ProcessBuilder |
processBuilder |
protected UnaryOperator<Consumer<String>> |
similarityRemover |
| Constructor and Description |
|---|
SimpleProcessExecutor(ProcessBuilder processBuilder) |
| Modifier and Type | Method and Description |
|---|---|
Process |
execute() |
Map.Entry<io.reactivex.rxjava3.core.Single<Integer>,Process> |
executeCore() |
io.reactivex.rxjava3.core.Single<Integer> |
executeFuture() |
void |
executeReadLines(io.reactivex.rxjava3.core.Flowable<String> upstream,
io.reactivex.rxjava3.core.FlowableEmitter<String> emitter) |
Consumer<String> |
getOutputSink() |
ProcessBuilder |
getProcessBuilder()
Return the underlying processBuilder
|
UnaryOperator<Consumer<String>> |
getSimilarityRemover() |
boolean |
isService() |
void |
run(Process p,
io.reactivex.rxjava3.core.FlowableEmitter<Integer> emitter)
Wraps process execution as a single that will hold the exit code.
|
SimpleProcessExecutor |
setOutputSink(Consumer<String> outputSink) |
SimpleProcessExecutor |
setService(boolean isService)
If the process is a service, its output will be processed by a separate thread.
|
SimpleProcessExecutor |
setSimilarityRemover(UnaryOperator<Consumer<String>> similarityRemover) |
int |
watchProcessOutput(Process p)
Utility function that blocks until the process the ends, thereby
forwarding output to the configured sink and applying filtering of
consecutive lines that are too similar
|
static SimpleProcessExecutor |
wrap(ProcessBuilder processBuilder) |
protected ProcessBuilder processBuilder
protected UnaryOperator<Consumer<String>> similarityRemover
protected boolean isService
public SimpleProcessExecutor(ProcessBuilder processBuilder)
public SimpleProcessExecutor setOutputSink(Consumer<String> outputSink)
public UnaryOperator<Consumer<String>> getSimilarityRemover()
public SimpleProcessExecutor setSimilarityRemover(UnaryOperator<Consumer<String>> similarityRemover)
public boolean isService()
public ProcessBuilder getProcessBuilder()
public SimpleProcessExecutor setService(boolean isService)
public int watchProcessOutput(Process p) throws IOException, InterruptedException
p - IOExceptionInterruptedExceptionpublic void run(Process p, io.reactivex.rxjava3.core.FlowableEmitter<Integer> emitter)
p - emitter - public Process execute() throws IOException, InterruptedException
IOExceptionInterruptedExceptionpublic void executeReadLines(io.reactivex.rxjava3.core.Flowable<String> upstream, io.reactivex.rxjava3.core.FlowableEmitter<String> emitter) throws IOException
IOExceptionpublic io.reactivex.rxjava3.core.Single<Integer> executeFuture() throws IOException, InterruptedException
IOExceptionInterruptedExceptionpublic Map.Entry<io.reactivex.rxjava3.core.Single<Integer>,Process> executeCore() throws IOException, InterruptedException
IOExceptionInterruptedExceptionpublic static SimpleProcessExecutor wrap(ProcessBuilder processBuilder)
Copyright © 2020. All rights reserved.