Is it possible to reference variables defined in different configuration files in grails?

163 Views Asked by At

I've seen several similar questions but I haven't found a solution. Apologies if this is a duplicate.

My datasource is MongoDB and its properties are being defined in an external configuration file by the user like so :

External Datasource File

mongo {
    host = "mongohost"
    port = 27017
    databaseName = "myDatabase"
}

This is fine and its been working well for quite a while. The problem has arisen now that I've added quartz to the application. I need to define the datasource for quartz in a Quartz configuration file.

QuartzConfig.groovy

quartz {
    autoStartup = true
    jdbcStore = false
    waitForJobsToCompleteOnShutdown = true
    exposeSchedulerInRepository = false

    props {
        scheduler.skipUpdateCheck = true
        jobStore.class="com.novemberain.quartz.mongodb.MongoDBJobStore"
        jobStore.mongoUri="${mongo.host}"
        jobStore.addresses="${mongo.host}"
        jobStore.dbName="quartz"
        jobStore.collectionPrefix="quartz"
        threadPool.threadCount=1
    }
}

The host should be the same as the user defined host in the external datasource. I can't seem to be able to access the mongo.host variable no matter what I try. One option would be to require the user to specify quartz configuration in the external file too but I don't want to do that as I want to keep that file as basic as possible. I'd like to just reuse the mongo.host variable.

Does anyone know how?

Note I'm using the quartz-mnongo class developed here https://github.com/michaelklishin/quartz-mongodb if anyone who is using quartz stumbles across the question and finds it strange that I have mongo configuration options.

0

There are 0 best solutions below