Camel .beanRef 已弃用 - 现在如何在 Java DSL 路由中访问容器管理的 bean? [英] Camel .beanRef deprecated - how now to access container-managed beans in Java DSL route?

查看:23
本文介绍了Camel .beanRef 已弃用 - 现在如何在 Java DSL 路由中访问容器管理的 bean?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从 2015 年的 Apache Camel 2.16.3 开始,所有 .beanRef Java DSL 路由构建器方法 已弃用.

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

不幸的是,即使在 2017 年 官方 Camel 文档 仍然说要使用不推荐使用的 .beanRef 方法.虽然 API 说要使用 .bean(...) 方法,但所有这些方法都会实例化一个新版本的 bean 或期望传入一个现有版本.

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.

我的问题是,如何在 Spring 框架中使用这些方法在 Java DSL 路由中传入 Spring 管理的 bean,Camel 的官方推荐是什么?

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?

这个类似的问题是在 2015 年提出的但答案与我关于托管 bean 的具体问题无关.

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

推荐答案

使用.bean("beanRef"),因为如果ProcessorDefinition.bean(Object bean)的参数 方法是一个字符串,而不是 Camel 将 ref 设置为该 bean.(来自Camel的相关来源)

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)

这篇关于Camel .beanRef 已弃用 - 现在如何在 Java DSL 路由中访问容器管理的 bean?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆