我正在使用apache,我将需要jndi注册中心,这样我就可以将一个对象绑定到它。
如何从RouteBuilder类检索JNDI注册表?我还可以使用xml绑定吗?谢谢!
发布于 2014-03-12 10:12:40
我不是在RouteBuilder中,而是在向camelMain添加上下文之前做到了这一点。
JndiRegistry registry = new JndiRegistry();
...
registry.bind("myAntFilter", filter);
DefaultCamelContext context = new DefaultCamelContext(registry);
camelMain.getCamelContexts().add(context);还需要注意的是,您需要在您的jndi.properties中有一个具有以下内容的/resources:
org.apache.camel.util.jndi.CamelInitialContextFactory = java.naming.factory.initial
如果没有这个,我会得到一个例外。
希望它能帮助那些遇到同样问题的人。
发布于 2014-02-14 13:10:02
CamelContext.getRegistry()适合你的需要吗?
/**
* Returns the registry used to lookup components by name and type such as the Spring ApplicationContext,
* JNDI or the OSGi Service Registry
*
* @return the registry
*/
Registry getRegistry();否则,您可以通过blueprint.xml或位于META-INF.spring中的spring上下文文件将事物(bean、服务引用等)绑定到注册表中。
出于测试目的,您有CamelTestSupport.createRegistry()。
https://stackoverflow.com/questions/21773330
复制相似问题