Camel .beanRef deprecated - how now to access container-managed beans in Java DSL route?

眉间皱痕 提交于 2019-12-24 10:13:12

问题


As of Apache Camel 2.16.3 in 2015, all of the .beanRef Java DSL routebuilder methods have been deprecated.

Unfortunately, even in 2017 the official Camel documentation still says to use the deprecated .beanRef methods. While the API says to use the .bean(...) methods instead, all of these methods instantiate a new version of the bean or expect an existing one passed in.

My question is, how do I use these methods with the Spring framework to pass in a Spring-managed bean in a Java DSL route and what is the official Camel recommendation?

This similar question was asked in 2015 but the answer is not relevant to my specific question regarding managed beans.


回答1:


Use .bean("beanRef"), because if the parameter of the ProcessorDefinition.bean(Object bean) method is a String than Camel sets the ref to that bean. (Relevant source from Camel)



来源:https://stackoverflow.com/questions/45820387/camel-beanref-deprecated-how-now-to-access-container-managed-beans-in-java-ds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!