diff --git a/grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/ControllersGrailsPlugin.groovy b/grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/ControllersGrailsPlugin.groovy index 90b6c52ba81..7e444dc1612 100644 --- a/grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/ControllersGrailsPlugin.groovy +++ b/grails-plugin-controllers/src/main/groovy/org/grails/plugins/web/controllers/ControllersGrailsPlugin.groovy @@ -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" diff --git a/grails-plugin-rest/src/main/groovy/org/grails/plugins/web/rest/transform/ResourceTransform.groovy b/grails-plugin-rest/src/main/groovy/org/grails/plugins/web/rest/transform/ResourceTransform.groovy index ad320012db2..a312bb17efc 100644 --- a/grails-plugin-rest/src/main/groovy/org/grails/plugins/web/rest/transform/ResourceTransform.groovy +++ b/grails-plugin-rest/src/main/groovy/org/grails/plugins/web/rest/transform/ResourceTransform.groovy @@ -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")