diff --git a/CookieSessionGrailsPlugin.groovy b/CookieSessionGrailsPlugin.groovy index 3021c6d..0ef8079 100644 --- a/CookieSessionGrailsPlugin.groovy +++ b/CookieSessionGrailsPlugin.groovy @@ -49,8 +49,21 @@ class CookieSessionGrailsPlugin { def doWithWebDescriptor = { xml -> - if ( !application.config.grails.plugin.cookiesession.enabled ) { - return + try { + // Something is wrong with mergedConfig, so just call it here to have value, otherwise its is not initialized + if( application.mergedConfig?.grails?.plugin?.cookiesession?.enabled ) + { + } + if ( !application.config.grails.plugin.cookiesession.enabled && !application.mergedConfig.grails.plugin.cookiesession.enabled ) { + return + } + } + catch( e ) + { + log.debug "plugin-config (mergedConfig) is not available, checking normal config" + if ( !application.config.grails.plugin.cookiesession.enabled ) { + return + } } // add the filter after the last context-param @@ -75,8 +88,21 @@ class CookieSessionGrailsPlugin { def doWithSpring = { - if ( !application.config.grails.plugin.cookiesession.enabled ) { - return + try { + // Something is wrong with mergedConfig, so just call it here to have value, otherwise its is not initialized + if( application.mergedConfig?.grails?.plugin?.cookiesession?.enabled ) + { + } + if ( !application.config.grails.plugin.cookiesession.enabled && !application.mergedConfig.grails.plugin.cookiesession.enabled ) { + return + } + } + catch( e ) + { + log.debug "plugin-config (mergedConfig) is not available, checking normal config" + if ( !application.config.grails.plugin.cookiesession.enabled ) { + return + } } sessionRepository(CookieSessionRepository){ diff --git a/src/groovy/com/granicus/grails/plugins/cookiesession/CookieSessionRepository.groovy b/src/groovy/com/granicus/grails/plugins/cookiesession/CookieSessionRepository.groovy index dbf72cd..cd5cd66 100644 --- a/src/groovy/com/granicus/grails/plugins/cookiesession/CookieSessionRepository.groovy +++ b/src/groovy/com/granicus/grails/plugins/cookiesession/CookieSessionRepository.groovy @@ -273,6 +273,10 @@ class CookieSessionRepository implements SessionRepository, InitializingBean, Ap def assignedSetting = false try{ def configKey = grailsApplication.config.grails.plugin.cookiesession.find{ k,v -> k.equalsIgnoreCase(settingName) } + if( !configKey ) + { + configKey = grailsApplication.mergedConfig?.grails?.plugin?.cookiesession?.find{ k,v -> k.equalsIgnoreCase(settingName) } + } if( configKey ){ this.(targetPropertyName.toString()) = configKey.value.asType(t) log.info "grails.plugin.cookiesession.${configKey.key} set: \'${this.(targetPropertyName.toString())}\'"