Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mergedConfig support #58

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions CookieSessionGrailsPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())}\'"
Expand Down