Apache Camel POJO Bean Processor Singleton or Prototype?

狂风中的少年 提交于 2019-12-05 17:44:35

Why don't you just try it out :)

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

Here is the relevant piece of code in MethodCallExpression#createExpression(CamelContext):

if (this.beanType != null)
{
  Expression answer;
  if (ObjectHelper.hasDefaultPublicNoArgConstructor(this.beanType)) {
    this.instance = camelContext.getInjector().newInstance(this.beanType);
    answer = new BeanExpression(this.instance, getMethod());
  } else {
    answer = new BeanExpression(this.beanType, getMethod());
  }
}

Camel is caching the instance it creates in a field.

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