1

Relating to Accessing grails application config from a quartz job:

Apparently, DI doesn't happen prior to the creation of a job. I'm guessing this is the same with other grails artefacts (couldn't spot relevant documentation).

In my particular case, I was aiming to load a property from config and expose that property from the job class. In general though, it seems a valid use-case to me, that artefacts will load configuration, and then return those properties via API.

I'm wondering then, how could this be achieved when a class cannot rely on access to grailsApplication.config at construction.

Thanks

Community
  • 1
  • 1
pointyhat
  • 568
  • 5
  • 16

1 Answers1

0

Try with:

import org.codehaus.groovy.grails.commons.ConfigurationHolder as CH

class MyJob {
   def execute() {
      def myConfigVar = CH.flatConfig.get('my.var.setup.in.config.groovy')
      ...
   }
}

OR

import grails.util.Holders

class MyJob {
   def execute() {
      def myConfigVar = Holders.config.my.var.setup.in.config.groovy
      ...
   }
}
Fran García
  • 2,011
  • 16
  • 24