5.8. JNDI
JNDI 集成由 JBoss EAP 特定的 CamelContext 提供,如下所示:
InitialContext inictx = new InitialContext(); CamelContextFactory factory = inictx.lookup("java:jboss/camel/CamelContextFactory"); WildFlyCamelContext camelctx = factory.createCamelContext();
从 WildFlyCamelContext
,您可以获得预配置的命名上下文
Context context = camelctx.getNamingContext(); context.bind("helloBean", new HelloBean());
然后可以从 Camel 路由引用。
camelctx.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start").beanRef("helloBean"); } }); camelctx.start();