简体   繁体   English

不推荐使用Camel .beanRef-现在如何在Java DSL路由中访问容器管理的bean?

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

As of Apache Camel 2.16.3 in 2015, all of the .beanRef Java DSL routebuilder methods have been deprecated . 从2015年的Apache Camel 2.16.3开始,所有.beanRef Java DSL routebuilder方法均已弃用

Unfortunately, even in 2017 the official Camel documentation still says to use the deprecated .beanRef methods. 不幸的是,即使在2017年,官方的Camel文档仍然说要使用不推荐使用的.beanRef方法。 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. 尽管API表示改为使用.bean(...)方法,但所有这些方法都实例化了bean的新版本,或者期望传入一个现有版本。

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? 我的问题是,如何将这些方法与Spring框架一起使用,以通过Java DSL路由传入Spring管理的bean,Camel的官方建议是什么?

This similar question was asked in 2015 but the answer is not relevant to my specific question regarding managed beans. 在2015年提出了类似的问题 ,但答案与我关于托管bean的特定问题无关。

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. 使用.bean("beanRef") ,因为如果ProcessorDefinition.bean(Object bean)方法的参数是String,则Camel .bean("beanRef")引用设置为该bean。 ( Relevant source from Camel ) 骆驼的相关资料

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM