Quantcast

plugin doWithSpring grailsApplication

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

plugin doWithSpring grailsApplication

Dencel
Hello,
 I've created an entity in my plugin which I want to wire into spring and initialize with the grailsApplication, but I can't get it to function.
The bean gets initialized and is available but grailsApplication is null.
Any ideas how to accomplish this?

This is my class:
class SmartServerConfig {
    GrailsApplication grailsApplication /* does not resolve automatic */
}

// This is what I've tried in the MyGrailsPlugin
    def doWithSpring = {
        smartServerConfig(SmartServerConfig){
            grailsApplication:application
        }
    }
//  Does not work, grailsApplication null
    def doWithSpring = {
        smartServerConfig(SmartServerConfig){
            grailsApplication:grailsApplication
        }
    }
//  Does not work, grailsApplication null
def doWithSpring = {
        smartServerConfig(SmartServerConfig)
}
//  Does not work, grailsApplication null

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: plugin doWithSpring grailsApplication

Ian Roberts
On 20/07/2012 13:23, Dennie.nl wrote:
> Hello,
>  I've created an entity in my plugin which I want to wire into spring
> and initialize with the grailsApplication, but I can't get it to function.
> The bean gets initialized and is available but grailsApplication is null.
> Any ideas how to accomplish this?

There's two ways to do it.  Either wire it in explicitly using ref:

def doWithSpring = {
    smartServerConfig(SmartServerConfig){
        grailsApplication = ref('grailsApplication')
    }
}

or enable autowiring by name (which is what services, controllers, etc. use)

def doWithSpring = {
    smartServerConfig(SmartServerConfig) { bean ->
        bean.autowire = "byName"
    }
}

Ian

--
Ian Roberts               | Department of Computer Science
[hidden email]  | University of Sheffield, UK



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Loading...