Mike
Mike

Reputation: 2434

Externalize quartz config in grails

I'm trying to externalize the QuartzConfig.groovy

I want to be able to set autoStartup to true or false with an external file.

In Config.groovy it is possible to use the grails.config.locations and set properties file that override the properties. Is there something like this in QuartzConfig.groovy ?

Thank you

Upvotes: 2

Views: 2626

Answers (4)

gabe
gabe

Reputation: 1129

Starting Quartz in Bootstrap based on a regular config variable worked best for me.

QuartzConfig.groovy:

quartz {
    autoStartup = false
}

BootStrap.groovy:

class BootStrap {

    def grailsApplication
    def quartzScheduler

    def init = { servletContext ->
        if(grailsApplication.config.startQuartz)
            Thread.start { quartzScheduler.start() }
    }
}

Thanks to Burt. http://grails.1312388.n4.nabble.com/Reduce-Quartz-Plugin-Start-up-Time-td1371547.html

Upvotes: 0

Colin Harrington
Colin Harrington

Reputation: 4459

QuartzConfig.groovy still doesn't have an externalized configuration mechanism built-in.

We had the same question back in '10. Our solution was to fork the plugin and use the built-in configuration with it's externalized config

Fast forward to now (March '11) and It looks like the quartz plugin has implemented some new features.

https://github.com/grails-plugins/grails-quartz/blob/master/QuartzGrailsPlugin.groovy (checkout the loadQuartzConfig() section at the end of the file)

It looks like the functionality is extensible via the default Config.groovy config.locations mechanism.

This is what it appears to be doing:

  • loads the default config (Config.groovy)
  • merges in the DefaultQuartzConfig on from the classLoader
  • merges in the QuartzConfig from the classLoader
  • loads the quartz.properties from the classLoader

You can setup your configuration in Config.groovy now if you want.

Upvotes: 1

james.cookie
james.cookie

Reputation: 455

No, you can't. See this jira for more information.

Upvotes: 0

user2427
user2427

Reputation: 7932

You may want to look 3.4 Externalized Configuration of http://www.grails.org/doc/1.0.x/guide/3.%20Configuration.html.

Though I haven't try externalize for quartz, I have use this to externalize logging:

grails.config.locations = ["file:${userHome}/logger.groovy"]

And it works perfectly.

Upvotes: 0

Related Questions