骆驼-获取jndi注册表 [英] camel - get jndi registry
问题描述
我正在使用apache骆驼,我将需要jndi注册表,以便可以将对象绑定到它.
I'm using apache camel, and I will be needing the jndi registry so that I can bind an object to it.
如何从RouteBuilder类检索JNDI注册表?我也可以使用xml绑定吗? 谢谢!
How do I retrieve a JNDI registry from a RouteBuilder class? Can I also bind using xml? Thanks!
推荐答案
我无法在RouteBuilder中完成此操作,但可以在向camelMain
添加上下文之前.
I was able to do it not within the RouteBuilder but before adding context to the camelMain
.
JndiRegistry registry = new JndiRegistry();
...
registry.bind("myAntFilter", filter);
DefaultCamelContext context = new DefaultCamelContext(registry);
camelMain.getCamelContexts().add(context);
还必须注意,您需要在/resources中具有以下内容的jndi.properties:
It is also important to note that you need to have a jndi.properties in your /resources with the following content:
java.naming.factory.initial = org.apache.camel.util.jndi.CamelInitialContextFactory
java.naming.factory.initial = org.apache.camel.util.jndi.CamelInitialContextFactory
没有这个,我要例外了.
Without this, I'm getting an exception.
希望它可以帮助在相同问题上绊倒的人
Hope it helps people who stumbled on the same problem
这篇关于骆驼-获取jndi注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!