views:

340

answers:

2

I have a camel route file which I want to populate/configure based on certain database records accessed through Grails domain classes. However, I cannot seem to access the domain classes (or anything in the spring context) from MyRoute.groovy. Any ideas on how I can make that possible?

I tried the recommendations at http://stackoverflow.com/questions/574807/grails-accessing-spring-beans-in-the-destory-closure-of-bootstrap-code but that doesn't seem to work.

+2  A: 

In the Java RouteBuilder you can get hold of the CamelContext with the getContext() method. I assume you have the same method in the groovy builder.

With the CamelContext you can lookup spring beans from its registry.

MyType foo = context.getRegistry().lookup("mySpringBean", MyType.class);

Claus Ibsen
You're exactly right. Unfortunately, it seems that this doesn't solve my issue though because at the the time I try to call the serviceBean it seems that it hasn't been GORMified yet and has no access to the database.
Abdullah Jibaly
A: 

You should take look at: http://camel.apache.org/hibernate.html

Please note, that you should add: ... ref('sessionFactory') ...

to beans section in your resources.groovy

archer
well, didn't try it as we don't have .hbm.xml files, so much assured it won't work. but this is very close to what we need ;)
archer