Apache Camel POJO Bean Processor Singleton 还是 Prototype? [英] Apache Camel POJO Bean Processor Singleton or Prototype?

查看:29
本文介绍了Apache Camel POJO Bean Processor Singleton 还是 Prototype?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Camel 的 spring DSL 来构建路由,我使用我的 POJO bean 作为处理器.

I'm using Camel's spring DSL to build routes and I'm using my POJO bean as a processor.

最初,我这样做:

<bean ref="myPojoBeanProcessor"/>

其中,myPojoBeanProcessor"在我的 spring 上下文中被定义为一个 bean.

where, 'myPojoBeanProcessor' was defined as a bean in my spring context.

然后,我切换到:

<bean beanType="com.mycompany.transformation.MyPojoBeanProcessor"/>

Java DSL 等价物,我认为:

The Java DSL equivalent would be, I think:

from("xxx").bean(MyPojoBeanProcessor.class).xxx

我想知道使用后一种方法,是否会在每个请求中实例化 bean 对象,或者是否会缓存 bean 实例并将其用作单例(如 spring 中的默认设置).

I'm wondering if with the later approach, a bean object would be instantiated with every request or would the bean instance be cached and used as a singleton (like the default in spring).

我无法在骆驼文档或谷歌上找到答案.有人知道这个问题的答案吗?

I was unable to find an answer in the camel documentation or on google. Does anyone know the answer to this question?

推荐答案

为什么不试试看 :)

Camel 将使用默认的无参数构造函数一次创建一个实例,并缓存该实例,例如它的单例范围.

Camel will create an instance one time using the default no-arg constructor, and cache the instance, eg its singleton scoped.

这篇关于Apache Camel POJO Bean Processor Singleton 还是 Prototype?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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