Reputation: 1175
In my grials application I have a job that runs, and this its trigger defenition:
static triggers = {
simple name: 'myJob', startDelay: 1000, repeatInterval: 36000000
}
I would like to change it that the value shouln't be hard coded, but they should be taken from a congif/properties file.
I tried this:
Config.groovy:
myJob {
simpleName = 'myJob'
startDelay = '1000'
repeatInterval = '36000000'
}
and in the job trigger:
static triggers = {
simple name: grailsApplication.config.myJob.name, startDelay: grailsApplication.config.myJob.startDelay, repeatInterval: grailsApplication.config.myJob.repeatInterval
}
But then I get a message saying: Cannot reference nonstatic symbol 'grailsApplication' from static context.
Does anyone have a better idea how to do so?
Thanks.
Upvotes: 2
Views: 1368
Reputation: 1
you can use like this ${org.codehaus.groovy.grails.commons.ConfigurationHolder.config.myJob.name}
Upvotes: 0
Reputation: 2383
Try using the Holders helper class.
import grails.util.Holders
static triggers = {
simple name: Holders.config.myJob.name,
startDelay: Holders.config.myJob.startDelay,
repeatInterval: Holders.config.myJob.repeatInterval
}
Upvotes: 7
Reputation: 2677
I have found also this problem and what I usually do is store the properties in the .properties file, remove the triggers from the Quartz job and then manually bootstrap those jobs in Bootstrap.groovy getting the values from the properties file.
Check this: Quartz Plugin Documentation to see how to trigger the jobs
Upvotes: 0