|
I currently have some Spring beans that I only want to be instantiated
if a particular configuration value is set. There are probably a number of different ways to do this, but currently it's set up like this: def doWithSpring = { if (ConfigurationHolder.config.requiredConfigValue) { customBean(com.my.customBean) { } } I know that ConfigurationHolder is deprecated, and would like to hear some opinions about other ways to accomplish this configuration. Thanks. --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
On 25/07/2012 18:18, Andrew Todd wrote:
> I currently have some Spring beans that I only want to be instantiated > if a particular configuration value is set. There are probably a > number of different ways to do this, but currently it's set up like > this: > > def doWithSpring = { > if (ConfigurationHolder.config.requiredConfigValue) { > customBean(com.my.customBean) { > } > } > > I know that ConfigurationHolder is deprecated, and would like to hear > some opinions about other ways to accomplish this configuration. > Thanks. In doWithSpring you have access to the GrailsApplication in the "application" variable, so if(application.config.requiredConfigValue) will do what you're after. 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 |
|
In reply to this post by Andrew Todd
The GrailsApplication is available as the 'application' variable, so you should do this:
def doWithSpring = { if (application.config.requiredConfigValue) { customBean(com.my.customBean) { } } } Burt
|
|
Thanks Ian and Burt, I'll give that a shot. It wasn't clear from the
docs that the application object was available in doWithSpring as well, since it's not passed into the closure. On Wed, Jul 25, 2012 at 1:22 PM, burtbeckwith <[hidden email]> wrote: > The GrailsApplication is available as the 'application' variable, so you > should do this: > > def doWithSpring = { > if (application.config.requiredConfigValue) { > customBean(com.my.customBean) { > } > } > } > > Burt > > > Andrew Todd wrote >> >> I currently have some Spring beans that I only want to be instantiated >> if a particular configuration value is set. There are probably a >> number of different ways to do this, but currently it's set up like >> this: >> >> def doWithSpring = { >> if (ConfigurationHolder.config.requiredConfigValue) { >> customBean(com.my.customBean) { >> } >> } >> >> I know that ConfigurationHolder is deprecated, and would like to hear >> some opinions about other ways to accomplish this configuration. >> Thanks. >> > > > > > -- > View this message in context: http://grails.1312388.n4.nabble.com/Reading-configuration-in-plugin-doWithSpring-closure-tp4632225p4632226.html > Sent from the Grails - user mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Powered by Nabble | Edit this page |
