cancel
Showing results for 
Search instead for 
Did you mean: 

JavaDelegate - New instance per call?

kaech
Champ in-the-making
Champ in-the-making
Are the JavaDelegates and ActivityBehaviors reused or is a new instance created for each call?
It might happen that they are called from different job executor threads. Are they thread safe?
Is there anything to keep in mind especially when working with ActivityExecution inside of ann Activity Behavior?

Thank you in advance
2 REPLIES 2

roig
Champ in-the-making
Champ in-the-making
AFAIK these delegate classes are not thread safe. They are instantiated only once, and then used with no thread safe mechanism (this is up to the class implementation)

meyerd
Champ on-the-rise
Champ on-the-rise
Hi roig

JavaDelegate and ActivityBehavior instances are static by design. They are not threadsafe.

C.f: user manual: http://activiti.org/userguide/index.html#bpmnJavaServiceTask
Note: there will be only one instance of that Java class created for the serviceTask it is defined on. All process-instances share the same class instance that will be used to call execute(DelegateExecution). This means that the class must not use any member variables and must be thread-safe, since it can be executed simultaneously from different threads. This also influences the way Field injection is handled.