[英]camel - get jndi registry
我正在使用apache駱駝,並且我將需要jndi注冊表,以便可以將對象綁定到它。
如何從RouteBuilder類檢索JNDI注冊表? 我也可以使用xml綁定嗎? 謝謝!
在添加上下文到camelMain
之前,我不能在RouteBuilder中執行此camelMain
。
JndiRegistry registry = new JndiRegistry();
...
registry.bind("myAntFilter", filter);
DefaultCamelContext context = new DefaultCamelContext(registry);
camelMain.getCamelContexts().add(context);
同樣重要的是要注意,您需要在/ resources中具有以下內容的jndi.properties:
java.naming.factory.initial = org.apache.camel.util.jndi.CamelInitialContextFactory
沒有這個,我就會例外。
希望它可以幫助偶然發現相同問題的人
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()
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.