3

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 Grails: Accessing spring beans in the destory closure of Bootstrap code? but that doesn't seem to work.

Community
  • 1
  • 1
Abdullah Jibaly
  • 53,220
  • 42
  • 124
  • 197

2 Answers2

3

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
  • 56,060
  • 7
  • 50
  • 65
  • 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 Jun 09 '09 at 07:36
0

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
  • 5,073
  • 8
  • 50
  • 96
  • 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 Feb 27 '10 at 15:12