Apache Camel POJO Bean处理器是Singleton还是Prototype? [英] Apache Camel POJO Bean Processor Singleton or 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).
我无法在骆驼文档或Google中找到答案.有人知道这个问题的答案吗?
I was unable to find an answer in the camel documentation or on google. Does anyone know the answer to this question?
推荐答案
为什么不尝试一下:)
Camel将使用默认的no-arg构造函数一次创建一个实例,并缓存该实例,例如其单例作用域.
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处理器是Singleton还是Prototype?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!