1 package org.smartcomps.twister.engine.priv.timer;
2
3 import org.smartcomps.twister.engine.priv.core.dynamic.ExecutionContextFactory;
4 import org.smartcomps.twister.engine.priv.core.dynamic.WaitEC;
5
6 import org.smartcomps.twister.common.persistence.FinderException;
7
8 import org.smartcomps.twister.common.persistence.DBSessionException;
9 import org.smartcomps.twister.common.transaction.TransactionManager;
10 import org.smartcomps.twister.common.transaction.TransactionException;
11
12 import org.apache.commons.logging.Log;
13 import org.apache.commons.logging.LogFactory;
14
15 import java.util.TimerTask;
16
17 /***
18 * Task that notifies a WaitEC that its due date has been reached.
19 */
20 public class WaitECTask extends ExecutionContextTask {
21
22 private Log log = LogFactory.getLog(WaitECTask.class);
23
24 private Long waitECId;
25
26 public WaitECTask(Long executionContextId) {
27 this.waitECId = executionContextId;
28 }
29
30 public Long getContextId() {
31 return waitECId;
32 }
33
34 public void run() {
35 WaitEC waitEC = null;
36 try {
37 TransactionManager.beginTransaction();
38 waitEC = (WaitEC) ExecutionContextFactory.findECById(waitECId);
39 waitEC.dueDateReached();
40 TransactionManager.commitTransaction();
41 } catch (DBSessionException e) {
42 log.error("A database error occured when initializing a connection for querying an execution context.", e);
43 } catch (TransactionException e) {
44 log.error("A database error occured when executing a finder on execution context.", e);
45 } catch (FinderException e) {
46 log.error("The waitEC that should have been notified for a due date that has been reached could not be " +
47 "found, please check for the Wait Execution Context with id " + waitECId, e);
48 }
49 }
50
51 public String getAdditionalInfo() {
52 return null;
53 }
54 }
This page was automatically generated by Maven