| 
                Last change
                  on this file since 227 was
                  199,
                  checked in by gav, 16 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
           | 
      
      
        
  | Line |   | 
|---|
| 1 | import org.codehaus.groovy.grails.commons.* | 
|---|
| 2 |  | 
|---|
| 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 | */ | 
|---|
| 10 | class TaskRecurringScheduleJob { | 
|---|
| 11 |  | 
|---|
| 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 |  | 
|---|
| 23 |     def execute() { | 
|---|
| 24 |  | 
|---|
| 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() | 
|---|
| 30 |  | 
|---|
| 31 |         // We do everything via services, quartz just sets up and fires off the thread. | 
|---|
| 32 |         taskRecurringScheduleService.generateAll() | 
|---|
| 33 |     } | 
|---|
| 34 | } | 
|---|
       
      
      Note: See 
TracBrowser
        for help on using the repository browser.