[英]Mule Java Component and Thread Safe
An excerpt from this http://www.mulesoft.org/documentation/display/current/Configuring+Java+Components is: 此http://www.mulesoft.org/documentation/display/current/Configuring+Java+Components的摘录为:
When you specify the class directly on the component or pooled-component element, the PrototypeObjectFactory is used by default, and a new instance is created for each invocation, or a new pooled component is created in the case of the PooledJavaComponent
And, I have configured a Java class as Mule Java component like below: 而且,我已经将Java类配置为Mule Java组件,如下所示:
<component class="com.mycompany.SalesOrderProductsHandler" doc:name="Java" />
. <component class="com.mycompany.SalesOrderProductsHandler" doc:name="Java" />
。 The class SalesOrderProductsHandler
has implemented org.mule.api.lifecycle.Callable
and has one state variable named targetProductsIndex . SalesOrderProductsHandler
类已实现org.mule.api.lifecycle.Callable
并具有一个名为targetProductsIndex的状态变量。
My question follows: 我的问题如下:
Will a new instance of com.mycompany.SalesOrderProductsHandler
get created every time a new request comes? 每次收到新请求时,都会创建
com.mycompany.SalesOrderProductsHandler
的新实例吗?
The documentation is absolutely correct. 该文档是绝对正确的。 With:
附:
<component class="com.mycompany.SalesOrderProductsHandler" />
you will get a new instance of com.mycompany.SalesOrderProductsHandler
for each invocation. 您将为每次调用获得
com.mycompany.SalesOrderProductsHandler
的新实例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.