cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to define a variable in a bpmn20.xml file?

ilgrosso
Champ in-the-making
Champ in-the-making
Hi,
I need to parametrize a UserTask (i.e. a Java class implementing JavaDelegate): thus, I would be able to define a variable in the process definition XML file, so that I can then get it from Java code.

Is that possible? Is there any workaround about this?

Thanks for your support.
2 REPLIES 2

bardioc
Champ in-the-making
Champ in-the-making
Hi,
I need to parametrize a UserTask (i.e. a Java class implementing JavaDelegate): thus, I would be able to define a variable in the process definition XML file, so that I can then get it from Java code.

Is that possible? Is there any workaround about this?

Thanks for your support.

Hello,

I'm a bit confused, as you speek about a UserTask and refer to a JavaDelegate too. IMHO, a user task does not have a java delegate - only service tasks do. If you are speaking about service tasks, check out the manual about field injection. It allows you to inject static fields, as well as expressions into tasks. Keep in mind, that the injection into your java delegate object only occurs at its first creation. Subsequent calls to your java delegate will use the injected value. The corresponding chapter in the manual is http://www.activiti.org/userguide/index.html#serviceTaskFieldInjection

For user tasks, there is no such field injection possible I think.

Best regards,

Heiko

ilgrosso
Champ in-the-making
Champ in-the-making
Thanks for explanation, you are completely right about injection.

For my purpose I could just use a groovy ScriptTask doing something like execution.setVariable("myVar", scriptVar) then fetching myVar in JavaDelegate's execute() via execution.getVariable().