01: package org.jbpm.job;
02:
03: import org.apache.commons.logging.Log;
04: import org.apache.commons.logging.LogFactory;
05: import org.jbpm.JbpmContext;
06: import org.jbpm.graph.def.Action;
07: import org.jbpm.graph.def.Node;
08: import org.jbpm.graph.exe.ExecutionContext;
09: import org.jbpm.graph.exe.Token;
10:
11: public class ExecuteActionJob extends Job {
12:
13: private static final long serialVersionUID = 1L;
14:
15: Action action;
16:
17: public ExecuteActionJob() {
18: }
19:
20: public ExecuteActionJob(Token token) {
21: super (token);
22: }
23:
24: public boolean execute(JbpmContext jbpmContext) throws Exception {
25: log.debug("job[" + id + "] executes " + action);
26: ExecutionContext executionContext = new ExecutionContext(token);
27: executionContext.setAction(action);
28: executionContext.setEvent(action.getEvent());
29:
30: Node node = (token != null ? token.getNode() : null);
31: if (node != null) {
32: node.executeAction(action, executionContext);
33: } else {
34: action.execute(executionContext);
35: }
36:
37: jbpmContext.save(token);
38:
39: return true;
40: }
41:
42: public Action getAction() {
43: return action;
44: }
45:
46: public void setAction(Action action) {
47: this .action = action;
48: }
49:
50: private static Log log = LogFactory.getLog(ExecuteActionJob.class);
51: }
|