Provide classes and interfaces for scheduling some tasks that can be recurrent.
The recurrence is a Quartz CRON expression.
Few special entries are allowed:
- @tradingday: runs when the trading day change
- @reboot: runs when the system is restarted
Defining a new task
A new task must implements a {@link Task} interface.
The run() method is called when the recurrence occurs.
The task interface includes a method setData(Object data) that receive
the context of the task when submitted. The current implementation sets
only the current TradingDay value when the task is submitted @tradingday.
Other recurrences won't provide any data.
The getName() must provide a unique name to retrieve the task from the factory.
Start up
The start process is part of the ServerMate start up.
Register the tasks
At start up, all instances of {@link Task} MUST be registered into the {@link TaskFactory} factory.
The task name property into a {@link Schedule} MUST match the task name of a registered {@link Task}. A task name MUST be unique.
Start the {@link Scheduler}
For each {@link Schedule} instances, a method startTimer() into {@link Scheduler} is called.
Following the start, the method runReboot is called.
When the trading day change, the method runTradingDay is called.
Schedule a task
This schedule is defined into the persistent class {@link Schedule}.
If a task is deleted or changed, it is rescheduled by calling
endTimer and startTimer: the creation or modification of a schedule
instance cancels the corresponding timer task and creates a new one
using the new recurrence. The deletion of a schedule cancels the timer.
Note: this package contains many public classes and methods that should not be
public. However, due to the previous test package structure, everything needed
to be public. The classes that are not documented in this page should be package private.