1 package org.smartcomps.twister.engine.priv.core.dynamic.impl;
2
3 import org.smartcomps.twister.engine.priv.core.dynamic.ReceiveEC;
4 import org.smartcomps.twister.engine.priv.core.dynamic.impl.xao.VariableXAO;
5 import org.smartcomps.twister.engine.priv.core.definition.Receive;
6 import org.smartcomps.twister.engine.exception.ExecutionException;
7 import org.smartcomps.twister.common.persistence.XMLSessionException;
8 import org.dom4j.Element;
9 import org.dom4j.Document;
10
11 /***
12 * Execution context of a Receive activity.
13 */
14 public class ReceiveECImpl extends BasicECImpl implements ReceiveEC {
15
16 public void execute() {
17 this.setStatus(ACTIVE);
18
19 // Notify the container for execution
20 notifyExecutionToContainer();
21 }
22
23 public void acknowledgeMessage(Document message) {
24 if (getStatus() == ACTIVE) {
25 String variableToSet = ((Receive)getInitialActivity()).getVariable();
26 if (variableToSet != null && message != null) {
27 ProcessInstanceImpl thisInstance = (ProcessInstanceImpl) fetchInstance();
28 try {
29 VariableXAO.createVariable(thisInstance.getProcess().getName(), variableToSet
30 , thisInstance.getId(), message);
31 } catch (XMLSessionException e) {
32 throw new ExecutionException("Could not set a variable in XML database " +
33 variableToSet, e);
34 }
35 }
36 notifyTerminationToContainer();
37 this.setStatus(COMPLETED);
38 } else {
39 throw new ExecutionException("This receive execution context is at status " + getStatus() +
40 " it can't acknowledge the message " + message.asXML());
41 }
42 }
43
44 }
This page was automatically generated by Maven