In order to schedule a task, a component needs a pointer to the Scheduler, which is usually set as a component property. The component schedules a new task by calling addScheduledJob on the Scheduler. The Scheduler executes the job as scheduled.

When the Scheduler executes a job, it calls performScheduledTask on the object that performs the task, which must implement atg.service.scheduler.Schedulable. Typically, the component that schedules the task is also the Schedulable component that executes it, but this is not strictly required.

When a component schedules a task, it must provide the Scheduler with the following information:

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

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

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.


Copyright © 1997, 2012 Oracle and/or its affiliates. All rights reserved.

Legal Notices