View Javadoc
1 package org.smartcomps.twister.engine.priv.timer; 2 3 import org.smartcomps.twister.common.transaction.TransactionManager; 4 import org.smartcomps.twister.common.transaction.TransactionException; 5 import org.smartcomps.twister.common.persistence.DBSessionException; 6 import org.smartcomps.twister.common.util.logger.Logger; 7 import org.smartcomps.twister.common.event.EventManager; 8 import org.smartcomps.twister.engine.priv.core.dynamic.ExecutionContextFactory; 9 import org.smartcomps.twister.engine.priv.core.dynamic.PickEC; 10 import org.smartcomps.twister.common.persistence.FinderException; 11 12 import java.util.TimerTask; 13 14 /*** 15 * Callback for alarm events of pick execution contexts. 16 * @see EngineTimer 17 * @see org.smartcomps.twister.engine.priv.core.dynamic.PickEC 18 */ 19 public class PickECTask extends ExecutionContextTask { 20 21 private Logger log = Logger.getLogger(PickECTask.class); 22 23 public Long pickECId; 24 private int activityPos; 25 26 public PickECTask(Long pickECId, int activityPos) { 27 this.pickECId = pickECId; 28 this.activityPos = activityPos; 29 if (log.isDebugEnabled()) { 30 log.debug("Registering a pick alarm for PickEC " + pickECId + " and activity pos " + activityPos); 31 } 32 } 33 34 public Long getContextId() { 35 return pickECId; 36 } 37 38 public void run() { 39 PickEC pickEC = null; 40 try { 41 TransactionManager.beginTransaction(); 42 pickEC = (PickEC) ExecutionContextFactory.findECById(pickECId); 43 pickEC.notifyAlarm(activityPos); 44 TransactionManager.commitTransaction(); 45 } catch (DBSessionException e) { 46 EventManager.fireError(e); 47 log.error("A database error occured when initializing a connection for querying an execution context.", e); 48 } catch (TransactionException e) { 49 EventManager.fireError(e); 50 log.error("A database error occured when executing a finder on execution context.", e); 51 } catch (FinderException e) { 52 EventManager.fireError(e); 53 log.error("The pickEC that should have been notified for a due date that has been reached could not be " + 54 "found, please check for the Pick Execution Context with id " + pickECId, e); 55 } 56 } 57 58 public String getAdditionalInfo() { 59 return Integer.toString(activityPos); 60 } 61 }

This page was automatically generated by Maven