In order for a component to schedule a task, the component needs a pointer to the Scheduler, which is usually set as a property. The component then schedules a new task by calling addScheduledJob on the Scheduler. The Scheduler handles things from there, waiting until the time comes to execute the job.

When the Scheduler executes a job, it calls performScheduledTask on the object that is supposed to perform the task, which must implement atg.service.scheduler.Schedulable. Most often the component that scheduled the task will also be the Schedulable that will handle the task, but this is not strictly required.

When a component schedules a task, it must specify enough information for the Scheduler to handle the scheduling:

All of this information is encapsulated in a ScheduledJob object, which is passed to the addScheduledJob method of the Scheduler.

When a job is added to the Scheduler, the Scheduler returns a job ID for the job, which is an integer that can later refer to that job. For example, to stop a scheduled job, you can call removeScheduledJob on the Scheduler, passing in the ID of the job to be stopped.

When the Schedulable object is called to perform a task, it is passed the ScheduledJob object that was used to schedule that task. This is useful in the case where a single service is supposed to perform several kinds of scheduled tasks, and needs the properties of the ScheduledJob to determine which task it is supposed to perform.

 
loading table of contents...