Search code examples
grails

Grails 4 Controllers: Where in Grails 4 code can I find a proof that grails.controllers.defaultScope = 'singleton'


From various searches

I understand the default Controllers scope changed from 'prototype' to 'singleton', perhaps a long time ago. I want to understand in which version exactly the change happened.

But as I should only ask one question, I am asking:

Where in Grails 4 code can I find a proof that grails.controllers.defaultScope = 'singleton'?


Solution

  • Here is the key for that setting - https://github.com/grails/grails-core/blob/948bf681ece30322e7bd5e63bf734fbf0ce68ec0/grails-core/src/main/groovy/grails/config/Settings.groovy#L109

    Here is a test that the setting works - https://github.com/grails/grails-core/blob/7ab9e47ad805fbeb9433a488dd33f91bef44c0fa/grails-core/src/test/groovy/org/grails/core/DefaultGrailsControllerClassSpec.groovy#L15-L25

    And here is where it is actually set - though it does seem that if it is unset in config it would be prototype, (which... is odd) - https://github.com/grails/grails-core/blob/7ab9e47ad805fbeb9433a488dd33f91bef44c0fa/grails-core/src/main/groovy/org/grails/core/DefaultGrailsControllerClass.java#L80