View Javadoc
1 package org.smartcomps.twister.engine.priv.core.dynamic.impl; 2 3 import org.smartcomps.twister.engine.priv.core.dynamic.WaitEC; 4 import org.smartcomps.twister.engine.priv.core.definition.Wait; 5 import org.smartcomps.twister.engine.priv.timer.WaitECTask; 6 import org.smartcomps.twister.engine.priv.timer.EngineTimer; 7 import org.smartcomps.twister.engine.priv.expression.ExpressionProcessorFactory; 8 import org.smartcomps.twister.engine.exception.ProcessStructuralException; 9 import org.smartcomps.twister.engine.exception.EngineRuntimeException; 10 import org.smartcomps.twister.engine.exception.ExecutionException; 11 import org.smartcomps.twister.engine.exception.XPathEvaluationException; 12 import org.smartcomps.twister.common.util.DurationUtil; 13 import org.relaxng.datatype.DatatypeException; 14 15 import java.util.Date; 16 import java.util.Calendar; 17 18 import com.sun.msv.datatype.xsd.XSDatatype; 19 import com.sun.msv.datatype.xsd.DatatypeFactory; 20 import com.sun.msv.datatype.xsd.datetime.BigTimeDurationValueType; 21 22 /*** 23 * Persistent implementation of the WaitEC interface. 24 */ 25 public class WaitECImpl extends BasicECImpl implements WaitEC { 26 27 private Date dueDate; 28 29 public Date getDueDate() { 30 return dueDate; 31 } 32 33 public void setDueDate(Date dueDate) { 34 this.dueDate = dueDate; 35 } 36 37 public void execute() { 38 // Calculate the due date 39 Wait initialWait = (Wait)getInitialActivity(); 40 Date expiration = null; 41 if (initialWait.isDuration()) { 42 try { 43 expiration = ExpressionProcessorFactory.getBPELExpressionProcessor().evaluateDurationAsDate( 44 fetchInstance(), initialWait.getTime()); 45 } catch (XPathEvaluationException e) { 46 throw new ExecutionException(e); 47 } 48 } else { 49 try { 50 expiration = ExpressionProcessorFactory.getBPELExpressionProcessor().evaluateAsDate( 51 fetchInstance(), initialWait.getTime()); 52 } catch (XPathEvaluationException e) { 53 throw new ExecutionException(e); 54 } 55 } 56 this.setDueDate(expiration); 57 58 // Asks for notification when time is reached 59 WaitECTask callingTask = new WaitECTask(this.getId()); 60 EngineTimer.schedule(callingTask, this.getDueDate()); 61 62 // Notify the container for execution 63 notifyExecutionToContainer(); 64 65 // Update status 66 this.setStatus(ACTIVE); 67 } 68 69 public void dueDateReached() { 70 // Notify container 71 notifyTerminationToContainer(); 72 73 // Terminate this activity 74 this.setStatus(COMPLETED); 75 } 76 }

This page was automatically generated by Maven