Class MultiplexerAccumulator
java.lang.Object
com.scivicslab.turingworkflow.plugins.logoutput.MultiplexerAccumulator
- All Implemented Interfaces:
com.scivicslab.pojoactor.core.accumulator.Accumulator
public class MultiplexerAccumulator
extends Object
implements com.scivicslab.pojoactor.core.accumulator.Accumulator
Multiplexer accumulator that forwards output to multiple downstream accumulators.
Architecture:
Node/NodeGroup Actors
|
v
MultiplexerAccumulator
|
+--> ConsoleAccumulator --> System.out
+--> FileAccumulator --> text file
+--> DatabaseAccumulator --> H2 database
- Since:
- 1.0
- Author:
- devteam@scivicslab.com
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an emptyMultiplexerAccumulatorwith no downstream targets. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaddTarget(com.scivicslab.pojoactor.core.accumulator.Accumulator target) Registers a downstream accumulator target.voidclear()intgetCount()intReturns the number of currently registered downstream targets.booleanremoveTarget(com.scivicslab.pojoactor.core.accumulator.Accumulator target) Removes a downstream accumulator target.
-
Constructor Details
-
MultiplexerAccumulator
public MultiplexerAccumulator()Constructs an emptyMultiplexerAccumulatorwith no downstream targets. UseaddTarget(Accumulator)to register targets.
-
-
Method Details
-
addTarget
public void addTarget(com.scivicslab.pojoactor.core.accumulator.Accumulator target) Registers a downstream accumulator target. Entries added to this multiplexer will be forwarded to all registered targets.- Parameters:
target- the accumulator to add;nullvalues are silently ignored
-
removeTarget
public boolean removeTarget(com.scivicslab.pojoactor.core.accumulator.Accumulator target) Removes a downstream accumulator target.- Parameters:
target- the accumulator to remove- Returns:
trueif the target was found and removed
-
getTargetCount
public int getTargetCount()Returns the number of currently registered downstream targets.- Returns:
- the target count
-
add
Forwards the entry to every registered downstream target. If any target throws an exception, a warning is printed to
System.errand the remaining targets are still processed.- Specified by:
addin interfacecom.scivicslab.pojoactor.core.accumulator.Accumulator
-
getSummary
Returns a multi-line summary including the total forwarded count and the individual summary of each downstream target.
- Specified by:
getSummaryin interfacecom.scivicslab.pojoactor.core.accumulator.Accumulator
-
getCount
public int getCount()- Specified by:
getCountin interfacecom.scivicslab.pojoactor.core.accumulator.Accumulator
-
clear
public void clear()Resets the multiplexer's own counter and also clears every downstream target.
- Specified by:
clearin interfacecom.scivicslab.pojoactor.core.accumulator.Accumulator
-