I'm embedding camel in ActiveMQ. I start activemq, which reads
$ACTIVEMQ_HOME/conf/activemq.xml . I want to use the java DSL for my routes,
using the <package> tag in activemq.xml to allow them to be discovered from
the classpath. The RouteBuilders defined there use a Registry based on the
ApplicationContext defined by the activemq.xml file, whereas I want them to
see a registry built out of an ApplicationContext that already exists,
defined by my code and spring xml files in my jars. 

It looks like the activemq.xml parsing of the camelContext element is
handled by org.apache.camel.spring.handler.CamelNamespaceHandler which uses
a org.apache.camel.spring.CamelContextFactoryBean. This is
ApplicationContextAware and uses the injected context as the basis for a
SpringCamelContext. This is used in installRoutes(), which calls addRoutes()
on the discovered RouteBuilders, whereupon each RouteBuilder's context is
set to the SpringCamelContext from CamelContextFactoryBean.

So it seems what I need to do is to tell the CamelContextFactoryBean to use
the ApplicationContext I want. An equivalent way is to start activemq and
have the application context it constructs from the activemq.xml use mine as
a parent. It looks like I could do that by overriding
createApplicationContext() in XBeanBrokerFactory to call
ResourceXmlApplicationContext(resource, parent) and having my subclass
override the handling of xbean: uri's. Is this overkill? 



-- 
View this message in context: 
http://www.nabble.com/Controlling-the-ApplicationContext-used-by-a-RouteBuilder-tp17594236s22882p17594236.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to