2017-06-28 7 views
0

Grails 2では、Config.groovyファイルに次のコードブロックがありました。 ConfigurationManagementクラスは、構成管理データベースでランタイムルックアップを実行して、パラメータがtrueまたはfalseである必要があるかどうかを判断しました。同様の設定を使用して、追加のQuartzプロパティをロードしました。Grailsでの動的石英設定3

quartz { 
    def autoStartupOnTheseServers = ConfigurationManagement.getValue("myApp.quartz.autoStartupOnTheseServers", "").split(",") 

    if (autoStartupOnTheseServers.any { it.trim().toUpperCase() == hostName.toUpperCase() }) { 
     autoStartup = true 
    } 
    else { 
     autoStartup = false 
    } 

    // Default for clustering (jdbcStore) has to be "false" so the app will run locally. 
    // Clustering (jdbcStore) will be true for DEV, TEST, QA, and PROD (set by Configuartion Management). 
    jdbcStore = ConfigurationManagement.getValue("myApp.quartz.jdbcStore", "false").toBoolean() 
    // don't set the props if not enabling quartz clustering...causes an exception. 
    if(jdbcStore == true) { props(quartzProps) } 
} 

のGrails 3において、application.groovyで使用される同様のコードは動作せず、私はapplication.ymlを見つけることができる条件文のための任意の設備がありません。 Grails 3に同様の動的設定を行う方法はありますか?

答えて

0

Grails 3では、これらの値を直接設定することはできないようですが、ローカル変数を宣言してプロパティを設定することができます。上記の私の例では、以下の作品があります:

def extServerList = ConfigurationManagement.getValue("myApp.quartz.autoStartupOnTheseServers", "").split(",") 
def extAutoStartup = extServerList.any { it.trim().toUpperCase() == hostName.toUpperCase() } 
def extJdbcStore = ConfigurationManagement.getValue("myApp.quartz.jdbcStore", "false").toBoolean() 

quartz { 
    autoStartupOnTheseServers = extServerList 
    autoStartup = extAutoStartup 
    jdbcStore = extJdbcStore 
} 
関連する問題