Class StreamGobbler
java.lang.Object
java.lang.Thread
de.iip_ecosphere.platform.support.plugins.StreamGobbler
- All Implemented Interfaces:
Runnable
Simple process stream gobbler.
- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddConsumer(Consumer<String> consumer) Adds a line consumer.static voidAttaches two default stream gobblers to the givenprocess.static voidattach(Process process, PrintStream out, Consumer<String> outConsumer, PrintStream err, Consumer<String> errConsumer) Attaches two stream gobblers to the givenprocesswith given consumers.static voidAttaches two default stream gobblers to the givenprocesswith given consumers.voidrun()Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
in
-
out
-
consumer
-
-
Constructor Details
-
StreamGobbler
Creates a stream gobbler.- Parameters:
in- the process streamout- the output stream where to write the process output to
-
-
Method Details
-
addConsumer
Adds a line consumer.- Parameters:
consumer- the line consumer, may be null for none- Returns:
- this for chaining
-
run
public void run() -
attach
Attaches two default stream gobblers to the givenprocess.- Parameters:
process- the process to attach to
-
attach
public static void attach(Process process, Consumer<String> outConsumer, Consumer<String> errConsumer) Attaches two default stream gobblers to the givenprocesswith given consumers.- Parameters:
process- the process to attach tooutConsumer- the output stream consumer, may be null for noneerrConsumer- the error stream consumer, may be null for none
-
attach
public static void attach(Process process, PrintStream out, Consumer<String> outConsumer, PrintStream err, Consumer<String> errConsumer) Attaches two stream gobblers to the givenprocesswith given consumers.- Parameters:
process- the process to attach toout- the stream where the process output shall be written tooutConsumer- the output stream consumer, may be null for noneerr- the stream where the process errors shall be written toerrConsumer- the error stream consumer, may be null for none
-