On 17/01/2008, DominicTulley <[EMAIL PROTECTED]> wrote: > > Hi, I've written a RouteBuilder implementation which I am deploying in > AMQ/Camel using the <package> element in the CamelContext. > This is working fine - the router deploys and runs as expected. However, I > really want to have some configurable properties in this class and I'm > struggling to work out how to do this. > > I thought of creating another bean in the activemq.xml file (just a plain > old bean that contains configuration information and can be customised in > the xml file). Is there any way for my router to find the singleton > instance that gets created? Also, is there a way to make the dependency > explicit, so that initialisation of the route builder is deferred until > after the config bean has been built? > > I'm a bit stumped and would appreciate suggestions either on how to make > this way work, or an alternative approach.
When the CamelContext instantiates any RouteBuilder class it uses Spring to perform any dependency injection; so you could add some Spring annotations for injection to try configure things that way. e.g. you could use @AutoWire or @Resource or whatever to inject things you need. Currently creating a RouteBuilder explicitly in spring.xml doesn't actually register it with the CamelContext. We could solve that either via having some kinda property in the XML like... <camelContext ...> <routeBuilder ref="someID"/> ... </camelContext> <bean id="someID" .../> Or we could have an auto-registering RouteBuilder class which implements CamelContextAware and when injected with the CamelContext calls CamelContext.addRoutes(this); -- James ------- http://macstrac.blogspot.com/ Open Source Integration http://open.iona.com
