Quantcast

Using ConfigObject in resources.groovy under grails 2?

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

Using ConfigObject in resources.groovy under grails 2?

Luis Muniz-2
Hi,

In grails 1.x, we could obtain the ConfigurationHolder object in resources.groovy, and wire the configuration into psring beans, take complex decisions, etc.

I was wondering whether there is an alternate way to use this configuration method, now that the ConfigurationHolder is deprecated.

grailsApplication is probably not fully instantiated when we build the beans so i guess the grailsApplication.config way is not possible?


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

Re: Using ConfigObject in resources.groovy under grails 2?

Luis Muniz-2
Ops sorry, should have searched the mailing list more thoroughly. I still need to test it, but this should work:

application.config.my.property


On Fri, Dec 16, 2011 at 1:48 PM, Luis Muniz <[hidden email]> wrote:
Hi,

In grails 1.x, we could obtain the ConfigurationHolder object in resources.groovy, and wire the configuration into psring beans, take complex decisions, etc.

I was wondering whether there is an alternate way to use this configuration method, now that the ConfigurationHolder is deprecated.

grailsApplication is probably not fully instantiated when we build the beans so i guess the grailsApplication.config way is not possible?



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

Re: Using ConfigObject in resources.groovy under grails 2?

Ian Roberts
In reply to this post by Luis Muniz-2
On 16/12/2011 12:48, Luis Muniz wrote:
> Hi,
>
> In grails 1.x, we could obtain the ConfigurationHolder object in
> resources.groovy, and wire the configuration into psring beans, take
> complex decisions, etc.

An aside - if you want to wire Config.groovy entries into bean
definitions the easiest way is to use something like

someProperty = '${myapp.confOption}'

with *single* quotes.  This sets the property value in the bean def to
the literal string ${myapp.configOption} and this is then resolved
against the config later in the process by Spring's
PropertyPlaceholderConfigurer.

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


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

Re: Using ConfigObject in resources.groovy under grails 2?

Luis Muniz-2
Aha! sweet!!!

On Fri, Dec 16, 2011 at 1:59 PM, Ian Roberts <[hidden email]> wrote:
On 16/12/2011 12:48, Luis Muniz wrote:
Hi,

In grails 1.x, we could obtain the ConfigurationHolder object in
resources.groovy, and wire the configuration into psring beans, take
complex decisions, etc.

An aside - if you want to wire Config.groovy entries into bean definitions the easiest way is to use something like

someProperty = '${myapp.confOption}'

with *single* quotes.  This sets the property value in the bean def to the literal string ${myapp.configOption} and this is then resolved against the config later in the process by Spring's PropertyPlaceholderConfigurer.

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...