[Index]

bus:bus


Links components in a data pipeline. Components provide data by accepting an java.util.function.Consumer either by being an org.oddjob.beanbus.Outbound or by marking a setter with the org.oddjob.beanbus.Destination annotation. Components accept data by being a java.util.function.Consumer. Components can be both.

This component parent provides the following features over other component parents such as sequential:


Property Summary

busConductor Provides coordination facilities to the components of a bus.
count  
name A name, can be any text.
noAutoLink Bus components will automatically be linked unless this is true.
of The components of a Bus.
services Provides services to other components of a bus.
stop Read only view of the internal stop flag.
to An onward consumer so that bus services may be nested.

Example Summary

Example 1 A simple bus of 3 components.
Example 2 Shows how a bus can be nested to create side branches.

Property Detail

busConductor

Configured ByELEMENT
AccessREAD_WRITE
RequiredNo.

Provides coordination facilities to the components of a bus. Set automatically and exposed for advance use only.

count

AccessREAD_ONLY

name

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

A name, can be any text.

noAutoLink

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo, defaults to false.

Bus components will automatically be linked unless this is true.

of

Configured ByELEMENT
AccessWRITE_ONLY
RequiredNo, but pointless if missing.

The components of a Bus.

services

AccessREAD_ONLY
RequiredRead Only.

Provides services to other components of a bus. Exposed for advance use only.

stop

AccessREAD_ONLY

Read only view of the internal stop flag. This flag is cleared with a reset.

to

Configured ByELEMENT
AccessREAD_WRITE
RequiredNo.

An onward consumer so that bus services may be nested.


Examples

Example 1

A simple bus of 3 components. The first component is the bus driver that sends 3 beans down the pipe. The second component is a function that doubles the price and the last component collects the results.

<oddjob>
    <job>
        <bus:bus id="bean-bus" xmlns:bus="oddjob:beanbus">
            <of>
                <bus:driver>
                    <values>
                        <list>
                            <values>
                                <value value="#{25.5}"/>
                                <value value="#{36.2}"/>
                                <value value="#{40.4}"/>
                            </values>
                        </list>
                    </values>
                </bus:driver>
                <bus:map>
                    <function>
                        <value value="#{ function(x) { return x * 2 } }"/>
                    </function>
                </bus:map>
                <bus:collect id="results"/>
            </of>
        </bus:bus>
    </job>
</oddjob>

Example 2

Shows how a bus can be nested to create side branches. The data is passed to each branch in turn.

<oddjob>
    <job>
        <cascade>
            <jobs>
                <bus:bus id="bus" xmlns:bus="oddjob:beanbus">
                    <of>
                        <bus:driver>
                            <values>
                                <list>
                                    <values>
                                        <value value="red"/>
                                        <value value="red"/>
                                        <value value="blue"/>
                                        <value value="green"/>
                                    </values>
                                </list>
                            </values>
                        </bus:driver>
                        <bus:bus>
                            <of>
                                <bus:filter id="filterRed">
                                    <predicate>
                                        <value value="#{ function(x) { return 'red' == x }}"/>
                                    </predicate>
                                </bus:filter>
                            </of>
                        </bus:bus>
                        <bus:bus>
                            <of>
                                <bus:filter id="filterBlue">
                                    <predicate>
                                        <value value="#{ function(x) { return 'blue' == x }}"/>
                                    </predicate>
                                </bus:filter>
                            </of>
                        </bus:bus>
                    </of>
                </bus:bus>
                <check value="${filterRed.passed}" eq="2"/>
                <check value="${filterBlue.passed}" eq="1"/>
            </jobs>
        </cascade>
    </job>
</oddjob>


(c) R Gordon Ltd 2005 - Present