org.oddjob.schedules.schedules
Class CountSchedule

java.lang.Object
  extended by org.oddjob.schedules.AbstractSchedule
      extended by org.oddjob.schedules.schedules.CountSchedule
All Implemented Interfaces:
Serializable, RefineableSchedule, Schedule

public final class CountSchedule
extends AbstractSchedule
implements Serializable

Description

This schedule returns up to count number of child schedules. It is typically used to count a number intervals for re-trying something.

If there is more than one count in a schedule a key must be provided to differentiate their internally store numbers, otherwise the count value would be shared.

If the nested schedule isn't specified it defaults to NowSchedule

Example

A schedule for 5 times at intervals of 15 minutes.
<schedules:count count="5" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules">
    <refinement>
        <schedules:interval interval="00:15"/>
    </refinement>
</schedules:count>

Example

A schedule for 3 times each day at 5 minute intervals.
<schedules:daily xmlns:schedules="http://rgordon.co.uk/oddjob/schedules">
    <refinement>
        <schedules:time from="11:00">
            <refinement>
                <schedules:count count="3">
                    <refinement>
                        <schedules:interval interval="00:05"/>
                    </refinement>
                </schedules:count>
            </refinement>
        </schedules:time>
    </refinement>
</schedules:daily>

Example

Nested count schedules. This slightly contrived example would cause a timer to run a job twice at 1 minute intervals for 3 days. Note that we need a key on one of the schedules to differentiate them.
<schedules:count identifier="outer" count="6" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules">
    <refinement>
        <schedules:daily from="11:00">
            <refinement>
                <schedules:count count="2">
                    <refinement>
                        <schedules:interval interval="00:01"/>
                    </refinement>
                </schedules:count>
            </refinement>
        </schedules:daily>
    </refinement>
</schedules:count>
See Also:
Serialized Form
Author:
Rob Gordon

Constructor Summary
CountSchedule()
          Bean constructor.
CountSchedule(int countTo)
          Constructor with count.
 
Method Summary
 int getCount()
          Get the number to count to.
 String getIdentifier()
          Getter for key.
 ScheduleResult nextDue(ScheduleContext context)
          For a given date a schedule will provide the interval this schedule should next be scheduled in.
 void setCount(int count)
          Set the number to count to.
 void setIdentifier(String key)
          Setter for key.
 String toString()
          Override toString to be more meaningful.
 
Methods inherited from class org.oddjob.schedules.AbstractSchedule
getRefinement, setRefinement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CountSchedule

public CountSchedule()
Bean constructor.


CountSchedule

public CountSchedule(int countTo)
Constructor with count.

Parameters:
countTo -
Method Detail

setCount

public void setCount(int count)
Set the number to count to.

Parameters:
count - The number to count to.

getCount

public int getCount()
Get the number to count to.

Returns:
The number to count to.

getIdentifier

public String getIdentifier()
Getter for key.

Returns:

setIdentifier

public void setIdentifier(String key)
Setter for key.

Parameters:
key -

nextDue

public ScheduleResult nextDue(ScheduleContext context)
Description copied from interface: Schedule
For a given date a schedule will provide the interval this schedule should next be scheduled in.

If the schedule is never due again for the given date, null is returned.

Specified by:
nextDue in interface Schedule
Returns:
The next due interval for the schedule.

toString

public String toString()
Override toString to be more meaningful.

Overrides:
toString in class Object