开发者

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


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.


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.


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜