01: package org.jbpm.ejb.impl;
02:
03: import org.apache.commons.logging.Log;
04: import org.apache.commons.logging.LogFactory;
05: import org.jbpm.JbpmContext;
06: import org.jbpm.command.Command;
07: import org.jbpm.db.JobSession;
08: import org.jbpm.job.Job;
09:
10: public class ExecuteJobCommand implements Command {
11:
12: private static final long serialVersionUID = 1L;
13:
14: long jobId;
15:
16: public ExecuteJobCommand(long jobId) {
17: this .jobId = jobId;
18: }
19:
20: public Object execute(JbpmContext jbpmContext) throws Exception {
21: JobSession jobSession = jbpmContext.getJobSession();
22: log.debug("loading job " + jobId);
23: Job job = jobSession.loadJob(jobId);
24: log.debug("executing job " + jobId);
25: if (!job.execute(jbpmContext)) {
26: log
27: .warn("job " + jobId
28: + " was not supposed to be deleted");
29: }
30: jobSession.deleteJob(job);
31: return null;
32: }
33:
34: private static Log log = LogFactory.getLog(ExecuteJobCommand.class);
35: }
|