### Eclipse Workspace Patch 1.0
#P jbpm4
Index: modules/test-db/src/test/java/org/jbpm/test/timer/TimerTest.java
===================================================================
--- modules/test-db/src/test/java/org/jbpm/test/timer/TimerTest.java (revision 6372)
+++ modules/test-db/src/test/java/org/jbpm/test/timer/TimerTest.java (working copy)
@@ -22,6 +22,7 @@
package org.jbpm.test.timer;
import java.util.Calendar;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -428,6 +429,97 @@
assertProcessInstanceEnded(processInstance);
}
+
+ public void testTimerRepeat() {
+ deployJpdlXmlString(
+ "" +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ ""
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL", "82436");
+
+ Job job = managementService.createJobQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult();
+
+ managementService.executeJob(job.getId());
+
+
+ job = managementService.createJobQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult();
+
+ managementService.executeJob(job.getId());
+
+ processInstance = executionService.findProcessInstanceById(processInstance.getId());
+ String processInstanceId = processInstance.findActiveExecutionIn("a").getId();
+
+ processInstance = executionService.signalExecutionById(processInstanceId);
+
+ processInstance = executionService.signalExecutionById(processInstance.getId());
+
+ assertProcessInstanceEnded(processInstance);
+ }
+
+ public void testTimerELRepeat() {
+ deployJpdlXmlString(
+ "" +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ " " +
+ ""
+ );
+
+ Map variables = Collections.singletonMap("repeat", "20 seconds");
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL", variables, "82436");
+
+ Job job = managementService.createJobQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult();
+
+ managementService.executeJob(job.getId());
+
+
+ job = managementService.createJobQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult();
+
+ managementService.executeJob(job.getId());
+
+ processInstance = executionService.findProcessInstanceById(processInstance.getId());
+ String processInstanceId = processInstance.findActiveExecutionIn("a").getId();
+
+ processInstance = executionService.signalExecutionById(processInstanceId);
+
+ processInstance = executionService.signalExecutionById(processInstance.getId());
+
+ assertProcessInstanceEnded(processInstance);
+ }
public static class MyCustomWait implements ExternalActivityBehaviour, EventListener {
Index: modules/pvm/src/main/java/org/jbpm/pvm/internal/el/Expression.java
===================================================================
--- modules/pvm/src/main/java/org/jbpm/pvm/internal/el/Expression.java (revision 6447)
+++ modules/pvm/src/main/java/org/jbpm/pvm/internal/el/Expression.java (working copy)
@@ -97,6 +97,10 @@
// runtime evaluation ///////////////////////////////////////////////////////
+ public Object evaluate() {
+ return evaluateInScope(null);
+ }
+
public Object evaluate(Execution execution) {
return evaluateInScope((ScopeInstanceImpl)execution);
}
Index: modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
===================================================================
--- modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java (revision 6435)
+++ modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java (working copy)
@@ -34,6 +34,7 @@
import org.jbpm.api.JbpmException;
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.cal.CronExpression;
+import org.jbpm.pvm.internal.el.Expression;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.history.HistoryEvent;
import org.jbpm.pvm.internal.history.events.VariableCreate;
@@ -318,7 +319,14 @@
if (retries!=null) {
timer.setRetries(retries);
}
- timer.setRepeat(timerDefinition.getRepeat());
+ // support for repeat attribute given as expression
+ // only if repeat is specified
+ if (timerDefinition.getRepeat() != null) {
+ Object repeatEl = Expression.create(timerDefinition.getRepeat(), Expression.LANGUAGE_UEL_VALUE).evaluate();
+ timer.setRepeat(repeatEl.toString());
+ } else {
+ timer.setRepeat(timerDefinition.getRepeat());
+ }
}
return timer;