English 中文(简体)
阿帕奇骆驼POJO豆处理器 单子或原型?
原标题:Apache Camel POJO Bean Processor Singleton or Prototype?

我用骆驼弹簧DSL建造路线 用我的POJO豆子做处理器

一开始,我正在做:

<bean ref="myPojoBeanProcessor"/>

我的PojoBean Processor 在我的春季被定义为豆。

然后,我转向:

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

我想 Java DSL 等同于:

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

我在想,如果采用后一种方法,每个请求都会对一个豆物进行即时处理,还是作为单吨(如春季的缺省)缓存并使用该豆物。

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

最佳回答

为何不试试看:

骆驼将使用默认的无弧构造器一次创建实例, 并缓存实例, 例如其单子范围 。

问题回答

以下是“方法反应”中相关的代码片段#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());
  }
}

骆驼正在捕捉它在田野中产生的情况。





相关问题
Creating JMS Queues at runtime [closed]

I am working on an application where the app user can create / delete queues . Also , he would be able to move a message from 1 queue to another, delete a message , rearrange the messages in the ...

Extending ManagedPerformanceCounter

I have been trying to add my own performance counter, and I m unable to use this performance counter for my routes. Could anyone tell me how to use a custom performance counter instead of ...

Apache Camel with ActiveMQ clustering

I m trying to determine my options for clustering my ServiceMix 3.3.1/Camel 2.1/AMQ 5.3 application. I m performing high volume message processing and I need to cluster for high availability and ...

Using Camel 2.1 with Grails 1.2.1 - Classloading problem

I m trying to define a Camel context in my Grails application. resource.groovy: xmlns camel: http://camel.apache.org/schema/spring camel { camelContext(id: camelContext ) { } } Results ...

Apache camel without maven

I have a hard time finding documentation/tutorials or just getting a dependency overview without going into some spiralling maven-nightmare. I even have trouble getting the examples to work, as its ...

CamelContext.start() doesn t block

I want to run a simple Apache Camel example that copies files from one directory to another: CamelContext context = new DefaultCamelContext(); context.addRoutes(new RouteBuilder() { public void ...

热门标签