source: trunk/grails-app/jobs/TaskRecurringScheduleJob.groovy @ 613

Last change on this file since 613 was 199, checked in by gav, 15 years ago

Upgrade quartz plugin to 0.4.1 propper.
Refactor and enable quartz scheduling for recurring tasks.
Adjust svn ignores to ignore all log files.
Create a pseudo system person for automated insertions.

File size: 1.4 KB
RevLine 
[199]1import org.codehaus.groovy.grails.commons.*
[123]2
[199]3/**
4* Provides a quartz job that reviews and generates all recurring tasks.
5* The quartz scheduler is restarted if this file is edited so startDelay will then delay again.
6* The execute method is called once every repeatInterval (in milliseconds).
7* With concurrent=false the repeat interval starts counting after the previous job completes.
8* Apparently we need a hibernate session otherwise we get a LazyInitializationException, default is true but we specify it to be sure.
9*/
10class TaskRecurringScheduleJob {
[123]11
[199]12    def taskRecurringScheduleService
13
14    def concurrent = false
15    def sessionRequired = true
16
17    static triggers = {
18        simple name: "GenerateAll",
19                    startDelay: 60000,
20                    repeatInterval: ConfigurationHolder.config.taskRecurringScheduleJob.repeatInterval*1000
21    }
22
[123]23    def execute() {
24
[199]25        // Some information can be accessed if we run with "def execute(context) ".
26        // For more info see: http://quartz.sourceforge.net/javadoc/org/quartz/JobExecutionContext.html
27        // log.debug context.getTrigger()
28        // log.debug context.getPreviousFireTime()
29        // log.debug context.getFireTime()
[123]30
[199]31        // We do everything via services, quartz just sets up and fires off the thread.
32        taskRecurringScheduleService.generateAll()
33    }
[123]34}
Note: See TracBrowser for help on using the repository browser.