cancel
Showing results for 
Search instead for 
Did you mean: 

Force serialization after a Script Task

mathiasd
Champ in-the-making
Champ in-the-making
Hi,
I would like to manipulate some objects (Java Objects) in script task. For example :


<scriptTask id="scripttask1" name="Setter" scriptFormat="javascript">
      <script><![CDATA[
               object1.setValue(1);
          ]]></script>
    </scriptTask>

The java code which starts a process instance is :

Map<String, Object> variables = new HashMap<String, Object>();
variables.put("object1", new MyObject());
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(name,businessKey,variables);

The problem is that the engine doesn't serialize object1 at the end of the script task, because the engine doesn't know that the object1 has changed. I would like to know if there is a way to notify the engine "object1 has changed !" ?

The solution I found is to change the set method in order to return the object. So the script is :


<scriptTask id="scripttask1" name="Setter" scriptFormat="javascript">
      <script><![CDATA[
               object1 = object1.setValue(1);
          ]]></script>
    </scriptTask>

Is there another solution ?
Actually the list of manipulated objects is well-known, so a "hard-coded" solution like "save the object1 after each script task" would be good enough.
1 REPLY 1

mathiasd
Champ in-the-making
Champ in-the-making
I'm sorry, the problem is already known as bug :

http://jira.codehaus.org/browse/ACT-820