Class EqualsState

All Implemented Interfaces:
Serializable, Runnable, ArooaContextAware, ArooaSessionAware, Forceable, PropertyChangeNotifier, Iconic, LogEnabled, Resettable, Stateful, Stoppable, Structural

public class EqualsState extends StructuralJob<Stateful> implements Stoppable
Author:
Rob Gordon
See Also:

Description

Runs it's child job and then compares the state of the child job to the given state. It's own state is complete if the states match, incomplete otherwise.

This job is probably most useful in it's 'not equals' form - i.e. to check when something hasn't completed.

Example

COMPLETE when the child job isn't complete. This example demonstrates how the state:equals job can be used to reverse the meaning of the exists job. A request to shutdown a database may complete asynchronously, and the only way to tell if shutdown is complete is to check that the Database's lock file has be removed. This example demonstrates how Oddjob can check for this situation before attempting to back up the database.
<oddjob id="this">

    <job>

        <scheduling:retry name="Database Backup" xmlns:scheduling="http://rgordon.co.uk/oddjob/scheduling">

            <schedule>

                <schedules:interval interval="00:00:02" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules"/>

            </schedule>

            <job>

                <sequential id="db-backup">

                    <jobs>

                        <state:equals state="!COMPLETE" xmlns:state="http://rgordon.co.uk/oddjob/state">

                            <job>

                                <state:resets harden="true">

                                    <job>

                                        <exists file="${db.lock.file}"/>

                                    </job>

                                </state:resets>

                            </job>

                        </state:equals>

                        <echo>Backing up the Database...</echo>

                    </jobs>

                </sequential>

            </job>

        </scheduling:retry>

    </job>

</oddjob>