can resources.groovy be referenced as in Externalized Configuration?

View: New views
7 Messages — Rating Filter:   Alert me  

can resources.groovy be referenced as in Externalized Configuration?

by Edderd :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm able to define my Config.groovy and DataSource.groovy in external files per section 3.4 in http://grails.org/doc/1.1.x/

I am unable to do the same for the resources.groovy file which uses the grails Spring DSL. 

Is there a reason for this or am I doing something wrong?

Is there some alternative so that I can reference some externalized spring config in a grails/groovy way?

--
- Ed

Re: can resources.groovy be referenced as in Externalized Configuration?

by ianroberts :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ed Young wrote:
> I'm able to define my Config.groovy and DataSource.groovy in external
> files per section 3.4 in http://grails.org/doc/1.1.x/.
>
> I am unable to do the same for the resources.groovy file which uses the
> grails Spring DSL.

You should be able to put loadBeans("file:externalResources.groovy") or
similar into your normal resources.groovy.

Ian

--
Ian Roberts               | Department of Computer Science
i.roberts@...  | University of Sheffield, UK

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

    http://xircles.codehaus.org/manage_email



Re: can resources.groovy be referenced as in Externalized Configuration?

by Edderd :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I haven't been able to get loadBeans to work using any of the overloaded signatures. 

resources = {

}


On Sun, Nov 8, 2009 at 1:46 PM, Ian Roberts <i.roberts@...> wrote:
Ed Young wrote:
> I'm able to define my Config.groovy and DataSource.groovy in external
> files per section 3.4 in http://grails.org/doc/1.1.x/.
>
> I am unable to do the same for the resources.groovy file which uses the
> grails Spring DSL.

You should be able to put loadBeans("file:externalResources.groovy") or
similar into your normal resources.groovy.

Ian

--
Ian Roberts               | Department of Computer Science
i.roberts@...  | University of Sheffield, UK

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

   http://xircles.codehaus.org/manage_email





--
- Ed

Re: can resources.groovy be referenced as in Externalized Configuration?

by Edderd :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I haven't been able to get loadBeans to work using any of the overloaded signatures. 
This is the one that seems most relevant. 

beans = {
  loadBeans("file:c:\\myResources.groovy")
}

The file myResources.groovy looks like this: 

beans = {
     extConfig(com.mycompany.reporttool.ExtConfig) {
configValue = "Grails spring beanbuilder Configured externally!!"
                DEFAULT_DATA_PATH = "c:/development/software/apache/Apache2.2/htdocs/reports/"
}
}

When I try to access the extConfig in my controller with

def extConfig it fails with a NPE. 

Note, this works fine when I simply put the beans definition in the spring/resource.groovy file. 


 


On Sun, Nov 8, 2009 at 1:46 PM, Ian Roberts <i.roberts@...> wrote:
Ed Young wrote:
> I'm able to define my Config.groovy and DataSource.groovy in external
> files per section 3.4 in http://grails.org/doc/1.1.x/.
>
> I am unable to do the same for the resources.groovy file which uses the
> grails Spring DSL.

You should be able to put loadBeans("file:externalResources.groovy") or
similar into your normal resources.groovy.

Ian

--
Ian Roberts               | Department of Computer Science
i.roberts@...  | University of Sheffield, UK

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

   http://xircles.codehaus.org/manage_email





--
- Ed



--
- Ed

Re: can resources.groovy be referenced as in Externalized Configuration?

by Joshua Burnett :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

try removing the "=" right after beans in the myResources.groovy
instead of "beans = { ..." do "beans {..."


On Nov 8, 2009, at 9:38 PM, Ed Young wrote:

I haven't been able to get loadBeans to work using any of the overloaded signatures. 
This is the one that seems most relevant. 

beans = {
  loadBeans("file:c:\\myResources.groovy")
}

The file myResources.groovy looks like this: 

beans = {
     extConfig(com.mycompany.reporttool.ExtConfig) {
configValue = "Grails spring beanbuilder Configured externally!!"
                DEFAULT_DATA_PATH = "c:/development/software/apache/Apache2.2/htdocs/reports/"
}
}

When I try to access the extConfig in my controller with

def extConfig it fails with a NPE. 

Note, this works fine when I simply put the beans definition in the spring/resource.groovy file. 


 


On Sun, Nov 8, 2009 at 1:46 PM, Ian Roberts <i.roberts@...> wrote:
Ed Young wrote:
> I'm able to define my Config.groovy and DataSource.groovy in external
> files per section 3.4 in http://grails.org/doc/1.1.x/.
>
> I am unable to do the same for the resources.groovy file which uses the
> grails Spring DSL.

You should be able to put loadBeans("file:externalResources.groovy") or
similar into your normal resources.groovy.

Ian

--
Ian Roberts               | Department of Computer Science
i.roberts@...  | University of Sheffield, UK

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

   http://xircles.codehaus.org/manage_email





--
- Ed



--
- Ed


Re: can resources.groovy be referenced as in Externalized Configuration?

by Edderd :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Joshua. That did it. 

Now all I need is to get access to ${appName} and ${userHome} in my externalized resources.groovy file the way it's available to my externalized Config.groovy file. 

Any ideas there?


On Sun, Nov 8, 2009 at 9:25 PM, Joshua Burnett <joshgrails@...> wrote:
try removing the "=" right after beans in the myResources.groovy
instead of "beans = { ..." do "beans {..."


On Nov 8, 2009, at 9:38 PM, Ed Young wrote:

I haven't been able to get loadBeans to work using any of the overloaded signatures. 
This is the one that seems most relevant. 

beans = {
  loadBeans("file:c:\\myResources.groovy")
}

The file myResources.groovy looks like this: 

beans = {
     extConfig(com.mycompany.reporttool.ExtConfig) {
configValue = "Grails spring beanbuilder Configured externally!!"
                DEFAULT_DATA_PATH = "c:/development/software/apache/Apache2.2/htdocs/reports/"
}
}

When I try to access the extConfig in my controller with

def extConfig it fails with a NPE. 

Note, this works fine when I simply put the beans definition in the spring/resource.groovy file. 


 


On Sun, Nov 8, 2009 at 1:46 PM, Ian Roberts <i.roberts@...> wrote:
Ed Young wrote:
> I'm able to define my Config.groovy and DataSource.groovy in external
> files per section 3.4 in http://grails.org/doc/1.1.x/.
>
> I am unable to do the same for the resources.groovy file which uses the
> grails Spring DSL.

You should be able to put loadBeans("file:externalResources.groovy") or
similar into your normal resources.groovy.

Ian

--
Ian Roberts               | Department of Computer Science
i.roberts@...  | University of Sheffield, UK

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

   http://xircles.codehaus.org/manage_email





--
- Ed



--
- Ed




--
- Ed

Re: can resources.groovy be referenced as in Externalized Configuration?

by ianroberts :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ed Young wrote:
> Thanks Joshua. That did it.
>
> Now all I need is to get access to ${appName} and ${userHome} in my
> externalized resources.groovy file the way it's available to my
> externalized Config.groovy file.

System.getProperty('user.home') is a workaround for userHome.  If the
ApplicationHolder is set up at the point where this file is parsed then
ApplicationHolder.application.metadata.'app.name' would work for the
appName but I haven't tried this myself.

Ian

--
Ian Roberts               | Department of Computer Science
i.roberts@...  | University of Sheffield, UK

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

    http://xircles.codehaus.org/manage_email