AnsweredAssumed Answered

Is it safe to keep state in Java delegates?

Question asked by jorell on Sep 26, 2013
Latest reply on Oct 1, 2013 by jorell
I have a use case where I need to reaccess an expression when signaling out of a delegate. Since the signal method does not have the ActivityExecution instance to get the values of an expression, I am thinking of setting the values in a member variable and access it when signaling. Something like:

public class MyTaskDelegate extends BaseTaskDelegate {

  private Logger logger = LoggerFactory.getLogger(SymphonyTaskDelegate.class);
  private Expression inVariables;
  private Expression outVariables;
  private String outVariablesStr;

public void execute(ActivityExecution execution) throws Exception {
  /*Do something*/
  outVariablesStr = outVariables..getValue(execution);
}

public void signal(ActivityExecution execution, String signalName, Object signalData)
      throws Exception {
    /*READ outVariablesStr*/
    if (outVariablesStr != null) {
         /*Do Something*/
    }
    leave(execution);
  }
}

Is this doable? Can I rely on the delegate state being saved, even if say, I restart the activiti server after execute and before signal?

Outcomes