Under Grails 3, I took the recommendation of Jeff Scott Brown and used GrailsApplicationAware instead:
Here's how you are going to configure the bean:
So, in your new plugin descriptor, you need to change the grails 2 def doWithSpring style to ClosureDoWithSpring, as shown below:
Notice that in Grails 2 we introduced grailsApplication, in grails 3 all we do is declare a bean:
/* def doWithSpring = { sshConfig(SshConfig) { grailsApplication = ref('grailsApplication') } } */ Closure doWithSpring() { {-> sshConfig(SshConfig) } }
Now, to get your plugin configuration:
Src / main / groovy / grails / plugin / remotessh / sshconfig sshconfig.groovy
package grails.plugin.remotessh import grails.core.GrailsApplication import grails.core.support.GrailsApplicationAware class SshConfig implements GrailsApplicationAware { GrailsApplication grailsApplication public ConfigObject getConfig() { return grailsApplication.config.remotessh ?: '' } }
grails.plugin.remotessh.RemoteSsh.groovy:
String Result(SshConfig ac) throws InterruptedException { Object sshuser = ac.config.USER ?: '' Object sshpass = ac.config.PASS ?: '' ...
Now your configuration object is passed to the groovy src classes. The end user application would pass the sshConfig bean as follows:
class TestController { def sshConfig def index() { RemoteSSH rsh = new RemoteSSH() .... def g = rsh.Result(sshConfig) }
Edited to add, just found this :) which is a relevant or recurring question:
http://grails.1312388.n4.nabble.com/Getting-application-config-in-doWithSpring-closure-with-a-Grails-3-application-td4659165.html