Skip to content

Commit

Permalink
Ensure @resource generated controllers are not lazy
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher committed May 30, 2016
1 parent 52db932 commit 6bb4de5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ class ControllersGrailsPlugin extends Plugin {
for (controller in application.getArtefacts(ControllerArtefactHandler.TYPE)) {
log.debug "Configuring controller $controller.fullName"
if (controller.available) {
def lazyInit = controller.hasProperty("lazyInit") ? controller.getPropertyValue("lazyInit") : true
"${controller.fullName}"(controller.clazz) { bean ->
bean.lazyInit = true
bean.lazyInit = lazyInit
def beanScope = controller.getScope()
bean.scope = beanScope
bean.autowire = "byName"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ class ResourceTransform implements ASTTransformation, CompilationUnitAware {
final uri = uriAttr.getText()
if(uri) {
final urlMappingsClassNode = new ClassNode(UrlMappings).getPlainNodeReference()

final lazyInitField = new FieldNode('lazyInit', PUBLIC | STATIC | FINAL, ClassHelper.Boolean_TYPE,newControllerClassNode, new ConstantExpression(Boolean.FALSE))
newControllerClassNode.addField(lazyInitField)

final urlMappingsField = new FieldNode('$urlMappings', PRIVATE, urlMappingsClassNode,newControllerClassNode, null)
newControllerClassNode.addField(urlMappingsField)
final urlMappingsSetterParam = new Parameter(urlMappingsClassNode, "um")
Expand Down

0 comments on commit 6bb4de5

Please sign in to comment.