[Index]

events:when


Runs a job when triggered by the arrival of an event.

Property Summary

jobs The child jobs.
name A name, can be any text.
stop Read only view of the internal stop flag.
trigger The trigger event.

Example Summary

Example 1 Evaluating greengrocer portfolios of fruit when data arrives.

Property Detail

jobs

Configured ByELEMENT
AccessWRITE_ONLY
RequiredNo, but pointless if missing.

The child jobs.

name

Configured ByATTRIBUTE
AccessREAD_WRITE
RequiredNo.

A name, can be any text.

stop

AccessREAD_ONLY

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

trigger

AccessREAD_ONLY
RequiredRead only.

The trigger event.


Examples

Example 1

Evaluating greengrocer portfolios of fruit when data arrives.

<oddjob id="this">
    <job>
        <sequential>
            <jobs>
                <properties name="Properties">
                    <values>
                        <file file="${some.dir}" key="data.dir"/>
                    </values>
                </properties>
                <bean class="org.oddjob.events.example.FileFactStore" id="factStore" rootDir="${data.dir}"/>
                <events:when id="whenBookList" name="When BookList Available" xmlns:events="oddjob:events">
                    <jobs>
                        <bean class="org.oddjob.events.example.FactSubscriber" factStore="${factStore}" name="Subscribe to BookList" query="BookList:GREENGROCERS"/>
                        <foreach id="forEachBook" name="For Each Book">
                            <values>
                                <value value="${whenBookList.trigger.of.books}"/>
                            </values>
                            <configuration>
                                <inline>
                                    <foreach id="bookName">
                                        <job>
                                            <events:when id="whenBook" name="When ${bookName.current}">
                                                <jobs>
                                                    <bean class="org.oddjob.events.example.FactSubscriber" factStore="${factStore}" name="Subscribe to Book ${bookName.current}" query="Book:${bookName.current}"/>
                                                    <events:when id="priceMatch" name="When Prices for ${bookName.current}">
                                                        <jobs>
                                                            <events:for name="For Each Trade">
                                                                <configuration>
                                                                    <inline>
                                                                        <events id="trade">
                                                                            <job>
                                                                                <bean class="org.oddjob.events.example.FactSubscriber" factStore="${factStore}" name="Subscribe to Price for ${trade.current.product}" query="Price:${trade.current.product}"/>
                                                                            </job>
                                                                        </events>
                                                                    </inline>
                                                                </configuration>
                                                                <values>
                                                                    <value value="${whenBook.trigger.of.trades}"/>
                                                                </values>
                                                            </events:for>
                                                            <sequential name="Run Calculation">
                                                                <jobs>
                                                                    <bean class="org.oddjob.events.example.ValueCalculator" id="calculate">
                                                                        <trades>
                                                                            <value value="${whenBook.trigger.of.trades}"/>
                                                                        </trades>
                                                                        <prices>
                                                                            <value value="${priceMatch.trigger.ofs}"/>
                                                                        </prices>
                                                                    </bean>
                                                                    <echo>Value of ${bookName.current} is ${calculate.value}</echo>
                                                                </jobs>
                                                            </sequential>
                                                        </jobs>
                                                    </events:when>
                                                </jobs>
                                            </events:when>
                                        </job>
                                    </foreach>
                                </inline>
                            </configuration>
                        </foreach>
                    </jobs>
                </events:when>
            </jobs>
        </sequential>
    </job>
</oddjob>


(c) R Gordon Ltd 2005 - Present