public class SplitDestinations<T> extends StructuralJob<java.lang.Object> implements Transient, java.util.function.Consumer<T>, java.io.Flushable
<oddjob>
<job>
<sequential>
<jobs>
<script id="funcs">function fibonacci(x) {
if (x<1) return new java.lang.Integer(0)
if (x==1) return new java.lang.Integer(1)
return new java.lang.Integer(fibonacci(x-1) + fibonacci(x-2))
}
function factorial(x) {
if (x<1) return new java.lang.Integer(0)
if (x==1) return new java.lang.Integer(1)
return new java.lang.Integer(factorial(x-1) *x)
}
</script>
<parallel id="parallel">
<jobs>
<bus:bus name="Fibonacci Bus" xmlns:bus="oddjob:beanbus">
<of>
<bus:driver>
<values>
<value value="${fibonacciQueue}"/>
</values>
</bus:driver>
<bus:map name="Fibonacci">
<function>
<value value="${funcs.function(fibonacci)}"/>
</function>
</bus:map>
<bus:collect id="fibonacci"/>
</of>
</bus:bus>
<bus:bus name="Factorial Bus" xmlns:bus="oddjob:beanbus">
<of>
<bus:driver>
<values>
<value value="${factorialQueue}"/>
</values>
</bus:driver>
<bus:map name="Factorial">
<function>
<value value="${funcs.function(factorial)}"/>
</function>
</bus:map>
<bus:collect id="factorial"/>
</of>
</bus:bus>
<bus:bus xmlns:bus="oddjob:beanbus">
<of>
<bus:driver>
<values>
<sequence from="1" to="5"/>
</values>
</bus:driver>
<bean class="org.oddjob.beanbus.destinations.SplitDestinations">
<strategy>
<bean class="org.oddjob.beanbus.destinations.SplitDestinations$All"/>
</strategy>
<of>
<bus:queue id="fibonacciQueue" name="FibonacciQueue"/>
<bus:queue id="factorialQueue" name="FactorialQueue"/>
</of>
</bean>
</of>
</bus:bus>
</jobs>
</parallel>
<folder name="Test the Funcs">
<jobs>
<echo name="Test Fibonacci">#{funcs.getFunction('fibonacci').apply(3)}</echo>
<echo name="Test Factorial">#{funcs.getFunction('factorial').apply(6)}</echo>
</jobs>
</folder>
</jobs>
</sequential>
</job>
</oddjob>
| Modifier and Type | Class and Description |
|---|---|
static class |
SplitDestinations.All<T> |
static class |
SplitDestinations.Each<T> |
childHelper, destroy, stop, structuralState| Constructor and Description |
|---|
SplitDestinations() |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(T t) |
protected void |
execute()
Execute this job.
|
void |
flush() |
java.util.concurrent.atomic.AtomicInteger |
getCount() |
protected StateOperator |
getInitialStateOp()
Subclasses must provide the
StateOperator that will decide
how to evaluate the children's state. |
java.util.function.Function<? super java.util.function.Consumer<? super T>[],? extends java.util.function.Consumer<T>> |
getStrategy() |
protected void |
onReset()
Allow sub classes to do something on reset.
|
void |
setOf(int index,
java.lang.Object child)
Add a child.
|
void |
setStrategy(java.util.function.Function<? super java.util.function.Consumer<? super T>[],? extends java.util.function.Consumer<T>> strategy) |
addStructuralListener, fireDestroyedState, force, getStateChanger, hardReset, iconHelper, isStop, onDestroy, onHardReset, onSoftReset, onStop, postStop, removeStructuralListener, run, softReset, startChildStateReflector, stateHandler, stop, stopChildStateReflector, waitForChildrenOnStopconfigure, getName, logger, logger, loggerName, save, setName, toStringaddIconListener, addPropertyChangeListener, addStateListener, configure, destroy, firePropertyChange, getArooaSession, iconForId, initialise, lastStateEvent, onConfigured, onInitialised, removeIconListener, removePropertyChangeListener, removeStateListener, save, setArooaContext, setArooaSessionclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddStateListener, lastStateEvent, removeStateListenerprotected void execute()
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException
StructuralJobexecute in class StructuralJob<java.lang.Object>java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionpublic void flush()
throws java.io.IOException
flush in interface java.io.Flushablejava.io.IOExceptionprotected void onReset()
StructuralJobonReset in class StructuralJob<java.lang.Object>public void setOf(int index,
java.lang.Object child)
Property: of
Description: The components of a Bus.
Required: No, but pointless if missing.
child - A childprotected StateOperator getInitialStateOp()
StructuralJobStateOperator that will decide
how to evaluate the children's state.getInitialStateOp in class StructuralJob<java.lang.Object>public java.util.function.Function<? super java.util.function.Consumer<? super T>[],? extends java.util.function.Consumer<T>> getStrategy()
public void setStrategy(java.util.function.Function<? super java.util.function.Consumer<? super T>[],? extends java.util.function.Consumer<T>> strategy)
public java.util.concurrent.atomic.AtomicInteger getCount()