cancel
Showing results for 
Search instead for 
Did you mean: 

Script Task objects

george_d
Champ in-the-making
Champ in-the-making
I use Script Task with default Java Script engine. How can I add my own class object to every process instance?
5 REPLIES 5

jbarrez
Star Contributor
Star Contributor
What do you mean with 'own class object' ?

A variables? Some code you like to call in the script? or … ?

george_d
Champ in-the-making
Champ in-the-making
No.
I can add class instance to activiti engine, like this:

Map<Object, Object> globalObjects = new HashMap<Object, Object>();
globalObjects.put("myObject", new MyClass());
((ProcessEngineConfigurationImpl) processEngineConfiguration).setBeans(globalObjects);

But, I want to create new class instance for each process instance. Is this possible?

p.s. the object will only be used from script task.

trademak
Star Contributor
Star Contributor
When you start a process instance you can pass a Map of variables to it. So just add your bean there and you have a unique bean instance per process instance that you can use in a script task or any other place where you can use expressions.

Best regards,

george_d
Champ in-the-making
Champ in-the-making
I can add only 'serializable' object to process instance from map of variables. It doesn't suit me.

esseti
Champ in-the-making
Champ in-the-making
serialize and deserialize your class to json then. it should work.