JBoss JBPM SVN: r1735 - in jbpm4/pvm/trunk/modules/core/src: main/java/org/jbpm/pvm/internal/jobexecutor and 6 other directories.
by do-not-reply@jboss.org
Author: pascal.verdage
Date: 2008-07-28 07:11:28 -0400 (Mon, 28 Jul 2008)
New Revision: 1735
Added:
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TimerTest.java
Removed:
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TestTimerSession.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TestTimerSessionBinding.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TimerConfiguration.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TimerIntegrationTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TimerUnitTest.java
Modified:
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobTestTimerSession.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/TimerDefinitionImpl.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/ProcessFactory.java
jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.definition.hbm.xml
jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.job.hbm.xml
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/DbTests.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/pvm.wire.bindings.xml
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/IncrementCounterWaitState.java
jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/timer/environment.cfg.xml
Log:
use scripting expressions to define timers
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java 2008-07-27 08:13:58 UTC (rev 1734)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java 2008-07-28 11:11:28 UTC (rev 1735)
@@ -21,6 +21,7 @@
*/
package org.jbpm.pvm.internal.job;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -33,6 +34,7 @@
import org.jbpm.pvm.internal.jobexecutor.JobAddedNotification;
import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
import org.jbpm.pvm.internal.log.Log;
+import org.jbpm.pvm.internal.script.ScriptManager;
import org.jbpm.pvm.internal.util.Clock;
import org.jbpm.pvm.job.Timer;
import org.jbpm.pvm.model.ObservableElement;
@@ -53,45 +55,115 @@
private static final long serialVersionUID = 1L;
private static final Log log = Log.getLog(TimerImpl.class.getName());
- private final static String dateFormat = "yyyy-MM-dd HH:mm:ss,SSS";
+ private static String dateFormat = "yyyy-MM-dd HH:mm:ss,SSS";
protected String signalName;
protected String eventName;
protected String repeat;
+ protected String language;
public static final String EVENT_TIMER = "timer";
public TimerImpl() {
}
- public void setDueDateDescription(String dueDateDescription) {
- Duration duration = new Duration(dueDateDescription);
+ private static Date getDateFromDuration(String expression) {
+ Duration duration = new Duration(expression);
Date now = Clock.getCurrentTime();
-
+ Date result = null;
+
if ( duration.isBusinessTime()
- || duration.getMonths()>0
- || duration.getYears()>0
- ) {
+ || duration.getMonths()>0
+ || duration.getYears()>0
+ ) {
Environment environment = Environment.getCurrent();
if (environment==null) {
- throw new PvmException("no environment to get business calendar for calculating dueDate "+dueDateDescription);
+ log.debug("no environment to get business calendar for calculating dueDate "+expression);
+ } else {
+ BusinessCalendar businessCalendar = environment.get(BusinessCalendar.class);
+ if (businessCalendar==null) {
+ log.debug("no business calendar to calculate dueDate "+expression);
+ } else {
+ result = businessCalendar.add(now, duration);
+ }
}
- BusinessCalendar businessCalendar = environment.get(BusinessCalendar.class);
- dueDate = businessCalendar.add(now, duration);
-
} else {
long millis = duration.getMillis() +
- 1000*( duration.getSeconds() +
- 60*( duration.getMinutes() +
- 60*( duration.getHours() +
- 24*( duration.getDays() +
- 7*duration.getWeeks()))));
- dueDate = new Date(now.getTime() + millis);
+ 1000*( duration.getSeconds() +
+ 60*( duration.getMinutes() +
+ 60*( duration.getHours() +
+ 24*( duration.getDays() +
+ 7*duration.getWeeks()))));
+ result = new Date(now.getTime() + millis);
}
+ return result;
}
+ private Object evaluateExpression(String expression) {
+ Object result = null;
+ Environment environment = Environment.getCurrent();
+ if (environment==null) {
+ log.debug("no environment to get script manager to evaluate "+expression);
+ } else {
+ ScriptManager scriptManager = environment.getEnvironmentFactory().get(ScriptManager.class);
+ if (scriptManager==null) {
+ log.debug("no script manager to evaluate "+expression);
+ } else {
+ log.debug("evaluates "+expression);
+ result = scriptManager.evaluateExpression(expression, execution, language);
+ }
+ }
+ return result;
+ }
+
+ public void setDueDateDescription(String expression) {
+ Exception exception = null;
+ Object dueDateDescription = evaluateExpression(expression);
+
+ // now we analyse the description
+ Date date = null;
+ // date?
+ if (dueDateDescription instanceof Date) {
+ date = (Date)dueDateDescription;
+ } else if (dueDateDescription instanceof String) {
+ // formatted date?
+ try {
+ date = new SimpleDateFormat(dateFormat).parse((String) dueDateDescription);
+ } catch (ParseException e) {
+ // not a formatted date
+ exception = e;
+ }
+
+ // duration?
+ try {
+ date = getDateFromDuration((String) dueDateDescription);
+ } catch (PvmException e) {
+ // not a duration
+ exception = e;
+ }
+ } else {
+ throw new PvmException("invalid timer's dueDateDescription");
+ }
+
+ if (date!=null) {
+ setDueDate(date);
+ } else {
+ throw new PvmException("Unable to set dueDate from " + expression+". " +
+ "This might be a environment configuration error", exception);
+ }
+ }
+
+ private void repeatTimer(String repeat) {
+ Object description = evaluateExpression(repeat);
+ if (description instanceof String && description!=null) {
+ setDueDate(getDateFromDuration((String)description));
+ } else {
+ throw new PvmException("invalid timer's repeat: "+repeat);
+ }
+ }
+
public Boolean execute(Environment environment) throws Exception {
- if (log.isDebugEnabled()) log.debug("executing " + this);
+ log.debug("executing " + this);
if (environment==null) {
throw new PvmException("environment is null");
@@ -101,13 +173,13 @@
environment.addContext(jobContext);
try {
if (signalName!=null) {
- if (log.isDebugEnabled()) log.debug("feeding timer signal "+signalName+" into "+execution);
+ log.debug("feeding timer signal "+signalName+" into "+execution);
execution.signal(signalName);
}
if (eventName!=null) {
ObservableElement eventSource = execution.getNode();
- if (log.isDebugEnabled()) log.debug("firing event "+signalName+" into "+eventSource);
+ log.debug("firing event "+signalName+" into "+eventSource);
execution.fire(eventName, eventSource);
}
@@ -119,7 +191,7 @@
// if there is no repeat on this timer
if (repeat==null) {
// delete the jobImpl
- if (log.isDebugEnabled()) log.debug("deleting " + this);
+ log.debug("deleting " + this);
DbSession dbSession = environment.get(DbSession.class);
if (dbSession==null) {
throw new PvmException("no "+DbSession.class.getName()+" in environment");
@@ -131,10 +203,10 @@
// suppose that it took the timer runner thread a very long time to execute the timers
// then the repeat action dueDate could already have passed
do {
- setDueDateDescription(repeat);
+ repeatTimer(repeat);
} while (dueDate.getTime() <= Clock.getCurrentTime().getTime());
- if (log.isDebugEnabled()) log.debug("rescheduled "+this+" for "+formatDueDate(dueDate));
+ log.debug("rescheduled "+this+" for "+formatDueDate(dueDate));
// release the lock on the timer
setLockOwner(null);
@@ -178,6 +250,9 @@
public static String formatDueDate(Date date) {
return new SimpleDateFormat(dateFormat).format(date);
}
+ public static void setDateFormat(String dateFormat) {
+ TimerImpl.dateFormat = dateFormat;
+ }
public String getSignalName() {
return signalName;
@@ -197,4 +272,14 @@
public void setRepeat(String repeat) {
this.repeat = repeat;
}
+
+
+ public String getLanguage() {
+ return language;
+ }
+
+
+ public void setLanguage(String language) {
+ this.language = language;
+ }
}
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobTestTimerSession.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobTestTimerSession.java 2008-07-27 08:13:58 UTC (rev 1734)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobTestTimerSession.java 2008-07-28 11:11:28 UTC (rev 1735)
@@ -28,6 +28,7 @@
/**
* @author Tom Baeyens
+ * @author Pascal Verdage
*/
public class JobTestTimerSession implements TimerSession {
@@ -35,11 +36,15 @@
Session session;
public void schedule(Timer timer) {
- session.save(timer);
+ if (session!=null) {
+ session.save(timer);
+ }
}
public void cancel(Timer timer) {
- session.delete(timer);
+ if (session!=null) {
+ session.delete(timer);
+ }
}
}
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2008-07-27 08:13:58 UTC (rev 1734)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2008-07-28 11:11:28 UTC (rev 1735)
@@ -25,7 +25,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
@@ -76,6 +75,7 @@
/**
* @author Tom Baeyens
+ * @author Pascal Verdage
*/
public class ExecutionImpl implements ClientProcessInstance,
ActivityExecution,
@@ -792,8 +792,8 @@
createTimer(
timerDefinition.getEventName(),
timerDefinition.getSignalName(),
- timerDefinition.getDueDateDescription(),
- timerDefinition.getDueDate(),
+ timerDefinition.getExpression(),
+ timerDefinition.getLanguage(),
timerDefinition.getRepeat(),
timerDefinition.isExclusive(),
timerDefinition.getRetries()
@@ -822,15 +822,16 @@
}
}
- public void createTimer(String eventName, String signalName, String dueDateDescription) {
- createTimer(eventName, signalName, dueDateDescription, null, null, null, null);
+ public void createTimer(String eventName, String signalName, String expression) {
+ createTimer(eventName, signalName, expression, null, null, null, null);
}
- public void createTimer(String eventName, String signalName, String dueDateDescription, String repeat) {
- createTimer(eventName, signalName, dueDateDescription, null, repeat, null, null);
+ public void createTimer(String eventName, String signalName, String expression, String repeat) {
+ createTimer(eventName, signalName, expression, null, repeat, null, null);
}
- public void createTimer(String eventName, String signalName, String dueDateDescription, Date dueDate, String repeat, Boolean isExclusive, Integer retries) {
+ public void createTimer(String eventName, String signalName, String expression,
+ String language, String repeat, Boolean isExclusive, Integer retries) {
if ( (eventName==null)
&& (signalName==null)
) {
@@ -846,16 +847,17 @@
timerImpl.setExecution(this);
timers.add(timerImpl);
hasTimers = true;
- // setInverseReference(timerImpl);
- // initialise all the timer properties
+ // initialize all the timer properties
timerImpl.setEventName(eventName);
timerImpl.setSignalName(signalName);
- if (dueDate!=null) {
- timerImpl.setDueDate(dueDate);
- } else {
- timerImpl.setDueDateDescription(dueDateDescription);
+
+ // the if is added to keep the original default
+ if (language!=null) {
+ timerImpl.setLanguage(language);
}
+ // language has to be set before expression
+ timerImpl.setDueDateDescription(expression);
// the if is added to keep the original default
if (isExclusive!=null) {
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/TimerDefinitionImpl.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/TimerDefinitionImpl.java 2008-07-27 08:13:58 UTC (rev 1734)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/internal/model/TimerDefinitionImpl.java 2008-07-28 11:11:28 UTC (rev 1735)
@@ -22,7 +22,6 @@
package org.jbpm.pvm.internal.model;
import java.io.Serializable;
-import java.util.Date;
/**
@@ -35,13 +34,13 @@
protected long dbid;
protected int dbversion;
- protected String dueDateDescription;
+ protected String expression;
+ protected String language;
protected String repeat;
protected Boolean isExclusive;
protected Integer retries;
protected String eventName;
protected String signalName;
- protected Date dueDate;
public TimerDefinitionImpl() {
}
@@ -55,12 +54,6 @@
public long getDbid() {
return dbid;
}
- public String getDueDateDescription() {
- return dueDateDescription;
- }
- public void setDueDateDescription(String dueDateDescription) {
- this.dueDateDescription = dueDateDescription;
- }
public Boolean isExclusive() {
return isExclusive;
}
@@ -85,10 +78,20 @@
public void setEventName(String eventName) {
this.eventName = eventName;
}
- public Date getDueDate() {
- return dueDate;
+
+ public String getExpression() {
+ return expression;
}
- public void setDueDate(Date dueDate) {
- this.dueDate = dueDate;
+
+ public void setExpression(String expression) {
+ this.expression = expression;
}
+
+ public String getLanguage() {
+ return language;
+ }
+
+ public void setLanguage(String language) {
+ this.language = language;
+ }
}
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/ProcessFactory.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/ProcessFactory.java 2008-07-27 08:13:58 UTC (rev 1734)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/model/ProcessFactory.java 2008-07-28 11:11:28 UTC (rev 1735)
@@ -22,7 +22,6 @@
package org.jbpm.pvm.model;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import java.util.Stack;
@@ -192,34 +191,26 @@
}
/** declares a timer on the current node or process. {@link #scope()} is
- * automatically implied. */
- public ProcessFactory timer(String dueDateDescription, String signalName) {
- return timer(dueDateDescription, null, signalName, null);
+ * automatically implied.
+ * @param expression can be a formatted date or duration
+ * or an expression in the default expression language if defined */
+ public ProcessFactory timer(String expression, String signalName) {
+ return timer(expression, null, signalName, null);
}
/** declares a timer on the current node or process. {@link #scope()} is
- * automatically implied. */
- public ProcessFactory timer(String dueDateDescription, String signalName, String repeat) {
- return timer(dueDateDescription, null, signalName, repeat);
- }
-
- /** declares a timer on the current node or process. {@link #scope()} is
- * automatically implied. */
- public ProcessFactory timer(Date dueDate, String signalName) {
- return timer(null, dueDate, signalName, null);
- }
-
- protected ProcessFactory timer(String dueDateDescription, Date dueDate,
- String signalName, String repeat) {
+ * automatically implied.
+ * @param expression can be a formatted date or duration
+ * or an expression in the given language.
+ * @param language is a supposed known language (environment configuration) */
+ public ProcessFactory timer(String expression, String language,
+ String signalName, String repeat) {
if (node!=null && scope==null) {
scope();
}
TimerDefinitionImpl timerDefinition = scope.createTimerDefinition();
- if (dueDate!=null) {
- timerDefinition.setDueDate(dueDate);
- } else {
- timerDefinition.setDueDateDescription(dueDateDescription);
- }
+ timerDefinition.setExpression(expression);
+ timerDefinition.setLanguage(language);
timerDefinition.setSignalName(signalName);
timerDefinition.setRepeat(repeat);
return this;
Modified: jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.definition.hbm.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.definition.hbm.xml 2008-07-27 08:13:58 UTC (rev 1734)
+++ jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.definition.hbm.xml 2008-07-28 11:11:28 UTC (rev 1735)
@@ -378,13 +378,13 @@
<generator class="native" />
</id>
<version name="dbversion" column="DBVERSION_" />
- <property name="dueDateDescription" column="DUEDATEDESCR_"/>
+ <property name="expression" column="EXPRESSION_"/>
+ <property name="language" column="LANGUAGE_"/>
<property name="repeat" column="REPEAT_"/>
<property name="isExclusive" column="ISEXCL_"/>
<property name="retries" column="RETRIES_"/>
<property name="eventName" column="EVENT_"/>
<property name="signalName" column="SIGNAL_"/>
- <property name="dueDate" column="DUEDATE_" type="timestamp"/>
</class>
<!-- ### QUERIES ######################################################## -->
Modified: jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.job.hbm.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.job.hbm.xml 2008-07-27 08:13:58 UTC (rev 1734)
+++ jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/hibernate.job.hbm.xml 2008-07-28 11:11:28 UTC (rev 1735)
@@ -49,6 +49,7 @@
<property name="signalName" column="SIGNAL_" />
<property name="eventName" column="EVENT_" />
<property name="repeat" column="REPEAT_" />
+ <property name="language" column="LANGUAGE_" />
</subclass>
</class>
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/DbTests.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/DbTests.java 2008-07-27 08:13:58 UTC (rev 1734)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/DbTests.java 2008-07-28 11:11:28 UTC (rev 1735)
@@ -28,6 +28,7 @@
import org.jbpm.pvm.db.model.DbModelTests;
import org.jbpm.pvm.db.svc.DbSvcTests;
import org.jbpm.pvm.jobexecutor.JobExecutorTests;
+import org.jbpm.pvm.timer.DbTimerTests;
/**
@@ -43,7 +44,8 @@
suite.addTest(DbModelTests.suite());
suite.addTest(DbSvcTests.suite());
suite.addTest(JobExecutorTests.suite());
-
+ suite.addTest(DbTimerTests.suite());
+
//$JUnit-END$
return suite;
}
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/pvm.wire.bindings.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/pvm.wire.bindings.xml 2008-07-27 08:13:58 UTC (rev 1734)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/pvm.wire.bindings.xml 2008-07-28 11:11:28 UTC (rev 1735)
@@ -1,5 +1,2 @@
<wire-bindings>
-
- <binding class="org.jbpm.pvm.timer.TestTimerSessionBinding" />
-
</wire-bindings>
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/IncrementCounterWaitState.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/IncrementCounterWaitState.java 2008-07-27 08:13:58 UTC (rev 1734)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/IncrementCounterWaitState.java 2008-07-28 11:11:28 UTC (rev 1735)
@@ -53,8 +53,10 @@
}
}
if (continueToWait) {
+ log.debug("continue to wait");
execution.waitForSignal();
} else {
+ log.debug("take a timeout transition");
execution.take("timeout");
}
}
Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TestTimerSession.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TestTimerSession.java 2008-07-27 08:13:58 UTC (rev 1734)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TestTimerSession.java 2008-07-28 11:11:28 UTC (rev 1735)
@@ -1,85 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.timer;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.jbpm.pvm.env.Environment;
-import org.jbpm.pvm.internal.job.TimerImpl;
-import org.jbpm.pvm.job.Timer;
-import org.jbpm.pvm.session.TimerSession;
-
-/**
- * @author Tom Baeyens
- * @author Pascal Verdage
- */
-public class TestTimerSession implements TimerSession {
-
- private static final long serialVersionUID = 1L;
-
- protected List<TimerImpl> timers = new ArrayList<TimerImpl>();
-
- public void cancel(Timer timer) {
- timers.remove(timer);
- }
-
- public void schedule(Timer timer) {
- timers.add((TimerImpl)timer);
- }
-
- /** execute the first timer (ordered by dueDate)
- * @throws Exception */
- public void executeFirstTimer() throws Exception {
- TimerImpl timerImpl = getFirstTimer();
- if (timerImpl != null) {
- TimerConfiguration.getEnvironmentFactory().openEnvironment();
- try {
- boolean deleteThisJob = timerImpl.execute(Environment.getCurrent());
- if (deleteThisJob) {
- timers.remove(timerImpl);
- }
- } finally {
- Environment.getCurrent().close();
- }
- }
- }
-
- /** return the first timer (ordered by dueDate) */
- public TimerImpl getFirstTimer() {
- TimerImpl firstTimer = null;
- Date firstDueDate = new Date(Long.MAX_VALUE);
- for (TimerImpl timerImpl : timers) {
- if (firstDueDate.after(timerImpl.getDueDate())) {
- firstTimer = timerImpl;
- firstDueDate = timerImpl.getDueDate();
- }
- }
- return firstTimer;
- }
-
- /** return the number of scheduled timers */
- public int getNbTimer() {
- return timers.size();
- }
-}
Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TestTimerSessionBinding.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TestTimerSessionBinding.java 2008-07-27 08:13:58 UTC (rev 1734)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TestTimerSessionBinding.java 2008-07-28 11:11:28 UTC (rev 1735)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.timer;
-
-import org.jbpm.pvm.internal.util.TagBinding;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.pvm.internal.wire.xml.WireParser;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
-
-/**
- * @author Tom Baeyens
- */
-public class TestTimerSessionBinding extends TagBinding {
-
- public TestTimerSessionBinding() {
- super("test-timer-session", null, WireParser.CATEGORY_DESCRIPTOR);
- }
-
- public Object parse(Element element, Parse parse, Parser parser) {
- return new ObjectDescriptor(TestTimerSession.class);
- }
-
-}
Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TimerConfiguration.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TimerConfiguration.java 2008-07-27 08:13:58 UTC (rev 1734)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TimerConfiguration.java 2008-07-28 11:11:28 UTC (rev 1735)
@@ -1,50 +0,0 @@
- package org.jbpm.pvm.timer;
-
-import org.jbpm.pvm.ExecutionService;
-import org.jbpm.pvm.ManagementService;
-import org.jbpm.pvm.ProcessService;
-import org.jbpm.pvm.env.EnvironmentFactory;
-import org.jbpm.pvm.env.PvmEnvironmentFactory;
-
-/**
- * @author Pascal Verdage
- */
-public abstract class TimerConfiguration {
-
- static boolean isInitialized;
- static ProcessService processService;
- static ExecutionService executionService;
- static ManagementService managementService;
- static EnvironmentFactory environmentFactory;
-
- public static ProcessService getProcessService() {
- initialize();
- return processService;
- }
-
- public static ExecutionService getExecutionService() {
- initialize();
- return executionService;
- }
-
- public static ManagementService getManagementService() {
- initialize();
- return managementService;
- }
-
- public static EnvironmentFactory getEnvironmentFactory() {
- initialize();
- return environmentFactory;
- }
-
- private synchronized static void initialize() {
- if (!isInitialized) {
- isInitialized = true;
- environmentFactory = new PvmEnvironmentFactory("org/jbpm/pvm/timer/environment.cfg.xml");
- processService = environmentFactory.get(ProcessService.class);
- executionService = environmentFactory.get(ExecutionService.class);
- managementService = environmentFactory.get(ManagementService.class);
- }
- }
-
-}
Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TimerIntegrationTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TimerIntegrationTest.java 2008-07-27 08:13:58 UTC (rev 1734)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TimerIntegrationTest.java 2008-07-28 11:11:28 UTC (rev 1735)
@@ -1,342 +0,0 @@
-/**
- * Copyright (C) 2006 Bull S. A. S.
- * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
- * This library is free software; you can redistribute it and/or modify it under the terms
- * of the GNU Lesser General Public License as published by the Free Software Foundation
- * version 2.1 of the License.
- * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License along with this
- * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301, USA.
- **/
-package org.jbpm.pvm.timer;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.jbpm.pvm.Execution;
-import org.jbpm.pvm.ExecutionService;
-import org.jbpm.pvm.ProcessService;
-import org.jbpm.pvm.activity.ActivityExecution;
-import org.jbpm.pvm.activity.ExternalActivity;
-import org.jbpm.pvm.env.Environment;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.model.NodeImpl;
-import org.jbpm.pvm.internal.util.Clock;
-import org.jbpm.pvm.job.JobTestHelper;
-import org.jbpm.pvm.job.Timer;
-import org.jbpm.pvm.model.OpenExecution;
-import org.jbpm.pvm.model.ProcessDefinition;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.pvm.samples.activities.AutomaticActivity;
-import org.jbpm.pvm.session.DbSession;
-import org.jbpm.pvm.session.PvmDbSession;
-import org.jbpm.pvm.test.base.DbTestCase;
-
-/**
- * @author Pascal Verdage
- */
-public class TimerIntegrationTest extends DbTestCase {
- public static class WaitState implements ExternalActivity {
-
- private static final long serialVersionUID = 1L;
-
- public void execute(ActivityExecution execution) {
- execution.waitForSignal();
- }
-
- public void signal(ActivityExecution execution,
- String signalName,
- Map<String, Object> parameters) {
- if (signalName!=null) {
- execution.take(signalName);
- }
- }
- }
-
- private static Date getDueDate(long duration) {
- return new Date(System.currentTimeMillis() + duration);
- }
-
- private static long twoDaysDuration = 2*24*60*60*1000;
-
- private static ExecutionService getExecutionService() {
- return Environment.getCurrent().get(ExecutionService.class);
- }
-
- private static ExecutionImpl deployAndInstanciateProcess(ProcessDefinition definition) {
- ProcessService processService = Environment.getCurrent().get(ProcessService.class);
- processService.deploy(definition);
-
- Execution processInstance = getExecutionService().startExecution(definition.getName());
-
- return (ExecutionImpl) processInstance;
- }
-
- public void testTimerDefinition() {
- ProcessDefinition processDefinition = ProcessFactory.build("timerDefinition")
- .node("request").initial().behaviour(WaitState.class)
- .transition().to("decide")
- .node("decide").behaviour(WaitState.class)
- .timer(getDueDate(twoDaysDuration), "timeout")
- .transition("decision made").to("response") // first defined transition is the default one
- .transition("timeout").to("reassign")
- .node("reassign").behaviour(WaitState.class)
- .node("response").behaviour(WaitState.class)
- .done();
-
- ExecutionImpl processInstance = deployAndInstanciateProcess(processDefinition);
-
- Execution execution = processInstance;
- assertEquals("request", execution.getNodeName());
- // first node is a wait state with no timer
- execution = getExecutionService().signalExecution(execution.getDbid());
- assertEquals("decide", execution.getNodeName());
-
- assertTrue(execution instanceof OpenExecution);
- OpenExecution openExecution = (OpenExecution) execution;
-
- // timer are created in a child execution
- assertFalse(openExecution.hasTimers());
-
- assertEquals(1, openExecution.getExecutions().size());
- OpenExecution child = openExecution.getExecutions().iterator().next();
-
- NodeImpl node1 = (NodeImpl) openExecution.getNode();
- NodeImpl node2 = (NodeImpl) child.getNode();
- assertEquals(node1, node2);
- assertEquals("decide", node1.getName());
- assertNotNull(node1.getTimerDefinitions());
-
- assertTrue(child.hasTimers());
- Set<Timer> timers = child.getTimers();
- assertEquals(1, timers.size());
- }
-
- private static ExecutionImpl loadExecutionFromDb(long id) {
- return Environment.getCurrent().get(DbSession.class).get(ExecutionImpl.class, id);
- }
-
- public void testTimerExecution() {
- ProcessDefinition processDefinition = ProcessFactory.build("timerExecution")
- .node("decide").initial().behaviour(WaitState.class)
- .timer(getDueDate(twoDaysDuration), "timeout")
- .transition("decision made").to("response") // first defined transition is the default one
- .transition("timeout").to("reassign")
- .node("reassign").behaviour(WaitState.class)
- .node("response").behaviour(WaitState.class)
- .done();
-
- ExecutionImpl processInstance = deployAndInstanciateProcess(processDefinition);
-
- Execution execution = processInstance;
- assertEquals("decide", execution.getNodeName());
-
- OpenExecution child = ((OpenExecution) execution).getExecutions().iterator().next();
- assertEquals("decide", child.getNodeName());
- Timer timer = child.getTimers().iterator().next();
-
- JobTestHelper jobTestHelper = getEnvironmentFactory().get(JobTestHelper.class);
- child = (OpenExecution) jobTestHelper.executeTimer(timer.getDbid());
- assertEquals(Execution.STATE_ENDED, child.getState());
-
- // check that the subExecution was deleted
- child = loadExecutionFromDb(child.getDbid());
- assertNull(child);
-
- // check that timers have been deleted
- List<Timer> timers = Environment.getCurrent().get(PvmDbSession.class).findTimers();
- assertNotNull(timers);
- assertTrue(timers.isEmpty());
-
- // check that process is in the right state
- execution = loadExecutionFromDb(processInstance.getDbid());
- assertEquals("reassign", execution.getNodeName());
- }
-
- public void testCanceledTimer() {
- ProcessDefinition processDefinition = ProcessFactory.build("timerCanceled")
- .node("decide").initial().behaviour(WaitState.class)
- .timer(getDueDate(twoDaysDuration), "timeout")
- .transition("decision made").to("response") // first defined transition is the default one
- .transition("timeout").to("reassign")
- .node("reassign").behaviour(WaitState.class)
- .node("response").behaviour(WaitState.class)
- .done();
-
- ExecutionImpl processInstance = deployAndInstanciateProcess(processDefinition);
-
- Execution execution = processInstance;
- assertEquals("decide", execution.getNodeName());
-
- // signal child execution
- Execution child = ((OpenExecution)execution).getExecutions().iterator().next();
- execution = getExecutionService().signalExecution(child.getDbid());
- assertEquals(Execution.STATE_ENDED, execution.getState());
-
- // check that the subExecution was deleted
- child = loadExecutionFromDb(child.getDbid());
- assertNull(child);
-
- // check that timers have been deleted
- List<Timer> timers = Environment.getCurrent().get(PvmDbSession.class).findTimers();
- assertNotNull(timers);
- assertTrue(timers.isEmpty());
-
- // check that process is in the right state
- execution = loadExecutionFromDb(processInstance.getDbid());
- assertEquals("response", execution.getNodeName());
- }
-
- public void testFixedDateTimer() {
- Date now = new Date();
- long twoDaysFromNow = now.getTime() + twoDaysDuration;
-
- ProcessDefinition processDefinition = ProcessFactory.build("fixedDateTimer")
- .node("decide").initial().behaviour(WaitState.class)
- .timer(getDueDate(twoDaysDuration), "timeout")
- .transition("decision made").to("response") // first defined transition is the default one
- .transition("timeout").to("reassign")
- .node("reassign").behaviour(WaitState.class)
- .node("response").behaviour(WaitState.class)
- .done();
-
- ExecutionImpl processInstance = deployAndInstanciateProcess(processDefinition);
-
- Execution execution = processInstance;
- OpenExecution child = ((OpenExecution) execution).getExecutions().iterator().next();
- assertEquals("decide", child.getNodeName());
-
- // check that timer's dueDate is good
- Timer timer = child.getTimers().iterator().next();
- assertTrue(twoDaysFromNow <= timer.getDueDate().getTime());
-
- // timer execution is tested in testTimerExecution
- }
-
- public void testDueDateDescriptionTimer() {
- Date now = new Date();
- long twoDaysFromNow = now.getTime() + twoDaysDuration;
-
- ProcessDefinition processDefinition = ProcessFactory.build("dueDateDescriptionTimer")
- .node("decide").initial().behaviour(WaitState.class)
- .timer("2 days", "timeout")
- .transition("decision made").to("response") // first defined transition is the default one
- .transition("timeout").to("reassign")
- .node("reassign").behaviour(WaitState.class)
- .node("response").behaviour(WaitState.class)
- .done();
-
- ExecutionImpl processInstance = deployAndInstanciateProcess(processDefinition);
-
- Execution execution = processInstance;
- OpenExecution child = ((OpenExecution) execution).getExecutions().iterator().next();
- assertEquals("decide", child.getNodeName());
-
- // check that timer's dueDate is good
- Timer timer = child.getTimers().iterator().next();
- assertTrue(twoDaysFromNow <= timer.getDueDate().getTime());
-
- // timer execution is tested in testTimerExecution
- }
-
- public void testReschedulingTimer() {
- Date now = Clock.getCurrentTime();
- long twoDaysFromNow = now.getTime() + twoDaysDuration;
-
- ProcessDefinition processDefinition = ProcessFactory.build("reschedulingTimer")
- .node("decide").initial().behaviour(IncrementCounterWaitState.class)
- .variable(IncrementCounterWaitState.COUNTER, "0")
- .timer("2 days", "increment", "2 days")
- .transition("decision made").to("response") // first defined transition is the default one
- .transition("timeout").to("reassign")
- .node("reassign").behaviour(WaitState.class)
- .node("response").behaviour(WaitState.class)
- .done();
-
- ExecutionImpl processInstance = deployAndInstanciateProcess(processDefinition);
-
- Execution execution = processInstance;
- OpenExecution child = ((OpenExecution) execution).getExecutions().iterator().next();
-
- for (int i=0; i<IncrementCounterWaitState.MAX_COUNTER_VALUE; i++) {
- // check that the execution is in the right node
- assertNotNull(child);
- assertEquals("decide", child.getNodeName());
- assertEquals(Execution.STATE_ACTIVE, child.getState());
-
- // check there is one timer
- assertTrue(child.hasTimers());
- assertEquals(1, child.getTimers().size());
-
- // check that timer's dueDate is good
- Timer timer = child.getTimers().iterator().next();
- assertTrue("error is "+(timer.getDueDate().getTime()-twoDaysFromNow)+" millis",
- twoDaysFromNow <= timer.getDueDate().getTime()+200);
-
- // set next minimum due date
- twoDaysFromNow = Clock.getCurrentTime().getTime() + twoDaysDuration;
-
- // execute timer
- JobTestHelper jobTestHelper = getEnvironmentFactory().get(JobTestHelper.class);
- jobTestHelper.executeTimer(timer.getDbid());
- child = loadExecutionFromDb(child.getDbid());
- }
-
- newTransaction();
- child = loadExecutionFromDb(child.getDbid());
- assertNull(child);
-
- // check that timers have been deleted
- List<Timer> timers = Environment.getCurrent().get(PvmDbSession.class).findTimers();
- assertNotNull(timers);
- assertTrue(timers.isEmpty());
-
- // check that process is in the right state
- execution = loadExecutionFromDb(processInstance.getDbid());
- assertEquals("reassign", execution.getNodeName());
- }
-
- public void testTimerEndingProcessExecution() {
- ProcessDefinition processDefinition = ProcessFactory.build("timerEndingProcess")
- .node("decide").initial().behaviour(WaitState.class)
- .timer("2 business days", "timeout")
- .transition("decision made").to("response") // first defined transition is the default one
- .transition("timeout").to("reassign")
- .node("reassign").behaviour(AutomaticActivity.class)
- .node("response").behaviour(WaitState.class)
- .done();
-
- ExecutionImpl processInstance = deployAndInstanciateProcess(processDefinition);
-
- Execution execution = processInstance;
- OpenExecution child = ((OpenExecution) execution).getExecutions().iterator().next();
- assertEquals("decide", child.getNodeName());
-
- // timer execution
- Timer timer = child.getTimers().iterator().next();
-
- JobTestHelper jobTestHelper = getEnvironmentFactory().get(JobTestHelper.class);
- child = (OpenExecution) jobTestHelper.executeTimer(timer.getDbid());
- assertEquals(Execution.STATE_ENDED, child.getState());
-
- // check that the subExecution was deleted
- child = loadExecutionFromDb(child.getDbid());
- assertNull(child);
-
- // check that timers have been deleted
- List<Timer> timers = Environment.getCurrent().get(PvmDbSession.class).findTimers();
- assertNotNull(timers);
- assertTrue(timers.isEmpty());
-
- // check that process is in the right state
- execution = loadExecutionFromDb(processInstance.getDbid());
- assertEquals("reassign", execution.getNodeName());
- assertEquals(Execution.STATE_ENDED, execution.getState());
- }
-
-}
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TimerTest.java (from rev 1696, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TimerIntegrationTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TimerTest.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TimerTest.java 2008-07-28 11:11:28 UTC (rev 1735)
@@ -0,0 +1,475 @@
+/**
+ * Copyright (C) 2006 Bull S. A. S.
+ * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
+ * This library is free software; you can redistribute it and/or modify it under the terms
+ * of the GNU Lesser General Public License as published by the Free Software Foundation
+ * version 2.1 of the License.
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA 02110-1301, USA.
+ **/
+package org.jbpm.pvm.timer;
+
+import java.util.Date;
+import java.util.Map;
+
+import org.jbpm.pvm.Execution;
+import org.jbpm.pvm.ExecutionService;
+import org.jbpm.pvm.ProcessService;
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.internal.job.TimerImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.util.Clock;
+import org.jbpm.pvm.job.JobTestHelper;
+import org.jbpm.pvm.job.Timer;
+import org.jbpm.pvm.model.OpenExecution;
+import org.jbpm.pvm.model.ProcessDefinition;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.pvm.samples.activities.AutomaticActivity;
+import org.jbpm.pvm.session.DbSession;
+import org.jbpm.pvm.session.PvmDbSession;
+import org.jbpm.pvm.test.base.DbTestCase;
+
+/**
+ * @author Pascal Verdage
+ */
+public class TimerTest extends DbTestCase {
+ /** Wait state that tries to take a transition when signalled */
+ public static class WaitState implements ExternalActivity {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ActivityExecution execution) {
+ execution.waitForSignal();
+ }
+
+ public void signal(ActivityExecution execution,
+ String signalName,
+ Map<String, Object> parameters) {
+ if (signalName!=null &&
+ execution.getNode().hasOutgoingTransition(signalName)) {
+ execution.take(signalName);
+ }
+ }
+ }
+
+ /** Wait state whose execution sets 'dueDate' variable to a fixed Date */
+ public static class SetDueDateWaitState extends WaitState {
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ActivityExecution execution) {
+ Date dueDate = new Date(Clock.getCurrentTime().getTime() + twoDaysDuration);
+ execution.setVariable("dueDate", dueDate);
+ super.execute(execution);
+ }
+
+ }
+ /////////////////////////////////////////////////////////
+ // Tools
+ /////////////////////////////////////////////////////////
+ private static long twoDaysDuration = 2*24*60*60*1000;
+
+ private static String getFormattedDate(long delay) {
+ return TimerImpl.formatDueDate(new Date(System.currentTimeMillis() + delay));
+ }
+
+ private static OpenExecution signalExecution(long executionDbid) {
+ ExecutionService executionService =
+ Environment.getCurrent().get(ExecutionService.class);
+ return (OpenExecution) executionService.signalExecution(executionDbid);
+ }
+
+ private static OpenExecution deployAndInstanciateProcess(ProcessDefinition definition) {
+ ProcessService processService = Environment.getCurrent().get(ProcessService.class);
+ processService.deploy(definition);
+
+ ExecutionService executionService =
+ Environment.getCurrent().get(ExecutionService.class);
+ Execution processInstance = executionService.startExecution(definition.getName());
+
+ return (ExecutionImpl) processInstance;
+ }
+
+ private static OpenExecution loadExecutionFromDb(long id) {
+ return Environment.getCurrent().get(DbSession.class).get(ExecutionImpl.class, id);
+ }
+
+ private static void assertNoTimer() {
+ assertTrue(Environment.getCurrent().get(PvmDbSession.class).findTimers().isEmpty());
+ }
+
+ /////////////////////////////////////////////////////////
+ // test methods
+ /////////////////////////////////////////////////////////
+ private OpenExecution initTest(ProcessDefinition definition) {
+ OpenExecution processInstance = deployAndInstanciateProcess(definition);
+ OpenExecution execution = processInstance;
+
+ if ("request".equals(execution.getNodeName())) {
+ /* the request node might be use to have a specific initialisation
+ * through the node execution */
+ // go to test node
+ execution = signalExecution(execution.getDbid());
+ }
+ return execution;
+ }
+
+ private long makeTestNode(long minimumDate, OpenExecution execution) {
+ // check there is one sub execution
+ assertEquals(1, execution.getExecutions().size());
+
+ // check the execution state
+ assertEquals("decide", execution.getNodeName());
+ OpenExecution child = execution.getExecutions().iterator().next();
+ assertEquals("decide", child.getNodeName());
+
+ // check there is one timer
+ assertFalse(execution.hasTimers());
+ assertTrue(child.hasTimers());
+ assertEquals(1, child.getTimers().size());
+
+ // check that timer's dueDate is good
+ Timer timer = child.getTimers().iterator().next();
+ assertTrue("error is "+(minimumDate-timer.getDueDate().getTime()),
+ minimumDate <= timer.getDueDate().getTime());
+
+ // execute the timer
+ JobTestHelper jobTestHelper = getEnvironmentFactory().get(JobTestHelper.class);
+ child = (OpenExecution) jobTestHelper.executeTimer(timer.getDbid());
+
+ return child.getDbid();
+ }
+
+ private void endTest(long executionDbid, long childDbid, String expectedState) {
+ newTransaction();
+
+ // check that the sub execution has been deleted
+ OpenExecution child = loadExecutionFromDb(childDbid);
+ assertNull(child);
+
+ // check that timers have been deleted
+ assertNoTimer();
+
+ // check that process is in the right state
+ OpenExecution execution = loadExecutionFromDb(executionDbid);
+ assertEquals(0, execution.getExecutions().size());
+ assertEquals("reassign", execution.getNodeName());
+ assertEquals(expectedState, execution.getState());
+ }
+
+ private void makeTestNoRepeat(ProcessDefinition definition) {
+ long twoDaysFromNow =Clock.getCurrentTime().getTime() + twoDaysDuration;
+ OpenExecution execution = initTest(definition);
+
+ long childDbid = makeTestNode(twoDaysFromNow - 100, execution);
+
+ endTest(execution.getDbid(), childDbid, Execution.STATE_ACTIVE);
+ }
+
+ private void makeTestRepeat(ProcessDefinition definition) {
+ OpenExecution execution = initTest(definition);
+ long childDbid = -1;
+
+ for (int i=0; i<IncrementCounterWaitState.MAX_COUNTER_VALUE; i++) {
+ long twoDaysFromNow = Clock.getCurrentTime().getTime() + twoDaysDuration;
+ childDbid = makeTestNode(twoDaysFromNow-200, execution);
+ newTransaction();
+ execution = loadExecutionFromDb(execution.getDbid());
+ }
+
+ endTest(execution.getDbid(), childDbid, Execution.STATE_ACTIVE);
+ }
+
+ /////////////////////////////////////////////////////////
+ // simple timer execution
+ // not repeated timer when due date is not a script
+ /////////////////////////////////////////////////////////
+ /** This scenario test a timer defined by a string.
+ * The string represents a formatted date. */
+ public void testFormattedDateTimer() {
+ String dueDate = getFormattedDate(twoDaysDuration);
+
+ ProcessDefinition processDefinition = ProcessFactory.build("formattedDateTimer")
+ .node("decide").initial().behaviour(WaitState.class)
+ .timer(dueDate, "timeout")
+ .transition("decision made").to("response")
+ .transition("timeout").to("reassign")
+ .node("reassign").behaviour(WaitState.class)
+ .node("response").behaviour(WaitState.class)
+ .done();
+
+ makeTestNoRepeat(processDefinition);
+ }
+
+ /** This scenario test a timer defined by a string.
+ * The string represents a formatted date. */
+ public void testCustomFormattedDateTimer() {
+ TimerImpl.setDateFormat("EE, MM dd yyyy, hh:mm:ss,SSS a");
+ try {
+ String dueDate = getFormattedDate(twoDaysDuration);
+
+ ProcessDefinition processDefinition = ProcessFactory.build("customFormattedDateTimer")
+ .node("decide").initial().behaviour(WaitState.class)
+ .timer(dueDate, "timeout")
+ .transition("decision made").to("response")
+ .transition("timeout").to("reassign")
+ .node("reassign").behaviour(WaitState.class)
+ .node("response").behaviour(WaitState.class)
+ .done();
+
+ makeTestNoRepeat(processDefinition);
+ } finally {
+ // reset original date format
+ TimerImpl.setDateFormat("yyyy-MM-dd HH:mm:ss,SSS");
+ }
+ }
+
+ /** This scenario test a timer defined by a string.
+ * The string represents a duration. */
+ public void testDurationTimer() {
+ ProcessDefinition processDefinition = ProcessFactory.build("durationTimer")
+ .node("decide").initial().behaviour(WaitState.class)
+ .timer("2 days", "juel", "timeout", null)
+ .transition("decision made").to("response")
+ .transition("timeout").to("reassign")
+ .node("reassign").behaviour(WaitState.class)
+ .node("response").behaviour(WaitState.class)
+ .done();
+
+ makeTestNoRepeat(processDefinition);
+ }
+
+ /////////////////////////////////////////////////////////
+ // simple timer execution
+ // not repeated timer when due date is a juel script
+ /////////////////////////////////////////////////////////
+ /** This scenario test a timer defined by a juel script.
+ * The corresponding variable is a Date object */
+ public void testDateVariableJuelTimer() {
+ ProcessDefinition processDefinition = ProcessFactory.build("dateVariableJuelTimer")
+ .variable("dueDate")
+ .node("request").initial().behaviour(SetDueDateWaitState.class)
+ .transition().to("decide")
+ .node("decide").behaviour(WaitState.class)
+ .timer("#{dueDate}", "juel", "timeout", null)
+ .transition("decision made").to("response")
+ .transition("timeout").to("reassign")
+ .node("reassign").behaviour(WaitState.class)
+ .node("response").behaviour(WaitState.class)
+ .done();
+
+ makeTestNoRepeat(processDefinition);
+ }
+
+ /** This scenario test a timer defined by a juel script.
+ * The corresponding variable is a String object.
+ * The string represents a formatted date */
+ public void testFormattedDateVariableJuelTimer() {
+ String dueDate = getFormattedDate(twoDaysDuration);
+
+ ProcessDefinition processDefinition = ProcessFactory.build("formattedDateVariableJuelTimer")
+ .variable("timerDelay", dueDate)
+ .node("decide").initial().behaviour(WaitState.class)
+ .timer("#{timerDelay}", "juel", "timeout", null)
+ .transition("decision made").to("response")
+ .transition("timeout").to("reassign")
+ .node("reassign").behaviour(WaitState.class)
+ .node("response").behaviour(WaitState.class)
+ .done();
+
+ makeTestNoRepeat(processDefinition);
+ }
+
+ /** This scenario test a timer defined by a juel script.
+ * The corresponding variable is a String object.
+ * The string represents a duration */
+ public void testDurationVariableJuelTimer() {
+ ProcessDefinition processDefinition = ProcessFactory.build("durationVariableJuelTimer")
+ .variable("timerDelay", "2 days")
+ .node("decide").initial().behaviour(WaitState.class)
+ .timer("#{timerDelay}", "juel", "timeout", null)
+ .transition("decision made").to("response")
+ .transition("timeout").to("reassign")
+ .node("reassign").behaviour(WaitState.class)
+ .node("response").behaviour(WaitState.class)
+ .done();
+
+ makeTestNoRepeat(processDefinition);
+ }
+
+ /*
+ /////////////////////////////////////////////////////////
+ // simple timer execution
+ // not repeated timer when due date is a groovy script
+ /////////////////////////////////////////////////////////
+ public void testDateVariableGroovyTimer() {
+ ProcessDefinition processDefinition = ProcessFactory.build("dateVariableGroovyTimer")
+ .variable("dueDate")
+ .node("request").initial().behaviour(SetDueDateWaitState.class)
+ .transition().to("decide")
+ .node("decide").behaviour(WaitState.class)
+ .timer("dueDate", "groovy", "timeout", null)
+ .transition("decision made").to("response")
+ .transition("timeout").to("reassign")
+ .node("reassign").behaviour(WaitState.class)
+ .node("response").behaviour(WaitState.class)
+ .done();
+
+ makeTestNoRepeat(processDefinition);
+ }
+
+ public void testFormattedDateVariableGroovyTimer() {
+ String dueDate = getFormattedDate(twoDaysDuration);
+
+ ProcessDefinition processDefinition = ProcessFactory.build("formattedDateVariableGroovyTimer")
+ .variable("timerDelay", dueDate)
+ .node("decide").initial().behaviour(WaitState.class)
+ .timer("timerDelay", "groovy", "timeout", null)
+ .transition("decision made").to("response")
+ .transition("timeout").to("reassign")
+ .node("reassign").behaviour(WaitState.class)
+ .node("response").behaviour(WaitState.class)
+ .done();
+
+ makeTestNoRepeat(processDefinition);
+ }
+
+ public void testDurationVariableGroovyTimer() {
+ ProcessDefinition processDefinition = ProcessFactory.build("durationVariableGroovyTimer")
+ .variable("timerDelay", "2 days")
+ .node("decide").initial().behaviour(WaitState.class)
+ .timer("timerDelay", "groovy", "timeout", null)
+ .transition("decision made").to("response")
+ .transition("timeout").to("reassign")
+ .node("reassign").behaviour(WaitState.class)
+ .node("response").behaviour(WaitState.class)
+ .done();
+
+ makeTestNoRepeat(processDefinition);
+ }
+ */
+
+ /////////////////////////////////////////////////////////
+ // repeated timer execution
+ /////////////////////////////////////////////////////////
+ /** <p>this scenario tests a repeated timer.
+ * When signalled, the node makes an alert (logs).<br>
+ * After IncrementCounterWaitState.COUNTER loops,
+ * the node takes a timeout transition.</p>
+ * <p>Repeat is a string representing a duration.</p> */
+ public void testDurationRepeat() {
+ ProcessDefinition processDefinition = ProcessFactory.build("durationRepeat")
+ .node("decide").initial().behaviour(IncrementCounterWaitState.class)
+ .variable(IncrementCounterWaitState.COUNTER, "0")
+ .timer("2 days", null, "increment", "2 days")
+ .transition("decision made").to("response")
+ .transition("timeout").to("reassign")
+ .node("reassign").behaviour(WaitState.class)
+ .node("response").behaviour(WaitState.class)
+ .done();
+
+ makeTestRepeat(processDefinition);
+ }
+
+ /*
+ public void testDurationVariableGroovyRepeat() {
+ // groovy constraint
+ // if we use '2 days' instead of 'timerDelay' variable,
+ // scripting fails to evaluate '2 days'
+ ProcessDefinition processDefinition = ProcessFactory.build("durationGroovyRepeat")
+ .variable("repeat", "2 days")
+ .node("decide").initial().behaviour(IncrementCounterWaitState.class)
+ .variable(IncrementCounterWaitState.COUNTER, "0")
+ .timer("'2 days'", "groovy", "increment", "repeat")
+ .transition("decision made").to("response")
+ .transition("timeout").to("reassign")
+ .node("reassign").behaviour(WaitState.class)
+ .node("response").behaviour(WaitState.class)
+ .done();
+
+ makeTestRepeat(processDefinition);
+ }
+ */
+
+ /** <p>this scenario tests a repeated timer.
+ * When signalled, the node makes an alert (logs).<br>
+ * After IncrementCounterWaitState.COUNTER loops,
+ * the node takes a timeout transition.</p>
+ * <p>Repeat is a juel script referring to a duration.</p> */
+ public void testDurationVariableJuelRepeat() {
+ ProcessDefinition processDefinition = ProcessFactory.build("durationJuelRepeat")
+ .variable("repeat", "2 days")
+ .node("decide").initial().behaviour(IncrementCounterWaitState.class)
+ .variable(IncrementCounterWaitState.COUNTER, "0")
+ .timer("2 days", "juel", "increment", "#{repeat}")
+ .transition("decision made").to("response")
+ .transition("timeout").to("reassign")
+ .node("reassign").behaviour(WaitState.class)
+ .node("response").behaviour(WaitState.class)
+ .done();
+
+ makeTestRepeat(processDefinition);
+ }
+
+ /////////////////////////////////////////////////////////
+ // others
+ /////////////////////////////////////////////////////////
+ /** this scenario tests a timer that doesn't fire */
+ public void testCanceledTimer() {
+ String dueDate = getFormattedDate(twoDaysDuration);
+ ProcessDefinition processDefinition = ProcessFactory.build("timerCanceled")
+ .node("decide").initial().behaviour(WaitState.class)
+ .timer(dueDate, "timeout")
+ .transition("decision made").to("response")
+ .transition("timeout").to("reassign")
+ .node("reassign").behaviour(WaitState.class)
+ .node("response").behaviour(WaitState.class)
+ .done();
+
+ OpenExecution processInstance = deployAndInstanciateProcess(processDefinition);
+
+ OpenExecution execution = processInstance;
+ assertEquals("decide", execution.getNodeName());
+
+ // signal child execution
+ OpenExecution child = execution.getExecutions().iterator().next();
+ execution = signalExecution(child.getDbid());
+ assertEquals(Execution.STATE_ENDED, execution.getState());
+
+ // check that the subExecution was deleted
+ child = loadExecutionFromDb(child.getDbid());
+ assertNull(child);
+
+ // check that timers have been deleted
+ assertNoTimer();
+
+ // check that process is in the right state
+ execution = loadExecutionFromDb(processInstance.getDbid());
+ assertEquals("response", execution.getNodeName());
+ assertEquals(Execution.STATE_ACTIVE, execution.getState());
+ }
+
+ /** this scenario tests the case where the process execution ends
+ * in the transaction that executes the timer */
+ public void testTimerEndingProcessExecution() {
+ ProcessDefinition processDefinition = ProcessFactory.build("timerEndingProcess")
+ .node("decide").initial().behaviour(WaitState.class)
+ .timer("2 business days", "timeout")
+ .transition("decision made").to("response")
+ .transition("timeout").to("reassign")
+ .node("reassign").behaviour(AutomaticActivity.class)
+ .node("response").behaviour(WaitState.class)
+ .done();
+
+ long twoDaysFromNow = Clock.getCurrentTime().getTime()+twoDaysDuration;
+ OpenExecution execution = initTest(processDefinition);
+ long childDbid = makeTestNode(twoDaysFromNow, execution);
+ endTest(execution.getDbid(), childDbid, Execution.STATE_ENDED);
+ }
+
+}
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TimerTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TimerUnitTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TimerUnitTest.java 2008-07-27 08:13:58 UTC (rev 1734)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/timer/TimerUnitTest.java 2008-07-28 11:11:28 UTC (rev 1735)
@@ -1,176 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.timer;
-
-import java.util.Date;
-
-import org.jbpm.pvm.test.base.JbpmTestCase;
-import org.jbpm.pvm.internal.job.TimerImpl;
-import org.jbpm.pvm.job.Timer;
-
-/**
- * @author Tom Baeyens
- * @author Pascal Verdage
- */
-public class TimerUnitTest extends JbpmTestCase
-{
-
-
- protected Timer timer() {
- return new TimerImpl();
- }
-
- public void testSetDueDate() throws Exception {
- TimerImpl timer = new TimerImpl();
- Date now = new Date(System.currentTimeMillis());
- timer.setDueDate(now);
- TestTimerSession timerSession = new TestTimerSession();
- timerSession.schedule(timer);
- assertEquals(1, timerSession.getNbTimer());
- assertEquals(timer, timerSession.getFirstTimer());
- timerSession.executeFirstTimer();
- assertEquals(0, timerSession.getNbTimer());
- }
-
- /*
- TODO finish after refactoring
-
-
- public void testSetDueDateDescription() throws Exception {
- TimerImpl timerImpl = new TimerImpl();
- timerImpl.setDueDateDescription("5 seconds");
- TestTimerSession timerSession = new TestTimerSession();
- timerSession.schedule(timerImpl);
- assertEquals(1, timerSession.getNbTimer());
- assertEquals(timerImpl, timerSession.getFirstTimer());
- timerSession.executeFirstTimer();
- assertEquals(0, timerSession.getNbTimer());
- }
-
- public void testRepeatedTimer() throws Exception {
- TimerImpl timerImpl = new TimerImpl();
- Date now= new Date();
- timerImpl.setDueDate(now);
- timerImpl.setRepeat("3 seconds");
- TestTimerSession timerSession = new TestTimerSession();
- timerSession.schedule(timerImpl);
- assertEquals(1, timerSession.getNbTimer());
- assertEquals(timerImpl, timerSession.getFirstTimer());
- timerSession.executeFirstTimer();
- assertEquals(1, timerSession.getNbTimer());
- }
-
- private static class TestActivityInstance extends ActivityInstanceImpl {
- private static final long serialVersionUID = 1L;
- private int executionCount = 0;
-
- public void signal(String signalName, Map<String, Object> parameters) {
- executionCount++;
- }
- public int getExecutionCount() {
- return executionCount;
- }
-
- public String toString() {
- return "test activity";
- }
- }
-
- public void testActivityInstanceNoSignalNoEvent() throws Exception {
- TimerImpl timerImpl = new TimerImpl();
- TestActivityInstance instance = new TestActivityInstance();
- TestExecution execution = new TestExecution();
- timerImpl.setActivityInstance(instance);
- timerImpl.setExecution(execution);
- TestTimerSession timerSession = new TestTimerSession();
- timerSession.schedule(timerImpl);
- assertEquals(1, timerSession.getNbTimer());
- timerSession.executeFirstTimer();
- assertEquals(0, timerSession.getNbTimer());
- assertEquals(0, instance.getExecutionCount());
- assertEquals(0, execution.getExecutionCount());
- }
-
- public void testActivityInstanceWithSignal() throws Exception {
- TimerImpl timerImpl = new TimerImpl();
- TestActivityInstance instance = new TestActivityInstance();
- TestExecution execution = new TestExecution();
- timerImpl.setActivityInstance(instance);
- timerImpl.setSignalName("timeout");
- timerImpl.setExecution(execution);
- TestTimerSession timerSession = new TestTimerSession();
- timerSession.schedule(timerImpl);
- assertEquals(1, timerSession.getNbTimer());
- timerSession.executeFirstTimer();
- assertEquals(0, timerSession.getNbTimer());
- assertEquals(1, instance.getExecutionCount());
- assertEquals(0, execution.getExecutionCount());
- }
-
- private static class TestExecution extends ExecutionImpl {
- private static final long serialVersionUID = 1L;
- private int executionCount = 0;
-
- public int getExecutionCount() {
- return executionCount;
- }
-
- public void fire(String eventName, ObservableElement eventSource) {
- executionCount++;
- }
-
- public String toString() {
- return "test execution";
- }
- }
-
- public void testActivityInstanceWithEvent() throws Exception {
- TimerImpl timerImpl = new TimerImpl();
- TestActivityInstance instance = new TestActivityInstance();
- TestExecution execution = new TestExecution();
- timerImpl.setActivityInstance(instance);
- timerImpl.setEventName("timeout");
- timerImpl.setExecution(execution);
- TestTimerSession timerSession = new TestTimerSession();
- timerSession.schedule(timerImpl);
- assertEquals(1, timerSession.getNbTimer());
- timerSession.executeFirstTimer();
- assertEquals(0, timerSession.getNbTimer());
- assertEquals(0, instance.getExecutionCount());
- assertEquals(1, execution.getExecutionCount());
- }
-
- public void testEventWithNoActivityInstance() throws Exception {
- TimerImpl timerImpl = new TimerImpl();
- TestExecution execution = new TestExecution();
- timerImpl.setEventName("timeout");
- timerImpl.setExecution(execution);
- TestTimerSession timerSession = new TestTimerSession();
- timerSession.schedule(timerImpl);
- assertEquals(1, timerSession.getNbTimer());
- timerSession.executeFirstTimer();
- assertEquals(0, timerSession.getNbTimer());
- assertEquals(1, execution.getExecutionCount());
- }
-
- */
-}
Modified: jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/timer/environment.cfg.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/timer/environment.cfg.xml 2008-07-27 08:13:58 UTC (rev 1734)
+++ jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/timer/environment.cfg.xml 2008-07-28 11:11:28 UTC (rev 1735)
@@ -7,6 +7,7 @@
<job-test-helper />
<process-service />
+ <execution-service />
<command-service>
<retry-interceptor />
@@ -39,6 +40,14 @@
<holiday period="01/07/2008 - 31/08/2008"/>
</business-calendar>
+ <script-manager default-expression-language='juel'
+ default-script-language='juel'
+ read-contexts='execution, environment, environment-factory'
+ write-context='null'>
+ <script-language name='juel' factory='com.sun.script.juel.JuelScriptEngineFactory' />
+<!-- <script-language name='groovy' factory='com.sun.script.groovy.GroovyScriptEngineFactory' />-->
+ </script-manager>
+
</environment-factory>
<environment>
17 years, 9 months
JBoss JBPM SVN: r1734 - in jbossbpm/spec/trunk: modules/dialects/stp and 11 other directories.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-07-27 04:13:58 -0400 (Sun, 27 Jul 2008)
New Revision: 1734
Added:
jbossbpm/spec/trunk/modules/ri/src/test/
jbossbpm/spec/trunk/modules/ri/src/test/java/
jbossbpm/spec/trunk/modules/ri/src/test/java/org/
jbossbpm/spec/trunk/modules/ri/src/test/java/org/jboss/
jbossbpm/spec/trunk/modules/ri/src/test/java/org/jboss/bpm/
jbossbpm/spec/trunk/modules/ri/src/test/java/org/jboss/bpm/expression/
jbossbpm/spec/trunk/modules/ri/src/test/java/org/jboss/bpm/expression/MvelExpressionTest.java
Modified:
jbossbpm/spec/trunk/.classpath
jbossbpm/spec/trunk/modules/dialects/stp/pom.xml
jbossbpm/spec/trunk/modules/ri/pom.xml
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/BPMNElementImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/EventImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/FlowObjectImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GraphicalElementImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ReceiveTaskImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SendTaskImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SubProcessImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskImpl.java
jbossbpm/spec/trunk/modules/testsuite/pom.xml
jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java
jbossbpm/spec/trunk/pom.xml
Log:
Add MVEL
Modified: jbossbpm/spec/trunk/.classpath
===================================================================
--- jbossbpm/spec/trunk/.classpath 2008-07-26 09:43:04 UTC (rev 1733)
+++ jbossbpm/spec/trunk/.classpath 2008-07-27 08:13:58 UTC (rev 1734)
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="modules/api/target/classes" path="modules/api/src/main/java"/>
+ <classpathentry kind="src" path="modules/ri/src/test/java"/>
<classpathentry kind="src" path="modules/ri/src/main/java"/>
<classpathentry kind="src" output="modules/testsuite/target/test-classes" path="modules/testsuite/src/test/java"/>
<classpathentry kind="src" path="modules/dialects/api10/src/main/java"/>
Modified: jbossbpm/spec/trunk/modules/dialects/stp/pom.xml
===================================================================
--- jbossbpm/spec/trunk/modules/dialects/stp/pom.xml 2008-07-26 09:43:04 UTC (rev 1733)
+++ jbossbpm/spec/trunk/modules/dialects/stp/pom.xml 2008-07-27 08:13:58 UTC (rev 1734)
@@ -37,18 +37,6 @@
<artifactId>jaxb-impl</artifactId>
</dependency>
- <!-- Test Dependencies -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <scope>test</scope>
- </dependency>
-
<!-- Runtime Dependencies -->
<dependency>
<groupId>org.jboss.bpm</groupId>
Modified: jbossbpm/spec/trunk/modules/ri/pom.xml
===================================================================
--- jbossbpm/spec/trunk/modules/ri/pom.xml 2008-07-26 09:43:04 UTC (rev 1733)
+++ jbossbpm/spec/trunk/modules/ri/pom.xml 2008-07-27 08:13:58 UTC (rev 1734)
@@ -9,8 +9,10 @@
<!-- -->
<!-- ====================================================================== -->
-<!-- $Id$ -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<!-- $Id$
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>JBossBPM - Spec RI</name>
<groupId>org.jboss.bpm</groupId>
@@ -33,6 +35,9 @@
<version>${version}</version>
<scope>compile</scope>
</dependency>
+ <dependency>
+ <groupId>org.mvel</groupId>
+ <artifactId>mvel</artifactId>
+ </dependency>
</dependencies>
-
</project>
\ No newline at end of file
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityImpl.java 2008-07-26 09:43:04 UTC (rev 1733)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityImpl.java 2008-07-27 08:13:58 UTC (rev 1734)
@@ -27,14 +27,22 @@
import java.util.Collections;
import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jboss.bpm.InvalidProcessException;
import org.jboss.bpm.NotImplementedException;
import org.jboss.bpm.model.Activity;
import org.jboss.bpm.model.Expression;
+import org.jboss.bpm.model.Flow;
import org.jboss.bpm.model.InputSet;
import org.jboss.bpm.model.OutputSet;
import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.Property;
+import org.jboss.bpm.runtime.ExecutionHandler;
+import org.jboss.bpm.runtime.FlowHandler;
+import org.jboss.bpm.runtime.FlowScheduler;
+import org.jboss.bpm.runtime.Token;
+import org.jboss.bpm.runtime.FlowScheduler.Tuple;
/**
* An activity is a generic term for work that a company or organization performs via business processes. An activity
@@ -44,13 +52,19 @@
* @author thomas.diesler(a)jboss.com
* @since 08-Jul-2008
*/
-public abstract class ActivityImpl extends FlowObjectImpl implements Activity, MutablePropertySupport
+public abstract class ActivityImpl extends FlowObjectImpl implements Activity, MutablePropertySupport,
+ SingleInFlowSetterSupport, SingleOutFlowSetterSupport
{
+ // provide logging
+ private static final Log log = LogFactory.getLog(ActivityImpl.class);
+
private String name;
private List<InputSet> inputSets = new ArrayList<InputSet>();
private List<OutputSet> outputSets = new ArrayList<OutputSet>();
private List<Expression> ioRules = new ArrayList<Expression>();
private List<Property> props = new ArrayList<Property>();
+ private Flow inFlow;
+ private Flow outFlow;
public ActivityImpl(String name)
{
@@ -147,6 +161,59 @@
props.add(prop);
}
+ public Flow getInFlow()
+ {
+ return inFlow;
+ }
+
+ public void setInFlow(Flow inFlow)
+ {
+ this.inFlow = inFlow;
+ }
+
+ public Flow getOutFlow()
+ {
+ return outFlow;
+ }
+
+ public void setOutFlow(Flow flow)
+ {
+ this.outFlow = flow;
+ }
+
+ public ExecutionHandler getExecutionHandler()
+ {
+ ExecutionHandler handler = super.getExecutionHandler();
+ if (handler == null)
+ {
+ handler = new ExecutionHandler()
+ {
+ public void execute(Token token)
+ {
+ log.debug("Nothing to do in task: " + getName());
+ }
+ };
+ }
+ return handler;
+ }
+
+ public FlowHandler getFlowHandler()
+ {
+ FlowHandler handler = super.getFlowHandler();
+ if (handler == null)
+ {
+ handler = new FlowHandler()
+ {
+ public void execute(FlowScheduler scheduler, Token token)
+ {
+ Tuple tuple = new Tuple(outFlow, token);
+ scheduler.scheduleTuple(tuple);
+ }
+ };
+ }
+ return handler;
+ }
+
@Override
protected void initialize(Process proc)
{
@@ -157,19 +224,19 @@
{
int artSize = inSet.getArtifactInputs().size();
int propSize = inSet.getProperties().size();
- if (artSize == 0 && propSize == 0)
+ if (artSize == 0 && propSize == 0)
{
throw new InvalidProcessException(
"For the combination of ArtifactInputs and PropertyInputs, there MUST be at least one item defined for the InputSet");
}
}
-
+
// Validate OutputSets
for (OutputSet outSet : outputSets)
{
int artSize = outSet.getArtifactOutputs().size();
int propSize = outSet.getProperties().size();
- if (artSize == 0 && propSize == 0)
+ if (artSize == 0 && propSize == 0)
{
throw new InvalidProcessException(
"For the combination of ArtifactOutputs and PropertyOututs, there MUST be at least one item defined for the OutputSet");
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/BPMNElementImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/BPMNElementImpl.java 2008-07-26 09:43:04 UTC (rev 1733)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/BPMNElementImpl.java 2008-07-27 08:13:58 UTC (rev 1734)
@@ -43,6 +43,8 @@
*/
public class BPMNElementImpl implements BPMNElement
{
+ private static final long serialVersionUID = 1L;
+
private ObjectName id;
private Process process;
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/EventImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/EventImpl.java 2008-07-26 09:43:04 UTC (rev 1733)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/EventImpl.java 2008-07-27 08:13:58 UTC (rev 1734)
@@ -22,9 +22,6 @@
package org.jboss.bpm.model.internal;
import org.jboss.bpm.model.Event;
-import org.jboss.bpm.runtime.ExecutionHandler;
-import org.jboss.bpm.runtime.FlowHandler;
-import org.jboss.bpm.runtime.SignalHandler;
//$Id$
@@ -36,40 +33,7 @@
* @author thomas.diesler(a)jboss.com
* @since 08-Jul-2008
*/
-public abstract class EventImpl extends FlowObjectImpl implements Event, HandlerSetterSupport
+public abstract class EventImpl extends FlowObjectImpl implements Event
{
- private ExecutionHandler executionHandler;
- private FlowHandler flowHandler;
- private SignalHandler signalHandler;
-
- public ExecutionHandler getExecutionHandler()
- {
- return executionHandler;
- }
- public void setExecutionHandler(ExecutionHandler executionHandler)
- {
- this.executionHandler = executionHandler;
- }
-
- public FlowHandler getFlowHandler()
- {
- return flowHandler;
- }
-
- public void setFlowHandler(FlowHandler flowHandler)
- {
- this.flowHandler = flowHandler;
- }
-
- public SignalHandler getSignalHandler()
- {
- return signalHandler;
- }
-
- public void setSignalHandler(SignalHandler signalHandler)
- {
- this.signalHandler = signalHandler;
- }
-
}
\ No newline at end of file
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/FlowObjectImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/FlowObjectImpl.java 2008-07-26 09:43:04 UTC (rev 1733)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/FlowObjectImpl.java 2008-07-27 08:13:58 UTC (rev 1734)
@@ -33,6 +33,10 @@
import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.SingleInFlowSupport;
import org.jboss.bpm.model.SingleOutFlowSupport;
+import org.jboss.bpm.runtime.ExecutionHandler;
+import org.jboss.bpm.runtime.FlowHandler;
+import org.jboss.bpm.runtime.SignalHandler;
+import org.jboss.bpm.runtime.Token;
//$Id$
@@ -42,8 +46,53 @@
* @author thomas.diesler(a)jboss.com
* @since 08-Jul-2008
*/
-public abstract class FlowObjectImpl extends GraphicalElementImpl implements FlowObject
+public abstract class FlowObjectImpl extends GraphicalElementImpl implements FlowObject, HandlerSetterSupport
{
+ private static final long serialVersionUID = 1L;
+
+ private ExecutionHandler executionHandler;
+ private FlowHandler flowHandler;
+ private SignalHandler signalHandler;
+
+ public ExecutionHandler getExecutionHandler()
+ {
+ return executionHandler;
+ }
+
+ public void setExecutionHandler(ExecutionHandler executionHandler)
+ {
+ this.executionHandler = executionHandler;
+ }
+
+ public FlowHandler getFlowHandler()
+ {
+ return flowHandler;
+ }
+
+ public void setFlowHandler(FlowHandler flowHandler)
+ {
+ this.flowHandler = flowHandler;
+ }
+
+ public SignalHandler getSignalHandler()
+ {
+ return signalHandler;
+ }
+
+ public void setSignalHandler(SignalHandler signalHandler)
+ {
+ this.signalHandler = signalHandler;
+ }
+
+ public void execute(Token token)
+ {
+ ExecutionHandler handler = getExecutionHandler();
+ if (handler != null)
+ {
+ handler.execute(token);
+ }
+ }
+
@Override
protected void initialize(Process proc)
{
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayImpl.java 2008-07-26 09:43:04 UTC (rev 1733)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayImpl.java 2008-07-27 08:13:58 UTC (rev 1734)
@@ -49,16 +49,13 @@
* @author thomas.diesler(a)jboss.com
* @since 08-Jul-2008
*/
-public abstract class GatewayImpl extends FlowObjectImpl implements Gateway, HandlerSetterSupport, MultipleInFlowSetterSupport
+public abstract class GatewayImpl extends FlowObjectImpl implements Gateway, MultipleInFlowSetterSupport
{
// provide logging
private static final Log log = LogFactory.getLog(GatewayImpl.class);
private String name;
protected List<Flow> inFlows = new ArrayList<Flow>();
- private ExecutionHandler executionHandler;
- private FlowHandler flowHandler;
- private SignalHandler signalHandler;
private List<Gate> gates = new ArrayList<Gate>();
public GatewayImpl(String name)
@@ -93,7 +90,7 @@
public ExecutionHandler getExecutionHandler()
{
- ExecutionHandler handler = executionHandler;
+ ExecutionHandler handler = super.getExecutionHandler();
if (handler == null)
{
handler = new ExecutionHandler()
@@ -107,14 +104,9 @@
return handler;
}
- public void setExecutionHandler(ExecutionHandler executionHandler)
- {
- this.executionHandler = executionHandler;
- }
-
public FlowHandler getFlowHandler()
{
- FlowHandler handler = flowHandler;
+ FlowHandler handler = super.getFlowHandler();
if (handler == null && gates.size() == 1)
{
handler = new FlowHandler()
@@ -129,14 +121,9 @@
return handler;
}
- public void setFlowHandler(FlowHandler flowHandler)
- {
- this.flowHandler = flowHandler;
- }
-
public SignalHandler getSignalHandler()
{
- SignalHandler handler = signalHandler;
+ SignalHandler handler = super.getSignalHandler();
if (handler == null)
{
final FlowObject gateway = this;
@@ -155,9 +142,4 @@
}
return handler;
}
-
- public void setSignalHandler(SignalHandler signalHandler)
- {
- this.signalHandler = signalHandler;
- }
}
\ No newline at end of file
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GraphicalElementImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GraphicalElementImpl.java 2008-07-26 09:43:04 UTC (rev 1733)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GraphicalElementImpl.java 2008-07-27 08:13:58 UTC (rev 1734)
@@ -32,4 +32,5 @@
*/
public abstract class GraphicalElementImpl extends BPMNElementImpl implements GraphicalElement
{
+ private static final long serialVersionUID = 1L;
}
\ No newline at end of file
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ReceiveTaskImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ReceiveTaskImpl.java 2008-07-26 09:43:04 UTC (rev 1733)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ReceiveTaskImpl.java 2008-07-27 08:13:58 UTC (rev 1734)
@@ -114,7 +114,7 @@
public ExecutionHandler getExecutionHandler()
{
final Task task = this;
- ExecutionHandler handler = executionHandler;
+ ExecutionHandler handler = super.getExecutionHandler();
if (handler == null)
{
handler = new ExecutionHandler()
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SendTaskImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SendTaskImpl.java 2008-07-26 09:43:04 UTC (rev 1733)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SendTaskImpl.java 2008-07-27 08:13:58 UTC (rev 1734)
@@ -31,7 +31,6 @@
import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.Property;
import org.jboss.bpm.model.SendTask;
-import org.jboss.bpm.model.Task;
import org.jboss.bpm.runtime.ExecutionContext;
import org.jboss.bpm.runtime.ExecutionHandler;
import org.jboss.bpm.runtime.Token;
@@ -82,8 +81,7 @@
@Override
public ExecutionHandler getExecutionHandler()
{
- final Task task = this;
- ExecutionHandler handler = executionHandler;
+ ExecutionHandler handler = super.getExecutionHandler();
if (handler == null)
{
handler = new ExecutionHandler()
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SubProcessImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SubProcessImpl.java 2008-07-26 09:43:04 UTC (rev 1733)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SubProcessImpl.java 2008-07-27 08:13:58 UTC (rev 1734)
@@ -23,17 +23,10 @@
//$Id$
-import org.jboss.bpm.NotImplementedException;
-import org.jboss.bpm.model.Flow;
import org.jboss.bpm.model.FlowObject;
import org.jboss.bpm.model.Signal;
import org.jboss.bpm.model.SubProcess;
-import org.jboss.bpm.runtime.ExecutionHandler;
-import org.jboss.bpm.runtime.FlowHandler;
-import org.jboss.bpm.runtime.FlowScheduler;
import org.jboss.bpm.runtime.SignalHandler;
-import org.jboss.bpm.runtime.Token;
-import org.jboss.bpm.runtime.FlowScheduler.Tuple;
/**
* A Sub-Process is Process that is included within another Process.
@@ -41,13 +34,9 @@
* @author thomas.diesler(a)jboss.com
* @since 08-Jul-2008
*/
-public class SubProcessImpl extends ActivityImpl implements SubProcess, HandlerSetterSupport, SingleInFlowSetterSupport, SingleOutFlowSetterSupport
+public class SubProcessImpl extends ActivityImpl implements SubProcess, SingleInFlowSetterSupport, SingleOutFlowSetterSupport
{
- private Flow inFlow;
- private Flow outFlow;
- private ExecutionHandler executionHandler;
- private FlowHandler flowHandler;
- private SignalHandler signalHandler;
+ private static final long serialVersionUID = 1L;
public SubProcessImpl(String name)
{
@@ -59,72 +48,9 @@
return ActivityType.SubProcess;
}
- public Flow getInFlow()
- {
- return inFlow;
- }
-
- public void setInFlow(Flow inFlow)
- {
- this.inFlow = inFlow;
- }
-
- public Flow getOutFlow()
- {
- return outFlow;
- }
-
- public void setOutFlow(Flow flow)
- {
- this.outFlow = flow;
- }
-
- public ExecutionHandler getExecutionHandler()
- {
- ExecutionHandler handler = executionHandler;
- if (handler == null)
- {
- handler = new ExecutionHandler()
- {
- public void execute(Token token)
- {
- throw new NotImplementedException();
- }
- };
- }
- return handler;
- }
-
- public void setExecutionHandler(ExecutionHandler executionHandler)
- {
- this.executionHandler = executionHandler;
- }
-
- public FlowHandler getFlowHandler()
- {
- FlowHandler handler = flowHandler;
- if (handler == null)
- {
- handler = new FlowHandler()
- {
- public void execute(FlowScheduler scheduler, Token token)
- {
- Tuple tuple = new Tuple(outFlow, token);
- scheduler.scheduleTuple(tuple);
- }
- };
- }
- return handler;
- }
-
- public void setFlowHandler(FlowHandler flowHandler)
- {
- this.flowHandler = flowHandler;
- }
-
public SignalHandler getSignalHandler()
{
- SignalHandler handler = signalHandler;
+ SignalHandler handler = super.getSignalHandler();
if (handler == null)
{
final FlowObject subproc = this;
@@ -144,11 +70,6 @@
return handler;
}
- public void setSignalHandler(SignalHandler signalHandler)
- {
- this.signalHandler = signalHandler;
- }
-
public String toString()
{
return "SubProcess[" + getName() + "]";
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskImpl.java 2008-07-26 09:43:04 UTC (rev 1733)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskImpl.java 2008-07-27 08:13:58 UTC (rev 1734)
@@ -21,17 +21,9 @@
*/
package org.jboss.bpm.model.internal;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.bpm.model.Flow;
import org.jboss.bpm.model.Signal;
import org.jboss.bpm.model.Task;
-import org.jboss.bpm.runtime.ExecutionHandler;
-import org.jboss.bpm.runtime.FlowHandler;
-import org.jboss.bpm.runtime.FlowScheduler;
import org.jboss.bpm.runtime.SignalHandler;
-import org.jboss.bpm.runtime.Token;
-import org.jboss.bpm.runtime.FlowScheduler.Tuple;
//$Id$
@@ -44,18 +36,8 @@
* @author thomas.diesler(a)jboss.com
* @since 08-Jul-2008
*/
-public abstract class TaskImpl extends ActivityImpl implements Task, HandlerSetterSupport, SingleInFlowSetterSupport, SingleOutFlowSetterSupport
+public abstract class TaskImpl extends ActivityImpl implements Task
{
- // provide logging
- private static final Log log = LogFactory.getLog(TaskImpl.class);
-
- protected ExecutionHandler executionHandler;
-
- private Flow inFlow;
- private Flow outFlow;
- private FlowHandler flowHandler;
- private SignalHandler signalHandler;
-
public TaskImpl(String name)
{
super(name);
@@ -68,78 +50,9 @@
public abstract TaskType getTaskType();
- /**
- * Get the out flow
- */
- public Flow getInFlow()
- {
- return inFlow;
- }
-
- /**
- * Set the in flow
- */
- public void setInFlow(Flow inFlow)
- {
- this.inFlow = inFlow;
- }
-
- public Flow getOutFlow()
- {
- return outFlow;
- }
-
- public void setOutFlow(Flow flow)
- {
- this.outFlow = flow;
- }
-
- public ExecutionHandler getExecutionHandler()
- {
- ExecutionHandler handler = executionHandler;
- if (handler == null)
- {
- handler = new ExecutionHandler()
- {
- public void execute(Token token)
- {
- log.debug("Nothing to do in task: " + getName());
- }
- };
- }
- return handler;
- }
-
- public void setExecutionHandler(ExecutionHandler executionHandler)
- {
- this.executionHandler = executionHandler;
- }
-
- public FlowHandler getFlowHandler()
- {
- FlowHandler handler = flowHandler;
- if (handler == null)
- {
- handler = new FlowHandler()
- {
- public void execute(FlowScheduler scheduler, Token token)
- {
- Tuple tuple = new Tuple(outFlow, token);
- scheduler.scheduleTuple(tuple);
- }
- };
- }
- return handler;
- }
-
- public void setFlowHandler(FlowHandler flowHandler)
- {
- this.flowHandler = flowHandler;
- }
-
public SignalHandler getSignalHandler()
{
- SignalHandler handler = signalHandler;
+ SignalHandler handler = super.getSignalHandler();
if (handler == null)
{
final Task task = this;
@@ -159,11 +72,6 @@
return handler;
}
- public void setSignalHandler(SignalHandler signalHandler)
- {
- this.signalHandler = signalHandler;
- }
-
public String toString()
{
return "Task[" + getName() + "]";
Added: jbossbpm/spec/trunk/modules/ri/src/test/java/org/jboss/bpm/expression/MvelExpressionTest.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/test/java/org/jboss/bpm/expression/MvelExpressionTest.java (rev 0)
+++ jbossbpm/spec/trunk/modules/ri/src/test/java/org/jboss/bpm/expression/MvelExpressionTest.java 2008-07-27 08:13:58 UTC (rev 1734)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.expression;
+
+// $Id$
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.bpm.runtime.BasicAttachments;
+import org.jboss.bpm.runtime.Attachments.Key;
+import org.mvel.MVEL;
+
+import junit.framework.TestCase;
+
+/**
+ * Test MVEL access to Attachments
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public class MvelExpressionTest extends TestCase
+{
+ public void testBasicAttachments() throws Exception
+ {
+ BasicAttachments att = new BasicAttachments();
+ att.addAttachment("Name", "Kermit");
+ att.addAttachment("From", "MUC");
+ att.addAttachment("To", "NYC");
+ att.addAttachment("Date", "26-Jul-2008");
+ att.addAttachment("Seats", "2");
+
+ Map<String, Object> vars = new HashMap<String, Object>();
+ for (Key key : att.getAttachmentKeys())
+ {
+ String name = key.getNamePart();
+ Object value = att.getAttachment(name);
+ vars.put(name, value);
+ }
+
+ assertEquals("Kermit", MVEL.eval("Name", vars));
+ assertEquals("MUC", MVEL.eval("From", vars));
+ assertEquals("NYC", MVEL.eval("To", vars));
+ assertEquals("26-Jul-2008", MVEL.eval("Date", vars));
+ assertEquals("2", MVEL.eval("Seats", vars));
+
+ assertTrue((Boolean)MVEL.eval("Name != null && Seats > 0", vars));
+ }
+}
Property changes on: jbossbpm/spec/trunk/modules/ri/src/test/java/org/jboss/bpm/expression/MvelExpressionTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbossbpm/spec/trunk/modules/testsuite/pom.xml
===================================================================
--- jbossbpm/spec/trunk/modules/testsuite/pom.xml 2008-07-26 09:43:04 UTC (rev 1733)
+++ jbossbpm/spec/trunk/modules/testsuite/pom.xml 2008-07-27 08:13:58 UTC (rev 1734)
@@ -55,16 +55,6 @@
<artifactId>servlet-api</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <scope>test</scope>
- </dependency>
<!-- Runtime Dependencies -->
<dependency>
Modified: jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java
===================================================================
--- jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java 2008-07-26 09:43:04 UTC (rev 1733)
+++ jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java 2008-07-27 08:13:58 UTC (rev 1734)
@@ -109,7 +109,7 @@
addPropertyInput("Seats", null).
addOutputSet().
addPropertyOutput("isReqDataValid", null).
- addIORule("isReqDataValid == true if ....", ExpressionLanguage.MVEL).
+ addIORule("Name != null && From != null && To != null && Date != null && Seats > 0", ExpressionLanguage.MVEL).
addSequenceFlow("ValidateGateway");
// Build the Validate Gateway
Modified: jbossbpm/spec/trunk/pom.xml
===================================================================
--- jbossbpm/spec/trunk/pom.xml 2008-07-26 09:43:04 UTC (rev 1733)
+++ jbossbpm/spec/trunk/pom.xml 2008-07-27 08:13:58 UTC (rev 1734)
@@ -41,6 +41,7 @@
<javax.servlet.version>2.5</javax.servlet.version>
<jboss.microcontainer.version>2.0.0.Beta15</jboss.microcontainer.version>
<jboss.jbpm3.version>3.2.4-SNAPSHOT</jboss.jbpm3.version>
+ <mvel.version>1.3.7-java1.5</mvel.version>
</properties>
<!-- DependencyManagement -->
@@ -67,6 +68,11 @@
<version>${jboss.microcontainer.version}</version>
</dependency>
<dependency>
+ <groupId>org.mvel</groupId>
+ <artifactId>mvel</artifactId>
+ <version>${mvel.version}</version>
+ </dependency>
+ <dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${javax.servlet.version}</version>
@@ -74,6 +80,21 @@
</dependencies>
</dependencyManagement>
+ <!-- Dependencies -->
+ <dependencies>
+ <!-- Test Dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
<!-- DistributionManagement -->
<distributionManagement>
<!--
17 years, 9 months
JBoss JBPM SVN: r1732 - in jbossbpm/spec/trunk/modules: ri/src/main/java/org/jboss/bpm/model/internal and 1 other directories.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-07-25 13:03:26 -0400 (Fri, 25 Jul 2008)
New Revision: 1732
Added:
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ActivityBuilder.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/PropertySupport.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityBuilderImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/InputSetImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MutablePropertySupport.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/OutputSetImpl.java
Modified:
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Expression.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/InputSet.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Message.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/OutputSet.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/TaskBuilder.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExclusiveGatewayImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExpressionImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SubProcessImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskBuilderImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskImpl.java
jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java
Log:
More Activity impl
Added: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ActivityBuilder.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ActivityBuilder.java (rev 0)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ActivityBuilder.java 2008-07-25 17:03:26 UTC (rev 1732)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.model;
+
+import org.jboss.bpm.model.Expression.ExpressionLanguage;
+
+//$Id$
+
+/**
+ * The ActivityBuilder can be used to build an {@link Activity} dynamically.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public interface ActivityBuilder extends ProcessBuilder
+{
+ /**
+ * Add an {@link InputSet}
+ */
+ ActivityBuilder addInputSet();
+
+ /**
+ * Add an {@link Property} Input
+ */
+ ActivityBuilder addPropertyInput(String name, String value);
+
+ /**
+ * Add an {@link OutputSet}
+ */
+ ActivityBuilder addOutputSet();
+
+ /**
+ * Add an {@link Property} Output
+ */
+ ActivityBuilder addPropertyOutput(String name, String value);
+
+ /**
+ * Add an IORule @{link Expression}
+ */
+ ActivityBuilder addIORule(String body, ExpressionLanguage lang);
+}
\ No newline at end of file
Property changes on: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ActivityBuilder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Expression.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Expression.java 2008-07-25 13:51:28 UTC (rev 1731)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Expression.java 2008-07-25 17:03:26 UTC (rev 1732)
@@ -32,6 +32,11 @@
*/
public interface Expression extends SupportingElement
{
+ public enum ExpressionLanguage
+ {
+ MVEL, String
+ }
+
/**
* An ExpressionBody MUST be entered to provide the text of the expression, which
* will be written in the language defined by the ExpressionLanguage attribute.
@@ -43,6 +48,6 @@
* The value of the ExpressionLanguage should follow the naming conventions for the
* version of the specified language.
*/
- String getExpressionLanguage();
+ ExpressionLanguage getExpressionLanguage();
}
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/InputSet.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/InputSet.java 2008-07-25 13:51:28 UTC (rev 1731)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/InputSet.java 2008-07-25 17:03:26 UTC (rev 1732)
@@ -46,5 +46,5 @@
* combination of ArtifactInputs and PropertyInputs, there MUST be at least one
* item defined for the InputSet.
*/
- List<Property> getPropertyInputs();
+ List<Property> getProperties();
}
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Message.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Message.java 2008-07-25 13:51:28 UTC (rev 1731)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Message.java 2008-07-25 17:03:26 UTC (rev 1732)
@@ -23,6 +23,7 @@
import java.util.List;
+
//$Id$
/**
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/OutputSet.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/OutputSet.java 2008-07-25 13:51:28 UTC (rev 1731)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/OutputSet.java 2008-07-25 17:03:26 UTC (rev 1732)
@@ -46,5 +46,5 @@
* combination of ArtifactInputs and PropertyInputs, there MUST be at least one
* item defined for the InputSet.
*/
- List<Property> getPropertyOutputs();
+ List<Property> getProperties();
}
Added: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/PropertySupport.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/PropertySupport.java (rev 0)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/PropertySupport.java 2008-07-25 17:03:26 UTC (rev 1732)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.model;
+
+//$Id$
+
+import java.util.List;
+
+
+/**
+ * Property support
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 21-Jul-2008
+ */
+public interface PropertySupport
+{
+ /**
+ * Get a Property with a given name.
+ */
+ Property getProperty(String name);
+
+ /**
+ * Multiple Properties MAY entered for the Message.
+ */
+ List<Property> getProperties();
+
+ /**
+ * Get the list of property names
+ */
+ List<String> getPropertyNames();
+}
\ No newline at end of file
Property changes on: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/PropertySupport.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/TaskBuilder.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/TaskBuilder.java 2008-07-25 13:51:28 UTC (rev 1731)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/TaskBuilder.java 2008-07-25 17:03:26 UTC (rev 1732)
@@ -30,7 +30,7 @@
* @author thomas.diesler(a)jboss.com
* @since 08-Jul-2008
*/
-public interface TaskBuilder extends ProcessBuilder
+public interface TaskBuilder extends ActivityBuilder
{
TaskBuilder addMessageRef(String name);
Added: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityBuilderImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityBuilderImpl.java (rev 0)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityBuilderImpl.java 2008-07-25 17:03:26 UTC (rev 1732)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.model.internal;
+
+//$Id$
+
+import org.jboss.bpm.model.Activity;
+import org.jboss.bpm.model.ActivityBuilder;
+import org.jboss.bpm.model.Property;
+import org.jboss.bpm.model.Expression.ExpressionLanguage;
+
+/**
+ * The ActivityBuilder can be used to build an {@link Activity} dynamically.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public class ActivityBuilderImpl extends ProcessBuilderImpl implements ActivityBuilder
+{
+ private InputSetImpl inputSet;
+ private OutputSetImpl outputSet;
+
+ public ActivityBuilderImpl(ProcessImpl proc, FlowObjectImpl flowObject)
+ {
+ super(proc, flowObject);
+ }
+
+ public ActivityBuilder addInputSet()
+ {
+ inputSet = new InputSetImpl();
+ getActivity().addInputSet(inputSet);
+ return this;
+ }
+
+ public ActivityBuilder addPropertyInput(String name, String value)
+ {
+ Property prop = new PropertyImpl(name, new ExpressionImpl(value));
+ inputSet.addProperty(prop);
+ return this;
+ }
+
+ public ActivityBuilder addOutputSet()
+ {
+ outputSet = new OutputSetImpl();
+ getActivity().addOutputSet(outputSet);
+ return this;
+ }
+
+ public ActivityBuilder addPropertyOutput(String name, String value)
+ {
+ Property prop = new PropertyImpl(name, new ExpressionImpl(value));
+ outputSet.addProperty(prop);
+ return this;
+ }
+
+ public ActivityBuilder addIORule(String body, ExpressionLanguage lang)
+ {
+ ExpressionImpl expr = new ExpressionImpl(body, lang);
+ getActivity().addIORule(expr);
+ return this;
+ }
+
+ private ActivityImpl getActivity()
+ {
+ if (flowObject instanceof Activity == false)
+ throw new IllegalStateException("Last added flow object is not a Activity");
+ return (ActivityImpl)flowObject;
+ }
+}
\ No newline at end of file
Property changes on: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityBuilderImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityImpl.java 2008-07-25 13:51:28 UTC (rev 1731)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ActivityImpl.java 2008-07-25 17:03:26 UTC (rev 1732)
@@ -23,20 +23,35 @@
//$Id$
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.bpm.InvalidProcessException;
+import org.jboss.bpm.NotImplementedException;
import org.jboss.bpm.model.Activity;
+import org.jboss.bpm.model.Expression;
+import org.jboss.bpm.model.InputSet;
+import org.jboss.bpm.model.OutputSet;
+import org.jboss.bpm.model.Process;
+import org.jboss.bpm.model.Property;
/**
- * An activity is a generic term for work that a company or organization performs via business processes.
- * An activity can be atomic or non-atomic (compound).
- * The types of activities that are a part of a Process Model are: Process, Sub-Process, and Task.
+ * An activity is a generic term for work that a company or organization performs via business processes. An activity
+ * can be atomic or non-atomic (compound). The types of activities that are a part of a Process Model are: Process,
+ * Sub-Process, and Task.
*
* @author thomas.diesler(a)jboss.com
* @since 08-Jul-2008
*/
-public abstract class ActivityImpl extends FlowObjectImpl implements Activity
+public abstract class ActivityImpl extends FlowObjectImpl implements Activity, MutablePropertySupport
{
private String name;
-
+ private List<InputSet> inputSets = new ArrayList<InputSet>();
+ private List<OutputSet> outputSets = new ArrayList<OutputSet>();
+ private List<Expression> ioRules = new ArrayList<Expression>();
+ private List<Property> props = new ArrayList<Property>();
+
public ActivityImpl(String name)
{
this.name = name;
@@ -46,9 +61,119 @@
{
return name;
}
-
+
public void setName(String name)
{
this.name = name;
}
+
+ public int getStartQuantity()
+ {
+ throw new NotImplementedException();
+ }
+
+ public int getCompletionQuantity()
+ {
+ throw new NotImplementedException();
+ }
+
+ public List<Expression> getIORules()
+ {
+ return Collections.unmodifiableList(ioRules);
+ }
+
+ public void addIORule(Expression expr)
+ {
+ ioRules.add(expr);
+ }
+
+ public List<InputSet> getInputSets()
+ {
+ return Collections.unmodifiableList(inputSets);
+ }
+
+ public void addInputSet(InputSet inputSet)
+ {
+ inputSets.add(inputSet);
+ }
+
+ public List<OutputSet> getOutputSets()
+ {
+ return Collections.unmodifiableList(outputSets);
+ }
+
+ public void addOutputSet(OutputSet outputSet)
+ {
+ outputSets.add(outputSet);
+ }
+
+ public LoopType getLoopType()
+ {
+ throw new NotImplementedException();
+ }
+
+ public List<String> getPerformers()
+ {
+ throw new NotImplementedException();
+ }
+
+ public Property getProperty(String name)
+ {
+ for (Property prop : props)
+ {
+ if (prop.getName().equals(name))
+ return prop;
+ }
+ return null;
+ }
+
+ public List<Property> getProperties()
+ {
+ return Collections.unmodifiableList(props);
+ }
+
+ public List<String> getPropertyNames()
+ {
+ List<String> names = new ArrayList<String>();
+ for (Property prop : props)
+ {
+ names.add(prop.getName());
+ }
+ return names;
+ }
+
+ public void addProperty(Property prop)
+ {
+ props.add(prop);
+ }
+
+ @Override
+ protected void initialize(Process proc)
+ {
+ super.initialize(proc);
+
+ // Validate InputSets
+ for (InputSet inSet : inputSets)
+ {
+ int artSize = inSet.getArtifactInputs().size();
+ int propSize = inSet.getProperties().size();
+ if (artSize == 0 && propSize == 0)
+ {
+ throw new InvalidProcessException(
+ "For the combination of ArtifactInputs and PropertyInputs, there MUST be at least one item defined for the InputSet");
+ }
+ }
+
+ // Validate OutputSets
+ for (OutputSet outSet : outputSets)
+ {
+ int artSize = outSet.getArtifactOutputs().size();
+ int propSize = outSet.getProperties().size();
+ if (artSize == 0 && propSize == 0)
+ {
+ throw new InvalidProcessException(
+ "For the combination of ArtifactOutputs and PropertyOututs, there MUST be at least one item defined for the OutputSet");
+ }
+ }
+ }
}
\ No newline at end of file
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExclusiveGatewayImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExclusiveGatewayImpl.java 2008-07-25 13:51:28 UTC (rev 1731)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExclusiveGatewayImpl.java 2008-07-25 17:03:26 UTC (rev 1732)
@@ -23,11 +23,7 @@
//$Id$
-import java.util.List;
-
-import org.jboss.bpm.NotImplementedException;
import org.jboss.bpm.model.ExclusiveGateway;
-import org.jboss.bpm.model.Gate;
/**
* A point in the workflow process where, based on a decision or workflow control data, one of several branches is chosen.
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExpressionImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExpressionImpl.java 2008-07-25 13:51:28 UTC (rev 1731)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ExpressionImpl.java 2008-07-25 17:03:26 UTC (rev 1732)
@@ -23,7 +23,6 @@
//$Id$
-import org.jboss.bpm.NotImplementedException;
import org.jboss.bpm.model.Expression;
/**
@@ -36,19 +35,26 @@
public class ExpressionImpl extends SupportingElementImpl implements Expression
{
private String body;
+ private ExpressionLanguage lang = ExpressionLanguage.String;
public ExpressionImpl(String body)
{
this.body = body;
}
+ public ExpressionImpl(String body, ExpressionLanguage lang)
+ {
+ this.body = body;
+ this.lang = lang;
+ }
+
public String getExpressionBody()
{
return body;
}
- public String getExpressionLanguage()
+ public ExpressionLanguage getExpressionLanguage()
{
- throw new NotImplementedException();
+ return lang;
}
}
Added: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/InputSetImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/InputSetImpl.java (rev 0)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/InputSetImpl.java 2008-07-25 17:03:26 UTC (rev 1732)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.model.internal;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.bpm.NotImplementedException;
+import org.jboss.bpm.model.ArtifactInput;
+import org.jboss.bpm.model.ArtifactOutput;
+import org.jboss.bpm.model.InputSet;
+import org.jboss.bpm.model.Property;
+
+/**
+ * An InputSet, which is used in the definition of common attributes for Activities and for attributes of a Process
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public class InputSetImpl extends SupportingElementImpl implements InputSet, MutablePropertySupport
+{
+ private List<ArtifactInput> artInputs = new ArrayList<ArtifactInput>();
+ private List<Property> props = new ArrayList<Property>();
+
+ public List<ArtifactInput> getArtifactInputs()
+ {
+ return Collections.unmodifiableList(artInputs);
+ }
+
+ public void addArtifactInput(ArtifactInput artIn)
+ {
+ artInputs.add(artIn);
+ }
+
+ public Property getProperty(String name)
+ {
+ for (Property prop : props)
+ {
+ if (prop.getName().equals(name))
+ return prop;
+ }
+ return null;
+ }
+
+ public List<Property> getProperties()
+ {
+ return Collections.unmodifiableList(props);
+ }
+
+ public List<String> getPropertyNames()
+ {
+ List<String> names = new ArrayList<String>();
+ for (Property prop : props)
+ {
+ names.add(prop.getName());
+ }
+ return names;
+ }
+
+ public void addProperty(Property prop)
+ {
+ props.add(prop);
+ }
+}
Property changes on: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/InputSetImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageImpl.java 2008-07-25 13:51:28 UTC (rev 1731)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageImpl.java 2008-07-25 17:03:26 UTC (rev 1732)
@@ -29,6 +29,7 @@
import org.jboss.bpm.model.Message;
import org.jboss.bpm.model.Participant;
import org.jboss.bpm.model.Property;
+import org.jboss.bpm.model.PropertySupport;
//$Id$
@@ -40,7 +41,7 @@
* @author thomas.diesler(a)jboss.com
* @since 21-Jul-2008
*/
-public class MessageImpl extends SupportingElementImpl implements Message
+public class MessageImpl extends SupportingElementImpl implements Message, MutablePropertySupport
{
private String name;
private List<Property> props = new ArrayList<Property>();
@@ -58,9 +59,6 @@
return name;
}
- /**
- * Get a Property with a given name.
- */
public Property getProperty(String name)
{
for (Property prop : props)
@@ -70,18 +68,12 @@
}
return null;
}
-
- /**
- * Multiple Properties MAY entered for the Message.
- */
+
public List<Property> getProperties()
{
return Collections.unmodifiableList(props);
}
- /**
- * Get the list of property names
- */
public List<String> getPropertyNames()
{
List<String> names = new ArrayList<String>();
@@ -115,7 +107,7 @@
{
throw new NotImplementedException();
}
-
+
public String toString()
{
StringBuilder str = new StringBuilder("Message[name=" + name + ",props=");
@@ -124,4 +116,3 @@
return str.toString();
}
}
-
Added: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MutablePropertySupport.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MutablePropertySupport.java (rev 0)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MutablePropertySupport.java 2008-07-25 17:03:26 UTC (rev 1732)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.model.internal;
+
+import org.jboss.bpm.model.Property;
+import org.jboss.bpm.model.PropertySupport;
+
+//$Id$
+
+/**
+ * Mutable property support
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 21-Jul-2008
+ */
+public interface MutablePropertySupport extends PropertySupport
+{
+ /**
+ * Add a property
+ */
+ void addProperty(Property prop);
+}
\ No newline at end of file
Property changes on: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MutablePropertySupport.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/OutputSetImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/OutputSetImpl.java (rev 0)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/OutputSetImpl.java 2008-07-25 17:03:26 UTC (rev 1732)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.model.internal;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.bpm.NotImplementedException;
+import org.jboss.bpm.model.ArtifactOutput;
+import org.jboss.bpm.model.OutputSet;
+import org.jboss.bpm.model.Property;
+
+/**
+ * An OuputSet, which is used in the definition of common attributes for Activities and for attributes of a Process
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public class OutputSetImpl extends SupportingElementImpl implements OutputSet, MutablePropertySupport
+{
+ private List<ArtifactOutput> artOutputs = new ArrayList<ArtifactOutput>();
+ private List<Property> props = new ArrayList<Property>();
+
+ public List<ArtifactOutput> getArtifactOutputs()
+ {
+ return Collections.unmodifiableList(artOutputs);
+ }
+
+ public void addArtifactOutput(ArtifactOutput artOut)
+ {
+ artOutputs.add(artOut);
+ }
+
+ public Property getProperty(String name)
+ {
+ for (Property prop : props)
+ {
+ if (prop.getName().equals(name))
+ return prop;
+ }
+ return null;
+ }
+
+ public List<Property> getProperties()
+ {
+ return Collections.unmodifiableList(props);
+ }
+
+ public List<String> getPropertyNames()
+ {
+ List<String> names = new ArrayList<String>();
+ for (Property prop : props)
+ {
+ names.add(prop.getName());
+ }
+ return names;
+ }
+
+ public void addProperty(Property prop)
+ {
+ props.add(prop);
+ }
+}
Property changes on: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/OutputSetImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SubProcessImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SubProcessImpl.java 2008-07-25 13:51:28 UTC (rev 1731)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SubProcessImpl.java 2008-07-25 17:03:26 UTC (rev 1732)
@@ -23,15 +23,9 @@
//$Id$
-import java.util.List;
-
import org.jboss.bpm.NotImplementedException;
-import org.jboss.bpm.model.Expression;
import org.jboss.bpm.model.Flow;
import org.jboss.bpm.model.FlowObject;
-import org.jboss.bpm.model.InputSet;
-import org.jboss.bpm.model.OutputSet;
-import org.jboss.bpm.model.Property;
import org.jboss.bpm.model.Signal;
import org.jboss.bpm.model.SubProcess;
import org.jboss.bpm.runtime.ExecutionHandler;
@@ -65,46 +59,6 @@
return ActivityType.SubProcess;
}
- public int getCompletionQuantity()
- {
- throw new NotImplementedException();
- }
-
- public List<Expression> getIORules()
- {
- throw new NotImplementedException();
- }
-
- public List<InputSet> getInputSets()
- {
- throw new NotImplementedException();
- }
-
- public LoopType getLoopType()
- {
- throw new NotImplementedException();
- }
-
- public List<OutputSet> getOutputSets()
- {
- throw new NotImplementedException();
- }
-
- public List<String> getPerformers()
- {
- throw new NotImplementedException();
- }
-
- public List<Property> getProperties()
- {
- throw new NotImplementedException();
- }
-
- public int getStartQuantity()
- {
- throw new NotImplementedException();
- }
-
public Flow getInFlow()
{
return inFlow;
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskBuilderImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskBuilderImpl.java 2008-07-25 13:51:28 UTC (rev 1731)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskBuilderImpl.java 2008-07-25 17:03:26 UTC (rev 1732)
@@ -33,7 +33,7 @@
* @author thomas.diesler(a)jboss.com
* @since 08-Jul-2008
*/
-public class TaskBuilderImpl extends ProcessBuilderImpl implements TaskBuilder
+public class TaskBuilderImpl extends ActivityBuilderImpl implements TaskBuilder
{
private MessageImpl message;
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskImpl.java 2008-07-25 13:51:28 UTC (rev 1731)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskImpl.java 2008-07-25 17:03:26 UTC (rev 1732)
@@ -21,16 +21,9 @@
*/
package org.jboss.bpm.model.internal;
-import java.util.List;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.bpm.NotImplementedException;
-import org.jboss.bpm.model.Expression;
import org.jboss.bpm.model.Flow;
-import org.jboss.bpm.model.InputSet;
-import org.jboss.bpm.model.OutputSet;
-import org.jboss.bpm.model.Property;
import org.jboss.bpm.model.Signal;
import org.jboss.bpm.model.Task;
import org.jboss.bpm.runtime.ExecutionHandler;
@@ -75,46 +68,6 @@
public abstract TaskType getTaskType();
- public int getCompletionQuantity()
- {
- throw new NotImplementedException();
- }
-
- public List<Expression> getIORules()
- {
- throw new NotImplementedException();
- }
-
- public List<InputSet> getInputSets()
- {
- throw new NotImplementedException();
- }
-
- public LoopType getLoopType()
- {
- throw new NotImplementedException();
- }
-
- public List<OutputSet> getOutputSets()
- {
- throw new NotImplementedException();
- }
-
- public List<String> getPerformers()
- {
- throw new NotImplementedException();
- }
-
- public List<Property> getProperties()
- {
- throw new NotImplementedException();
- }
-
- public int getStartQuantity()
- {
- throw new NotImplementedException();
- }
-
/**
* Get the out flow
*/
Modified: jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java
===================================================================
--- jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java 2008-07-25 13:51:28 UTC (rev 1731)
+++ jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java 2008-07-25 17:03:26 UTC (rev 1732)
@@ -37,6 +37,7 @@
import org.jboss.bpm.model.ProcessBuilderFactory;
import org.jboss.bpm.model.Signal;
import org.jboss.bpm.model.TaskBuilder;
+import org.jboss.bpm.model.Expression.ExpressionLanguage;
import org.jboss.bpm.model.Gateway.GatewayType;
import org.jboss.bpm.model.Task.TaskType;
import org.jboss.bpm.test.DefaultEngineTestCase;
@@ -96,6 +97,19 @@
addMessageProperty("To", null, true).
addMessageProperty("Date", null, true).
addMessageProperty("Seats", null, true).
+ addSequenceFlow("ValidateTask");
+
+ // Build the Validate Task
+ taskBuilder = procBuilder.addTask("ValidateTask", TaskType.None);
+ taskBuilder.addInputSet().
+ addPropertyInput("Name", null).
+ addPropertyInput("From", null).
+ addPropertyInput("To", null).
+ addPropertyInput("Date", null).
+ addPropertyInput("Seats", null).
+ addOutputSet().
+ addPropertyOutput("isReqDataValid", null).
+ addIORule("isReqDataValid == true if ....", ExpressionLanguage.MVEL).
addSequenceFlow("ValidateGateway");
// Build the Validate Gateway
17 years, 9 months
JBoss JBPM SVN: r1731 - in jbossbpm/spec/trunk/modules: ri/src/main/java/org/jboss/bpm/model/internal and 1 other directories.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-07-25 09:51:28 -0400 (Fri, 25 Jul 2008)
New Revision: 1731
Added:
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SendTaskImpl.java
Modified:
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Message.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/MessageBuilder.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ProcessBuilder.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageBuilderImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ProcessBuilderImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ReceiveTaskImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskBuilderImpl.java
jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java
Log:
Add SendTaskImpl
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Message.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Message.java 2008-07-25 13:40:54 UTC (rev 1730)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Message.java 2008-07-25 13:51:28 UTC (rev 1731)
@@ -50,6 +50,11 @@
Property getProperty(String name);
/**
+ * Get the list of property names
+ */
+ List<String> getPropertyNames();
+
+ /**
* This defines the source of the Message.
*/
Participant getFromRef();
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/MessageBuilder.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/MessageBuilder.java 2008-07-25 13:40:54 UTC (rev 1730)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/MessageBuilder.java 2008-07-25 13:51:28 UTC (rev 1731)
@@ -39,12 +39,12 @@
/**
* Add a message property
*/
- MessageBuilder addMessageProperty(String name, String value);
+ MessageBuilder addProperty(String name, String value);
/**
* Add a message property
*/
- MessageBuilder addMessageProperty(String name, String value, boolean isCorrelation);
+ MessageBuilder addProperty(String name, String value, boolean isCorrelation);
/**
* Get the Message
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ProcessBuilder.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ProcessBuilder.java 2008-07-25 13:40:54 UTC (rev 1730)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ProcessBuilder.java 2008-07-25 13:51:28 UTC (rev 1731)
@@ -87,7 +87,7 @@
/**
* Add an {@link ExclusiveGateway} with a given name
*/
- ProcessBuilder addGateway(String name, GatewayType type);
+ GatewayBuilder addGateway(String name, GatewayType type);
/**
* Add an {@link ExecutionHandler} with a given Class
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageBuilderImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageBuilderImpl.java 2008-07-25 13:40:54 UTC (rev 1730)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageBuilderImpl.java 2008-07-25 13:51:28 UTC (rev 1731)
@@ -44,14 +44,14 @@
return this;
}
- public MessageBuilder addMessageProperty(String name, String value)
+ public MessageBuilder addProperty(String name, String value)
{
Property prop = new PropertyImpl(name, new ExpressionImpl(value));
message.addProperty(prop);
return this;
}
- public MessageBuilder addMessageProperty(String name, String value, boolean isCorrelation)
+ public MessageBuilder addProperty(String name, String value, boolean isCorrelation)
{
Property prop = new PropertyImpl(name, new ExpressionImpl(value), isCorrelation);
message.addProperty(prop);
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageImpl.java 2008-07-25 13:40:54 UTC (rev 1730)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/MessageImpl.java 2008-07-25 13:51:28 UTC (rev 1731)
@@ -80,6 +80,19 @@
}
/**
+ * Get the list of property names
+ */
+ public List<String> getPropertyNames()
+ {
+ List<String> names = new ArrayList<String>();
+ for (Property prop : props)
+ {
+ names.add(prop.getName());
+ }
+ return names;
+ }
+
+ /**
* Add a property
*/
public void addProperty(Property prop)
@@ -102,4 +115,13 @@
{
throw new NotImplementedException();
}
+
+ public String toString()
+ {
+ StringBuilder str = new StringBuilder("Message[name=" + name + ",props=");
+ str.append(getPropertyNames());
+ str.append("]");
+ return str.toString();
+ }
}
+
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ProcessBuilderImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ProcessBuilderImpl.java 2008-07-25 13:40:54 UTC (rev 1730)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ProcessBuilderImpl.java 2008-07-25 13:51:28 UTC (rev 1731)
@@ -152,6 +152,10 @@
{
flowObject = new ReceiveTaskImpl(name);
}
+ else if (type == TaskType.Send)
+ {
+ flowObject = new SendTaskImpl(name);
+ }
else
{
throw new NotImplementedException("Task type: " + type);
@@ -160,7 +164,7 @@
return new TaskBuilderImpl(proc, flowObject);
}
- public ProcessBuilder addGateway(String name, GatewayType type)
+ public GatewayBuilder addGateway(String name, GatewayType type)
{
if (GatewayType.Exclusive == type)
{
@@ -179,7 +183,7 @@
flowObject = new ComplexGatewayImpl(name);
}
addFlowObject();
- return this;
+ return new GatewayBuilderImpl(proc, flowObject);
}
public ProcessBuilder addExecutionHandler(Class<?> clazz)
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ReceiveTaskImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ReceiveTaskImpl.java 2008-07-25 13:40:54 UTC (rev 1730)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ReceiveTaskImpl.java 2008-07-25 13:51:28 UTC (rev 1731)
@@ -34,6 +34,7 @@
import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.Property;
import org.jboss.bpm.model.ReceiveTask;
+import org.jboss.bpm.model.Task;
import org.jboss.bpm.runtime.ExecutionContext;
import org.jboss.bpm.runtime.ExecutionHandler;
import org.jboss.bpm.runtime.MessageReceiver;
@@ -112,7 +113,7 @@
@Override
public ExecutionHandler getExecutionHandler()
{
- final ReceiveTask task = this;
+ final Task task = this;
ExecutionHandler handler = executionHandler;
if (handler == null)
{
Added: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SendTaskImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SendTaskImpl.java (rev 0)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SendTaskImpl.java 2008-07-25 13:51:28 UTC (rev 1731)
@@ -0,0 +1,129 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.model.internal;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.bpm.InvalidProcessException;
+import org.jboss.bpm.model.Expression;
+import org.jboss.bpm.model.Message;
+import org.jboss.bpm.model.MessageBuilder;
+import org.jboss.bpm.model.MessageBuilderFactory;
+import org.jboss.bpm.model.Process;
+import org.jboss.bpm.model.Property;
+import org.jboss.bpm.model.SendTask;
+import org.jboss.bpm.model.Task;
+import org.jboss.bpm.runtime.ExecutionContext;
+import org.jboss.bpm.runtime.ExecutionHandler;
+import org.jboss.bpm.runtime.Token;
+
+//$Id$
+
+/**
+ * Task that corresponds to the TaskType.None
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public class SendTaskImpl extends TaskImpl implements SendTask
+{
+ // provide logging
+ private static final Log log = LogFactory.getLog(SendTaskImpl.class);
+
+ // A Web service is the default technology
+ private Implementation implementation = Implementation.WebService;
+ private Message messageRef;
+
+ public SendTaskImpl(String name)
+ {
+ super(name);
+ }
+
+ @Override
+ public TaskType getTaskType()
+ {
+ return TaskType.Receive;
+ }
+
+ public Implementation getImplementation()
+ {
+ return implementation;
+ }
+
+ public Message getMessageRef()
+ {
+ return messageRef;
+ }
+
+ public void setMessageRef(Message message)
+ {
+ this.messageRef = message;
+ }
+
+ @Override
+ public ExecutionHandler getExecutionHandler()
+ {
+ final Task task = this;
+ ExecutionHandler handler = executionHandler;
+ if (handler == null)
+ {
+ handler = new ExecutionHandler()
+ {
+ public void execute(Token token)
+ {
+ MessageBuilderFactory factory = MessageBuilderFactory.newInstance();
+ MessageBuilder msgBuilder = factory.newMessageBuilder();
+ msgBuilder.newMessage(messageRef.getName());
+
+ // Copy the properties from the execution context
+ // to the send message
+ ExecutionContext exContext = token.getExecutionContext();
+ for (Property prop : messageRef.getProperties())
+ {
+ String key = prop.getName();
+ Object att = exContext.getAttachment(key);
+ if (att == null)
+ throw new IllegalStateException("Cannot obtain expression: " + key);
+ if (att instanceof Expression == false)
+ throw new IllegalStateException("Value is not an expression: " + att);
+
+ Expression value = (Expression)att;
+ msgBuilder.addProperty(key, value.getExpressionBody());
+ }
+
+ Message msg = msgBuilder.getMessage();
+ System.out.println(msg);
+ }
+ };
+ }
+ return handler;
+ }
+
+ @Override
+ protected void initialize(Process proc)
+ {
+ super.initialize(proc);
+
+ if (messageRef == null)
+ throw new InvalidProcessException("A Message for the MessageRef attribute MUST be entered");
+ }
+}
\ No newline at end of file
Property changes on: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/SendTaskImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskBuilderImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskBuilderImpl.java 2008-07-25 13:40:54 UTC (rev 1730)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/TaskBuilderImpl.java 2008-07-25 13:51:28 UTC (rev 1731)
@@ -49,6 +49,10 @@
{
((ReceiveTaskImpl)flowObject).setMessageRef(message);
}
+ else if (flowObject instanceof SendTaskImpl)
+ {
+ ((SendTaskImpl)flowObject).setMessageRef(message);
+ }
else
{
throw new IllegalStateException("Cannot add message to: " + flowObject);
Modified: jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java
===================================================================
--- jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java 2008-07-25 13:40:54 UTC (rev 1730)
+++ jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java 2008-07-25 13:51:28 UTC (rev 1731)
@@ -28,6 +28,7 @@
import org.jboss.bpm.client.ProcessManager;
import org.jboss.bpm.client.SignalListener;
import org.jboss.bpm.client.SignalManager;
+import org.jboss.bpm.model.GatewayBuilder;
import org.jboss.bpm.model.Message;
import org.jboss.bpm.model.MessageBuilder;
import org.jboss.bpm.model.MessageBuilderFactory;
@@ -36,6 +37,7 @@
import org.jboss.bpm.model.ProcessBuilderFactory;
import org.jboss.bpm.model.Signal;
import org.jboss.bpm.model.TaskBuilder;
+import org.jboss.bpm.model.Gateway.GatewayType;
import org.jboss.bpm.model.Task.TaskType;
import org.jboss.bpm.test.DefaultEngineTestCase;
@@ -84,18 +86,38 @@
// Create a Process through the ProcessBuilder
ProcessBuilder procBuilder = procFactory.newProcessBuilder();
- procBuilder.addProcess("Airticket").addStartEvent().addSequenceFlow("ReceiveReq");
+ procBuilder.addProcess("Airticket").addStartEvent().addSequenceFlow("ReceiveReqTask");
- TaskBuilder taskBuilder = procBuilder.addTask("ReceiveReq", TaskType.Receive);
+ // Build the ReceiveReq Task
+ TaskBuilder taskBuilder = procBuilder.addTask("ReceiveReqTask", TaskType.Receive);
taskBuilder.addMessageRef("ReqDataMsg").
addMessageProperty("Name", null, true).
addMessageProperty("From", null, true).
addMessageProperty("To", null, true).
addMessageProperty("Date", null, true).
addMessageProperty("Seats", null, true).
- addSequenceFlow("End");
+ addSequenceFlow("ValidateGateway");
- Process proc = procBuilder.addGateway("Validate", null).addEndEvent("End").getProcess();
+ // Build the Validate Gateway
+ GatewayBuilder gatewayBuilder = procBuilder.addGateway("ValidateGateway", GatewayType.Exclusive);
+ gatewayBuilder.addGate("CheckAvailabilityTask").addGate("SendInvalidTask");
+
+ // Build the CheckAvailability Task
+ taskBuilder = procBuilder.addTask("CheckAvailabilityTask", TaskType.None);
+ taskBuilder.addSequenceFlow("End");
+
+ // Build the SendInvalid Task
+ taskBuilder = procBuilder.addTask("SendInvalidTask", TaskType.Send);
+ taskBuilder.addMessageRef("InvalidDataMsg").
+ addMessageProperty("Name", null, true).
+ addMessageProperty("From", null, true).
+ addMessageProperty("To", null, true).
+ addMessageProperty("Date", null, true).
+ addMessageProperty("Seats", null, true).
+ addSequenceFlow("ReceiveReqTask");
+
+ // Add the EndEvent get the Process
+ Process proc = procBuilder.addEndEvent("End").getProcess();
// Register the Process with the ProcessManager
ProcessManager pm = ProcessManager.locateProcessManager();
@@ -105,14 +127,14 @@
MessageBuilder msgBuilder = msgFactory.newMessageBuilder();
Message msg = msgBuilder.newMessage("ReqDataMsg").
- addMessageProperty("Name", "Kermit").
- addMessageProperty("From", "MUC").
- addMessageProperty("To", "NYC").
- addMessageProperty("Date", "25-Jul-2008").
- addMessageProperty("Seats", "1").
+ addProperty("Name", "Kermit").
+ addProperty("From", "MUC").
+ addProperty("To", "NYC").
+ addProperty("Date", "25-Jul-2008").
+ addProperty("Seats", "1").
getMessage();
- proc.sendMessage("ReceiveReq", msg);
+ proc.sendMessage("ReceiveReqTask", msg);
proc.waitForEnd();
}
17 years, 9 months
JBoss JBPM SVN: r1730 - jbpm4/pvm/trunk.
by do-not-reply@jboss.org
Author: porcherg
Date: 2008-07-25 09:40:54 -0400 (Fri, 25 Jul 2008)
New Revision: 1730
Added:
jbpm4/pvm/trunk/assembly.xml
Modified:
jbpm4/pvm/trunk/pom.xml
Log:
work on pvm distrib generation: mvn clean package assembly:assembly
docbook generation and licence files are missing.
Added: jbpm4/pvm/trunk/assembly.xml
===================================================================
--- jbpm4/pvm/trunk/assembly.xml (rev 0)
+++ jbpm4/pvm/trunk/assembly.xml 2008-07-25 13:40:54 UTC (rev 1730)
@@ -0,0 +1,48 @@
+<assembly>
+ <id>package</id>
+ <formats>
+ <format>dir</format>
+ <format>zip</format>
+ <format>tar.gz</format>
+ </formats>
+ <includeBaseDirectory>true</includeBaseDirectory>
+ <moduleSets>
+ <moduleSet>
+ <includes>
+ <include>org.jboss.jbpm.pvm:pvm-core</include>
+ </includes>
+ <binaries>
+ <outputDirectory></outputDirectory>
+ <includeDependencies>true</includeDependencies>
+ <unpack>false</unpack>
+ <dependencySets>
+ <dependencySet>
+ <scope>test</scope>
+ <outputDirectory>lib</outputDirectory>
+ </dependencySet>
+ </dependencySets>
+ </binaries>
+ </moduleSet>
+ </moduleSets>
+ <fileSets>
+ <fileSet>
+ <directory>modules/core/target/apidocs</directory>
+ <outputDirectory>javadoc</outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>modules/core/src/main/java</directory>
+ <outputDirectory>src</outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>modules/core/src/main/resources</directory>
+ <outputDirectory>src</outputDirectory>
+ </fileSet>
+ <fileSet>
+ <directory>modules/core/src/test/java</directory>
+ <includes>
+ <include>org/jbpm/pvm/samples/**/*.*</include>
+ </includes>
+ <outputDirectory>examples</outputDirectory>
+ </fileSet>
+ </fileSets>
+</assembly>
\ No newline at end of file
Property changes on: jbpm4/pvm/trunk/assembly.xml
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: jbpm4/pvm/trunk/pom.xml
===================================================================
--- jbpm4/pvm/trunk/pom.xml 2008-07-25 13:32:48 UTC (rev 1729)
+++ jbpm4/pvm/trunk/pom.xml 2008-07-25 13:40:54 UTC (rev 1730)
@@ -153,9 +153,30 @@
<!-- Plugins -->
<build>
<plugins>
- <plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
</plugin>
+
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-2</version>
+ <configuration>
+ <ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
+ <appendAssemblyId>false</appendAssemblyId>
+ <descriptors>
+ <descriptor>assembly.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </plugin>
</plugins>
</build>
17 years, 9 months
JBoss JBPM SVN: r1729 - in jbpm4/pvm/trunk/modules/core: src/test/java/org/jbpm and 14 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-07-25 09:32:48 -0400 (Fri, 25 Jul 2008)
New Revision: 1729
Added:
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/CommandExecutorTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/CommandReceiverTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/EnterpriseTimerSessionTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/TimerTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom/
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/ExclusiveTestMessage.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/FailOnceTestMessage.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/FailingTestMessage.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/JobExecutorTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/JobExecutorTests.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/JobExecutorTimerSessionTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/TestMessage.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/TestTimer.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/cron/
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/msg/
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/msg/MemJobExecutor.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/msg/MemMessageService.java
jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/enterprise/
jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/jobexecutor/
jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/msg/
jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/msg/environment.cfg.xml
Removed:
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/db/
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/jobexecutor/
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/msg/
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/svc/memory/MemJobExecutor.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/svc/memory/MemMessageService.java
jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/enterprise/
jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/jobexecutor/
Modified:
jbpm4/pvm/trunk/modules/core/pom.xml
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/DbTests.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom/HappyActivity.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom/InsertPhraseCmd.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom/NoisyActivity.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom/Phrase.hbm.xml
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom/Phrase.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom/RemovePhraseCmd.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/cron/CronExpression.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/cron/CronTrigger.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/msg/MemMessageServiceTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/wire/ConcurrentWiringTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/wire/WireTests.java
jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/enterprise/custom/Phrase.hbm.xml
jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/jobexecutor/environment.cfg.xml
jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/jobexecutor/mappings.hbm.xml
Log:
reorganised test packages
Modified: jbpm4/pvm/trunk/modules/core/pom.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/pom.xml 2008-07-25 13:01:49 UTC (rev 1728)
+++ jbpm4/pvm/trunk/modules/core/pom.xml 2008-07-25 13:32:48 UTC (rev 1729)
@@ -158,16 +158,16 @@
<configuration>
<argLine>${surefire.jvm.args}</argLine>
<excludes>
- <exclude>org/jbpm/enterprise/CommandExecutorTest.java</exclude>
- <exclude>org/jbpm/enterprise/TimerTest.java</exclude>
- <exclude>org/jbpm/enterprise/EnterpriseTimerSessionTest.java</exclude>
- <exclude>org/jbpm/enterprise/CommandReceiverTest.java</exclude>
- <exclude>org/jbpm/jobexecutor/JobExecutorTimerSessionTest.java</exclude>
+ <exclude>org/jbpm/pvm/enterprise/CommandExecutorTest.java</exclude>
+ <exclude>org/jbpm/pvm/enterprise/TimerTest.java</exclude>
+ <exclude>org/jbpm/pvm/enterprise/EnterpriseTimerSessionTest.java</exclude>
+ <exclude>org/jbpm/pvm/enterprise/CommandReceiverTest.java</exclude>
+ <exclude>org/jbpm/pvm/jobexecutor/JobExecutorTimerSessionTest.java</exclude>
<exclude>org/jbpm/pvm/timer/TimerIntegrationTest.java</exclude>
- <exclude>org/jbpm/svc/jobexecutor/ContinuationTest.java</exclude>
<exclude>org/jbpm/pvm/samples/ex12/TimerTest.java</exclude>
<exclude>org/jbpm/pvm/samples/ex02/BasicProcessPersistenceTest.java</exclude>
<exclude>org/jbpm/pvm/samples/ex11/AsynchronousContinuationsTest.java</exclude>
+ <exclude>org/jbpm/svc/jobexecutor/ContinuationTest.java</exclude>
<exclude>org/jbpm/svc/hibernate/ExecutionTypeTest.java</exclude>
</excludes>
</configuration>
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/DbTests.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/DbTests.java 2008-07-25 13:01:49 UTC (rev 1728)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/DbTests.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -27,6 +27,7 @@
import org.jbpm.pvm.db.langext.DbLangExtTests;
import org.jbpm.pvm.db.model.DbModelTests;
import org.jbpm.pvm.db.svc.DbSvcTests;
+import org.jbpm.pvm.jobexecutor.JobExecutorTests;
/**
@@ -41,6 +42,7 @@
suite.addTest(DbLangExtTests.suite());
suite.addTest(DbModelTests.suite());
suite.addTest(DbSvcTests.suite());
+ suite.addTest(JobExecutorTests.suite());
//$JUnit-END$
return suite;
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/CommandExecutorTest.java (from rev 1726, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/CommandExecutorTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/CommandExecutorTest.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/CommandExecutorTest.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.enterprise;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBException;
+import javax.naming.InitialContext;
+
+import org.apache.cactus.ServletTestCase;
+
+import org.jbpm.pvm.enterprise.custom.InsertPhraseCmd;
+import org.jbpm.pvm.enterprise.custom.RemovePhraseCmd;
+import org.jbpm.pvm.internal.ejb.CommandExecutorSLSB;
+import org.jbpm.pvm.internal.ejb.LocalCommandExecutor;
+import org.jbpm.pvm.internal.ejb.LocalCommandExecutorHome;
+import org.jbpm.pvm.internal.log.Log;
+
+/**
+ * Server-side test for the {@linkplain CommandExecutorSLSB command executor}.
+ * The local interface is used.
+ *
+ * @author Tom Baeyens
+ * @author Alejandro Guizar
+ */
+public class CommandExecutorTest extends ServletTestCase {
+
+ private LocalCommandExecutor commandExecutor;
+
+ private static final Log log = Log.getLog(CommandExecutorTest.class.getName());
+
+ private static LocalCommandExecutorHome commandExecutorHome;
+
+ @Override
+ protected void setUp() throws Exception {
+ if (commandExecutorHome == null) {
+ // retrieve managed objects
+ InitialContext initialContext = new InitialContext();
+ try {
+ commandExecutorHome = (LocalCommandExecutorHome) initialContext.lookup("java:comp/env/ejb/LocalCommandExecutor");
+ } finally {
+ initialContext.close();
+ }
+ }
+ commandExecutor = commandExecutorHome.create();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ commandExecutor = null;
+ }
+
+ /**
+ * This scenario tests a command that completes with no incident.
+ * <h3>Preconditions</h3>
+ * The TEST_PHRASE table does not contain any row with the specified text.
+ * <h3>Behavior</h3>
+ * The {@link InsertPhraseCmd} command creates a row with the specified text.
+ * <h3>Postconditions</h3>
+ * A new row with the specified text exists in the table. The
+ * {@link RemovePhraseCmd} command removes the row, and the return value confirms
+ * it was there.
+ */
+ public void testHappyCommand() throws CreateException {
+ String text = "been there, done that";
+ commandExecutor.execute(new InsertPhraseCmd(text));
+ // verify phrase was inserted
+ assertTrue(commandExecutor.execute(new RemovePhraseCmd(text)));
+ }
+
+ /**
+ * This scenario tests a command that throws a checked exception inside the
+ * {@link InsertPhraseCmd#execute(org.jbpm.env.Environment) execute} method.
+ * <h3>Preconditions</h3>
+ * The TEST_PHRASE table does not contain any row with the specified text.
+ * <h3>Behavior</h3>
+ * The {@link InsertPhraseCmd} command creates a row with the specified text. The
+ * command is configured to throw a checked exception before completing.
+ * <h3>Postconditions</h3>
+ * The command executor throws an {@link EJBException} and rolls back the
+ * managed transaction. No row with the specified text exists in the database.
+ * The {@link RemovePhraseCmd} command return value confirms the row was not
+ * there.
+ */
+ public void testNoisyCommand() throws CreateException {
+ String text = "houston, we have a problem";
+ // insert phrase via command
+ try {
+ commandExecutor.execute(new InsertPhraseCmd(text, /* fail? */true));
+ fail("expected: " + EJBException.class.getSimpleName());
+ } catch (EJBException e) {
+ log.info("noisy command threw exception", e);
+ // verify phrase was NOT inserted
+ assertFalse(commandExecutor.execute(new RemovePhraseCmd(text)));
+ }
+ }
+}
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/CommandExecutorTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/CommandReceiverTest.java (from rev 1726, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/CommandReceiverTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/CommandReceiverTest.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/CommandReceiverTest.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -0,0 +1,178 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.enterprise;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.apache.cactus.ServletTestCase;
+
+import org.jbpm.pvm.enterprise.custom.InsertPhraseCmd;
+import org.jbpm.pvm.enterprise.custom.RemovePhraseCmd;
+import org.jbpm.pvm.internal.cmd.Command;
+import org.jbpm.pvm.internal.ejb.CommandReceiverMDB;
+
+/**
+ * Server-side test for the {@linkplain CommandReceiverMDB command receiver}.
+ *
+ * @author Alejandro Guizar
+ */
+public class CommandReceiverTest extends ServletTestCase {
+
+ private Connection jmsConnection;
+
+ private static final long TIMEOUT = 2000;
+
+ private static ConnectionFactory jmsConnectionFactory;
+ private static Destination commandQueue;
+
+ @Override
+ protected void setUp() throws Exception {
+ if (jmsConnectionFactory == null) {
+ // retrieve managed objects
+ Context initial = new InitialContext();
+ try {
+ jmsConnectionFactory = (ConnectionFactory) initial.lookup("java:comp/env/jms/CommandConnectionFactory");
+ commandQueue = (Destination) initial.lookup("java:comp/env/jms/CommandQueue");
+ } finally {
+ initial.close();
+ }
+ }
+ jmsConnection = jmsConnectionFactory.createConnection();
+ jmsConnection.start();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ if (jmsConnection != null) {
+ jmsConnection.stop();
+ jmsConnection.close();
+ jmsConnection = null;
+ }
+ }
+
+ /**
+ * This scenario tests a command message that completes with no incident.
+ * <h3>Preconditions</h3>
+ * The TEST_PHRASE table does not contain any row with the specified text.
+ * <h3>Behavior</h3>
+ * The {@link InsertPhraseCmd} command message creates a row with the specified
+ * text. Once the command completes, the command receiver sends the result to
+ * the reply queue.
+ * <h3>Postconditions</h3>
+ * A new row with the specified text exists in the table. The
+ * {@link RemovePhraseCmd} command message removes the row. The result sent to
+ * the reply queue confirms the row was there.
+ */
+ public void testHappyMessage() throws JMSException {
+ final String text = "been there, done that";
+ Session jmsSession = jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ try {
+ // send insert command
+ Command<Void> insertCommand = new InsertPhraseCmd(text, /* fail? */false);
+ Message insertMessage = jmsSession.createObjectMessage(insertCommand);
+ Destination replyTo = jmsSession.createTemporaryQueue();
+ insertMessage.setJMSReplyTo(replyTo);
+ MessageProducer producer = jmsSession.createProducer(commandQueue);
+ producer.send(insertMessage);
+
+ // receive insertion response
+ MessageConsumer insertConsumer = jmsSession.createConsumer(replyTo, "JMSCorrelationID = '" + insertMessage.getJMSMessageID() + "'");
+ ObjectMessage responseMessage = (ObjectMessage) insertConsumer.receive(TIMEOUT);
+ assertNull(responseMessage.getObject());
+
+ // send remove command
+ Command<Boolean> removeCommand = new RemovePhraseCmd(text);
+ Message removeMessage = jmsSession.createObjectMessage(removeCommand);
+ removeMessage.setJMSReplyTo(replyTo);
+ producer.send(removeMessage);
+
+ // receive removal response
+ MessageConsumer removeConsumer = jmsSession.createConsumer(replyTo, "JMSCorrelationID = '" + removeMessage.getJMSMessageID() + "'");
+ responseMessage = (ObjectMessage) removeConsumer.receive(TIMEOUT);
+ // verify phrase was inserted
+ assertTrue((Boolean) responseMessage.getObject());
+ } finally {
+ jmsSession.close();
+ }
+ }
+
+ /**
+ * This scenario tests a command message that throws a checked exception
+ * inside the {@link InsertPhraseCmd#execute(org.jbpm.env.Environment) execute}
+ * method.
+ * <h3>Preconditions</h3>
+ * The TEST_PHRASE table does not contain any row with the specified text.
+ * <h3>Behavior</h3>
+ * The {@link InsertPhraseCmd} command message creates a row with the specified
+ * text. The command is configured to throw a checked exception before
+ * completing. The exception prevents the command receiver from sending the
+ * result to the reply queue.
+ * <h3>Postconditions</h3>
+ * The command receiver rolls back the managed transaction and puts the
+ * insertion message back in the command queue. No row with the specified
+ * exists in the database. The {@link RemovePhraseCmd} command result sent to the
+ * reply queue confirms the row was not there.
+ */
+ public void testNoisyMessage() throws JMSException {
+ final String text = "houston, we have a problem";
+ // insert phrase via command
+ Session jmsSession = jmsConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ try {
+ // send insert command
+ Command<Void> insertCommand = new InsertPhraseCmd(text, /* fail? */true);
+ Message insertMessage = jmsSession.createObjectMessage(insertCommand);
+ Destination replyTo = jmsSession.createTemporaryQueue();
+ insertMessage.setJMSReplyTo(replyTo);
+ MessageProducer producer = jmsSession.createProducer(commandQueue);
+ producer.send(insertMessage);
+
+ // receive insertion response
+ MessageConsumer insertConsumer = jmsSession.createConsumer(replyTo, "JMSCorrelationID = '" + insertMessage.getJMSMessageID() + "'");
+ ObjectMessage insertResponse = (ObjectMessage) insertConsumer.receive(TIMEOUT);
+ assertNull(insertResponse);
+
+ // send remove command
+ Command<Boolean> removeCommand = new RemovePhraseCmd(text);
+ Message removeMessage = jmsSession.createObjectMessage(removeCommand);
+ removeMessage.setJMSReplyTo(replyTo);
+ producer.send(removeMessage);
+
+ // receive removal response
+ MessageConsumer removeConsumer = jmsSession.createConsumer(replyTo, "JMSCorrelationID = '" + removeMessage.getJMSMessageID() + "'");
+ ObjectMessage removeResponse = (ObjectMessage) removeConsumer.receive(TIMEOUT);
+ // verify phrase was NOT inserted
+ assertFalse((Boolean) removeResponse.getObject());
+ } finally {
+ jmsSession.close();
+ }
+ }
+}
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/CommandReceiverTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/EnterpriseTimerSessionTest.java (from rev 1726, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/EnterpriseTimerSessionTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/EnterpriseTimerSessionTest.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/EnterpriseTimerSessionTest.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -0,0 +1,166 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.enterprise;
+
+import java.util.Date;
+
+import javax.ejb.CreateException;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+
+import org.apache.cactus.ServletTestCase;
+import org.jbpm.pvm.Execution;
+import org.jbpm.pvm.Deployment;
+import org.jbpm.pvm.enterprise.custom.HappyActivity;
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.internal.cmd.Command;
+import org.jbpm.pvm.internal.cmd.DeployCmd;
+import org.jbpm.pvm.internal.cmd.StartExecutionCmd;
+import org.jbpm.pvm.internal.ejb.EnterpriseTimerSession;
+import org.jbpm.pvm.internal.ejb.LocalCommandExecutor;
+import org.jbpm.pvm.internal.ejb.LocalCommandExecutorHome;
+import org.jbpm.pvm.internal.job.TimerImpl;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.model.ProcessDefinition;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.pvm.session.DbSession;
+import org.jbpm.pvm.session.TimerSession;
+
+/**
+ * Server-side test for the enterprise
+ * {@linkplain EnterpriseTimerSession timerImpl session}.
+ *
+ * @author Alejandro Guizar
+ */
+public class EnterpriseTimerSessionTest extends ServletTestCase {
+
+ private LocalCommandExecutor commandExecutor;
+
+ private static final int TIMEOUT = 2000;
+
+ private static LocalCommandExecutorHome commandExecutorHome;
+
+ protected void setUp() throws Exception {
+ // lookup home in jndi
+ if (commandExecutorHome == null) {
+ Context initialContext = new InitialContext();
+ try {
+ commandExecutorHome = (LocalCommandExecutorHome) initialContext.lookup("java:comp/env/ejb/LocalCommandExecutor");
+ } finally {
+ initialContext.close();
+ }
+ }
+ // create local bean
+ commandExecutor = commandExecutorHome.create();
+ // deploy process
+ ProcessDefinition processDefinition = ProcessFactory.build(getName())
+ .timer(TIMEOUT + " milliseconds", null)
+ .event("timeout")
+ .listener(new ObjectDescriptor(HappyActivity.class))
+ .done();
+ commandExecutor.execute(new DeployCmd(new Deployment(processDefinition)));
+ }
+
+ protected void tearDown() throws Exception {
+ commandExecutor = null;
+ }
+
+ /**
+ * This scenario schedules a non-repeating timerImpl whose referenced activity
+ * completes with no incident.
+ * <h3>Preconditions</h3>
+ * The activity has not executed.
+ * <h3>Behavior</h3>
+ * The {@link ScheduleTimerCmd} command activates a timerImpl. After that, the test
+ * waits for the activity to execute. Upon timeout, the
+ * {@linkplain HappyActivity activity} notifies the test of its execution.
+ * <h3>Postconditions</h3>
+ * The activity executes on or after the timerImpl's due date.
+ */
+ public void testSchedule() throws CreateException {
+ // start an execution
+ Execution execution = commandExecutor.execute(new StartExecutionCmd("timers included", null, null));
+
+ /* TODO timers will have to be fetched with a call to the management service
+
+ Timer timer = execution.getTimers().iterator().next();
+
+ Date dueDate = timer.getDueDate();
+ Date executionDate = HappyActivity.waitFor();
+ assertTrue(dueDate.compareTo(executionDate) <= 0);
+ */
+ }
+
+ /**
+ * This scenario schedules a non-repeating timerImpl and immediately cancels it.
+ * <h3>Preconditions</h3>
+ * The activity has not executed.
+ * <h3>Behavior</h3>
+ * The {@link ScheduleTimerCmd} command activates a timerImpl, which is immediately
+ * disabled by the {@link CancelTimerCmd} command. After that, the test waits
+ * past the timerImpl's due date.
+ * <h3>Postconditions</h3>
+ * The activity does not execute, ever.
+ */
+ public void testCancel() throws CreateException {
+ // start an execution
+ commandExecutor.execute(new StartExecutionCmd("timers included", null, null));
+
+ Date executionDate = HappyActivity.waitFor(2 * TIMEOUT);
+ assertNull(executionDate);
+ }
+
+ static class ScheduleTimerCmd implements Command<Void> {
+
+ private final TimerImpl timer;
+
+ private static final long serialVersionUID = 1L;
+
+ ScheduleTimerCmd(TimerImpl timer) {
+ this.timer = timer;
+ }
+
+ public Void execute(Environment environment) throws Exception {
+ environment.get(DbSession.class).save(timer.getExecution());
+ environment.get(TimerSession.class).schedule(timer);
+ return null;
+ }
+ }
+
+ static class CancelTimerCmd implements Command<Void> {
+
+ private final long timerDbid;
+
+ private static final long serialVersionUID = 1L;
+
+ CancelTimerCmd(long timerDbid) {
+ this.timerDbid = timerDbid;
+ }
+
+ public Void execute(Environment environment) throws Exception {
+ TimerImpl timerImpl = environment.get(DbSession.class).get(TimerImpl.class, timerDbid);
+ environment.get(TimerSession.class).cancel(timerImpl);
+ return null;
+ }
+ }
+
+}
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/EnterpriseTimerSessionTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/TimerTest.java (from rev 1726, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/TimerTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/TimerTest.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/TimerTest.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -0,0 +1,253 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.enterprise;
+
+import java.util.Date;
+
+import javax.ejb.CreateException;
+import javax.naming.InitialContext;
+
+import org.apache.cactus.ServletTestCase;
+
+import org.jbpm.pvm.Deployment;
+import org.jbpm.pvm.enterprise.custom.HappyActivity;
+import org.jbpm.pvm.enterprise.custom.NoisyActivity;
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.internal.cmd.Command;
+import org.jbpm.pvm.internal.cmd.DeployCmd;
+import org.jbpm.pvm.internal.cmd.GetVariableCmd;
+import org.jbpm.pvm.internal.cmd.StartExecutionCmd;
+import org.jbpm.pvm.internal.ejb.LocalCommandExecutor;
+import org.jbpm.pvm.internal.ejb.LocalCommandExecutorHome;
+import org.jbpm.pvm.internal.ejb.LocalTimer;
+import org.jbpm.pvm.internal.ejb.LocalTimerHome;
+import org.jbpm.pvm.internal.ejb.TimerEB;
+import org.jbpm.pvm.internal.job.TimerImpl;
+import org.jbpm.pvm.internal.log.Log;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.model.ProcessDefinition;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.pvm.session.DbSession;
+
+/**
+ * Server-side test for the {@linkplain TimerEB timerImpl bean}. The local
+ * interface is used.
+ *
+ * @author Alejandro Guizar
+ */
+public class TimerTest extends ServletTestCase {
+
+ private ProcessDefinition processDefinition;
+ private ObjectDescriptor activityDescriptor = new ObjectDescriptor();
+
+ private LocalCommandExecutor commandExecutor;
+
+ private static final int TIMEOUT = 2000;
+ private static final int REPEAT = 1000;
+
+ private static final Log log = Log.getLog(TimerTest.class.getName());
+
+ private static LocalTimerHome timerHome;
+ private static LocalCommandExecutorHome commandExecutorHome;
+
+ protected void setUp() throws Exception {
+ // lookup homes in jndi
+ if (commandExecutorHome == null) {
+ InitialContext initialContext = new InitialContext();
+ try {
+ commandExecutorHome = (LocalCommandExecutorHome) initialContext.lookup("java:comp/env/ejb/LocalCommandExecutor");
+ timerHome = (LocalTimerHome) initialContext.lookup("java:comp/env/ejb/LocalTimer");
+ } finally {
+ initialContext.close();
+ }
+ }
+ // create local bean
+ commandExecutor = commandExecutorHome.create();
+ // define process
+ processDefinition = ProcessFactory.build(getName())
+ .event("timeout")
+ .listener(activityDescriptor)
+ .done();
+ }
+
+ protected void tearDown() throws Exception {
+ commandExecutor = null;
+ }
+
+ /**
+ * This scenario tests a non-repeating timerImpl whose referenced activity
+ * completes with no incident.
+ * <h3>Preconditions</h3>
+ * The activity has not executed.
+ * <h3>Behavior</h3>
+ * The {@link CreateTimerCmd} command subscribes a timerImpl bean to the EJB timerImpl
+ * service. After that, the test waits for the activity to execute. Upon
+ * timeout, the {@linkplain HappyActivity activity} notifies the test of its
+ * execution.
+ * <h3>Postconditions</h3>
+ * The activity executes on or after the timerImpl's due date.
+ */
+ public void testHappyTimer() throws CreateException {
+ activityDescriptor.setClassName(HappyActivity.class.getName());
+ commandExecutor.execute(new DeployCmd(new Deployment(processDefinition)));
+
+ ExecutionImpl execution = (ExecutionImpl) commandExecutor.execute(new StartExecutionCmd(processDefinition.getName(), null, null));
+
+ Date dueDate = new Date(System.currentTimeMillis() + TIMEOUT);
+ TimerImpl timerImpl = new TimerImpl();
+ timerImpl.setEventName("timeout");
+ timerImpl.setDueDate(dueDate);
+ timerImpl.setExecution(execution);
+ commandExecutor.execute(new CreateTimerCmd(timerImpl));
+
+ Date executionDate = HappyActivity.waitFor();
+ assertTrue(dueDate.compareTo(executionDate) <= 0);
+ }
+
+ /**
+ * This scenario tests a non-repeating timerImpl whose referenced activity throws
+ * a checked exception.
+ * <h3>Preconditions</h3>
+ * The activity has not executed.
+ * <h3>Behavior</h3>
+ * The {@link CreateTimerCmd} command subscribes a timerImpl bean to the EJB timerImpl
+ * service. After that, the test waits for the activity to execute. Upon
+ * timeout, the {@linkplain NoisyActivity activity} notifies the test of its
+ * execution, sets a variable and throws a checked exception.
+ * <h3>Postconditions</h3>
+ * The activity executes on or after the timerImpl's due date. The EJB timerImpl
+ * service rolls back the managed transaction. The variable is unset.
+ */
+ public void testNoisyTimer() throws CreateException {
+ activityDescriptor.setClassName(NoisyActivity.class.getName());
+ commandExecutor.execute(new DeployCmd(new Deployment(processDefinition)));
+
+ ExecutionImpl execution = (ExecutionImpl) commandExecutor.execute(new StartExecutionCmd(processDefinition.getName(), null, null));
+
+ Date dueDate = new Date(System.currentTimeMillis() + TIMEOUT);
+ TimerImpl timerImpl = new TimerImpl();
+ timerImpl.setEventName("timeout");
+ timerImpl.setDueDate(dueDate);
+ timerImpl.setExecution(execution);
+ commandExecutor.execute(new CreateTimerCmd(timerImpl));
+
+ Date executionDate = NoisyActivity.waitFor();
+ assertTrue(dueDate.compareTo(executionDate) <= 0);
+
+ Object variableValue = commandExecutor.execute(new GetVariableCmd(execution.getDbid(), "executionDate"));
+ assertNull(variableValue);
+ }
+
+ /**
+ * This scenario tests a repeating timerImpl whose referenced activity completes
+ * with no incident.
+ * <h3>Preconditions</h3>
+ * The activity has not executed.
+ * <h3>Behavior</h3>
+ * The {@link CreateTimerCmd} command subscribes a timerImpl bean to the EJB timerImpl
+ * service. After that, the test waits for the first execution of the
+ * activity, and then for the subsequent <em>n</em> executions of the
+ * activity. Upon each timeout, the {@linkplain HappyActivity activity}
+ * notifies the test of its execution.
+ * <h3>Postconditions</h3>
+ * The first execution of the activity occurs on or after the timerImpl's due
+ * date. The subsequent <em>n</em> executions of the activity occur on or
+ * after the timerImpl's repeat interval.
+ */
+ public void testCyclicTimer() throws CreateException {
+ activityDescriptor.setClassName(HappyActivity.class.getName());
+ commandExecutor.execute(new DeployCmd(new Deployment(processDefinition)));
+
+ ExecutionImpl execution = (ExecutionImpl) commandExecutor.execute(new StartExecutionCmd(processDefinition.getName(), null, null));
+
+ Date dueDate = new Date(System.currentTimeMillis() + TIMEOUT);
+ TimerImpl timerImpl = new TimerImpl();
+ timerImpl.setEventName("timeout");
+ timerImpl.setDueDate(dueDate);
+ timerImpl.setRepeat(REPEAT + " milliseconds");
+ timerImpl.setExecution(execution);
+ commandExecutor.execute(new CreateTimerCmd(timerImpl));
+
+ try {
+ Date executionTime = HappyActivity.waitFor();
+ assertTrue(dueDate.compareTo(executionTime) <= 0);
+
+ for (int i = 0; i < 5; i++) {
+ dueDate.setTime(dueDate.getTime() + REPEAT);
+ log.info("next execution due " + TimerImpl.formatDueDate(dueDate));
+ executionTime = HappyActivity.waitFor();
+ assertTrue(dueDate.compareTo(executionTime) <= 0);
+ }
+ } finally {
+ commandExecutor.execute(new CancelTimerCmd(timerImpl.getDbid()));
+ }
+ }
+
+ static class CreateTimerCmd implements Command<Void> {
+
+ private final TimerImpl timerImpl;
+
+ private static final long serialVersionUID = 1L;
+
+ CreateTimerCmd(TimerImpl timerImpl) {
+ this.timerImpl = timerImpl;
+ }
+
+ public Void execute(Environment environment) throws Exception {
+ DbSession dbSession = environment.get(DbSession.class);
+ dbSession.save(timerImpl);
+ dbSession.flush();
+
+ long timerDbid = timerImpl.getDbid();
+ log.info("scheduling " + timerImpl + " #" + timerDbid);
+ LocalTimer timerBean = timerHome.findByPrimaryKey(timerDbid);
+ timerBean.schedule();
+ return null;
+ }
+
+ public String toString() {
+ return CreateTimerCmd.class.getSimpleName() + '(' + timerImpl + ')';
+ }
+ }
+
+ static class CancelTimerCmd implements Command<Void> {
+
+ private final long timerDbid;
+
+ private static final long serialVersionUID = 1L;
+
+ CancelTimerCmd(long timerDbid) {
+ this.timerDbid = timerDbid;
+ }
+
+ public Void execute(Environment environment) throws Exception {
+ LocalTimer timerBean = timerHome.findByPrimaryKey(timerDbid);
+ timerBean.remove();
+ return null;
+ }
+
+ public String toString() {
+ return CancelTimerCmd.class.getSimpleName() + '(' + timerDbid + ')';
+ }
+ }
+}
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/TimerTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom (from rev 1726, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom)
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom/HappyActivity.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/HappyActivity.java 2008-07-25 12:29:12 UTC (rev 1726)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom/HappyActivity.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jbpm.enterprise.custom;
+package org.jbpm.pvm.enterprise.custom;
import java.util.Date;
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom/InsertPhraseCmd.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/InsertPhraseCmd.java 2008-07-25 12:29:12 UTC (rev 1726)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom/InsertPhraseCmd.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jbpm.enterprise.custom;
+package org.jbpm.pvm.enterprise.custom;
import java.sql.SQLException;
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom/NoisyActivity.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/NoisyActivity.java 2008-07-25 12:29:12 UTC (rev 1726)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom/NoisyActivity.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jbpm.enterprise.custom;
+package org.jbpm.pvm.enterprise.custom;
import java.sql.SQLException;
import java.util.Date;
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom/Phrase.hbm.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/Phrase.hbm.xml 2008-07-25 12:29:12 UTC (rev 1726)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom/Phrase.hbm.xml 2008-07-25 13:32:48 UTC (rev 1729)
@@ -2,7 +2,7 @@
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-access="field" auto-import="false">
- <class name="org.jbpm.enterprise.custom.Phrase" table="TEST_PHRASE">
+ <class name="org.jbpm.pvm.enterprise.custom.Phrase" table="TEST_PHRASE">
<id name="id" column="ID_">
<generator class="native" />
</id>
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom/Phrase.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/Phrase.java 2008-07-25 12:29:12 UTC (rev 1726)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom/Phrase.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jbpm.enterprise.custom;
+package org.jbpm.pvm.enterprise.custom;
/**
* @author Alejandro Guizar
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom/RemovePhraseCmd.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/enterprise/custom/RemovePhraseCmd.java 2008-07-25 12:29:12 UTC (rev 1726)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/enterprise/custom/RemovePhraseCmd.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jbpm.enterprise.custom;
+package org.jbpm.pvm.enterprise.custom;
import java.util.List;
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/ExclusiveTestMessage.java (from rev 1726, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/jobexecutor/ExclusiveTestMessage.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/ExclusiveTestMessage.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/ExclusiveTestMessage.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.jobexecutor;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.log.Log;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.model.OpenExecution;
+import org.jbpm.pvm.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveTestMessage extends MessageImpl<Object> {
+
+ private static final long serialVersionUID = 1L;
+ private static final Log log = Log.getLog(ExclusiveTestMessage.class.getName());
+ static Random random = new Random();
+
+ public ExclusiveTestMessage() {
+ }
+
+ public ExclusiveTestMessage(OpenExecution execution) {
+ this.execution = (ExecutionImpl) execution;
+ this.processInstance = (ExecutionImpl) execution.getProcessInstance();
+ this.isExclusive = true;
+ }
+
+ public Object execute(Environment environment) throws Exception {
+ Long threadId = Thread.currentThread().getId();
+ String executionKey = execution.getKey();
+
+ // exclusiveMessageIds maps execution keys to a set of thread ids.
+ // the idea is that for each execution, all the exclusive jobs will
+ // be executed by 1 thread sequentially.
+
+ // in the end, each set should contain exactly 1 element
+ Map<String, Set<Long>> exclusiveThreadIds = (Map<String, Set<Long>>) environment.get("exclusiveThreadIds");
+ Set<Long> groupMessages = exclusiveThreadIds.get(executionKey);
+ if (groupMessages==null) {
+ groupMessages = new HashSet<Long>();
+ exclusiveThreadIds.put(executionKey, groupMessages);
+ }
+ groupMessages.add(threadId);
+
+ // let's assume that an average jobImpl takes between 0 and 150 millis to complete.
+ int workTime = random.nextInt(150);
+ log.debug("executing exclusive message for "+execution+". this is going to take "+workTime+"ms");
+ try {
+ Thread.sleep(workTime);
+ } catch (RuntimeException e) {
+ log.debug("sleeping was interrupted");
+ }
+
+ DbSession dbSession = environment.get(DbSession.class);
+ dbSession.delete(this);
+
+ return null;
+ }
+
+}
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/ExclusiveTestMessage.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/FailOnceTestMessage.java (from rev 1726, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/jobexecutor/FailOnceTestMessage.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/FailOnceTestMessage.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/FailOnceTestMessage.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.jobexecutor;
+
+import java.util.List;
+
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.log.Log;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.model.Comment;
+import org.jbpm.pvm.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FailOnceTestMessage extends MessageImpl<Object> {
+
+ private static final long serialVersionUID = 1L;
+ private static final Log log = Log.getLog(FailOnceTestMessage.class.getName());
+
+ int messageId;
+
+ public FailOnceTestMessage() {
+ }
+
+ public FailOnceTestMessage(int messageId) {
+ this.messageId = messageId;
+ }
+
+ public Object execute(Environment environment) throws Exception {
+ DbSession dbSession = environment.get(DbSession.class);
+
+ // this message execution should be rolled back
+ Comment comment = new CommentImpl(Integer.toString(messageId));
+ dbSession.save(comment);
+
+ dbSession.delete(this);
+
+ List<Integer> failOnceMessageIds = (List) environment.get("failOnceMessageIds");
+ if (!failOnceMessageIds.contains(messageId)) {
+ // registering the failed message in a non-transactional resource
+ // so the messageId will still be added even after the transaction has rolled back
+ log.debug("adding failonce message "+messageId);
+ failOnceMessageIds.add(messageId);
+
+ throw new RuntimeException("failing once");
+ }
+
+ log.debug("message "+messageId+" now succeeds");
+
+ return null;
+ }
+
+}
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/FailOnceTestMessage.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/FailingTestMessage.java (from rev 1726, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/jobexecutor/FailingTestMessage.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/FailingTestMessage.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/FailingTestMessage.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.jobexecutor;
+
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.model.Comment;
+import org.jbpm.pvm.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FailingTestMessage extends MessageImpl<Object> {
+
+ private static final long serialVersionUID = 1L;
+
+ public Object execute(Environment environment) throws Exception {
+ DbSession dbSession = environment.get(DbSession.class);
+
+ // this message execution should be rolled back
+ Comment comment = new CommentImpl("failing update");
+ dbSession.save(comment);
+
+ dbSession.delete(this);
+
+ throw new RuntimeException("ooops");
+ }
+
+}
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/FailingTestMessage.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/JobExecutorTest.java (from rev 1726, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/jobexecutor/JobExecutorTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/JobExecutorTest.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/JobExecutorTest.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -0,0 +1,361 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.jobexecutor;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.hibernate.Session;
+import org.jbpm.pvm.test.base.EnvironmentFactoryTestCase;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.client.ClientProcessInstance;
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.env.Transaction;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
+import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
+import org.jbpm.pvm.internal.log.Log;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.job.Job;
+import org.jbpm.pvm.model.Comment;
+import org.jbpm.pvm.session.MessageSession;
+import org.jbpm.pvm.session.PvmDbSession;
+
+/**
+ * @author Tom Baeyens
+ */
+public class JobExecutorTest extends EnvironmentFactoryTestCase {
+
+ private static final Log log = Log.getLog(JobExecutorTest.class.getName());
+
+ /**
+ * test the case where the jobExecutor is start and shortly after stopped.
+ * It can appears for example in other tests with auto-start activated
+ * if the test is too short.
+ *
+ * The jobExecutor is registered as active when the run method is invoked.
+ * It happens only after a system context switching. If the jobExecutor is
+ * stopped before that, it won't really be stopped because it has not been
+ * started yet.
+ */
+ public void testImmediateJobExecutorShutdown() throws InterruptedException {
+
+ // if the test fail, there can be a live lock
+ // install a timer that will interrupt if it takes too long
+ // if that happens, it will lead to an interrupted exception and the test will fail
+ final Thread testThread = Thread.currentThread();
+ TimerTask interruptTask = new TimerTask() {
+ public void run() {
+ log.debug("test "+getName()+" took too long. going to interrupt..."+testThread);
+ testThread.interrupt();
+ }
+ };
+ Timer timer = new Timer();
+ timer.schedule(interruptTask, 10000);
+
+ final JobExecutor jobExecutor = getEnvironmentFactory().get(JobExecutor.class);
+ jobExecutor.setIdleInterval(1000);
+ assertFalse(jobExecutor.isActive());
+ jobExecutor.start();
+ jobExecutor.stop();
+ Thread.sleep(800);
+ assertFalse(jobExecutor.isActive());
+ }
+
+ public void testSuccessfulMessageProcessing() {
+ int nbrOfTestMessages = 5;
+ int testTimeoutMillis = 10000;
+ int checkInterval = 500;
+
+ List<Integer> processedMessageIds = (List<Integer>) getEnvironmentFactory().get("processedMessageIds");
+ processedMessageIds.clear();
+
+ JobExecutor jobExecutor = getEnvironmentFactory().get(JobExecutor.class);
+ jobExecutor.start();
+ try {
+ insertTestMessages(nbrOfTestMessages);
+ waitTillNoMoreMessages(jobExecutor, testTimeoutMillis, checkInterval);
+
+ } finally {
+ jobExecutor.stop(true);
+ }
+
+ for (int i=0; i<nbrOfTestMessages; i++) {
+ assertTrue("message "+i+" is not processed", processedMessageIds.contains(i));
+ }
+ }
+
+ public void testMessagesPresentUponJobExecutorStartUp() {
+ int nbrOfTestMessages = 2;
+ int testTimeoutMillis = 5000;
+ int checkInterval = 400;
+
+ insertTestMessages(nbrOfTestMessages);
+
+ List<Integer> processedMessageIds = (List<Integer>) getEnvironmentFactory().get("processedMessageIds");
+ processedMessageIds.clear();
+
+ JobExecutor jobExecutor = getEnvironmentFactory().get(JobExecutor.class);
+ jobExecutor.start();
+ try {
+ waitTillNoMoreMessages(jobExecutor, testTimeoutMillis, checkInterval);
+
+ } finally {
+ jobExecutor.stop(true);
+ }
+
+ for (int i=0; i<nbrOfTestMessages; i++) {
+ assertTrue("message "+i+" is not processed", processedMessageIds.contains(i));
+ }
+ }
+
+ public void testExclusiveMessageProcessing() {
+ int testTimeoutMillis = 10000;
+ int checkInterval = 500;
+ int nbrOfTestMessagesPerExecution = 5;
+ int nbrOfTestExecutions = 1;
+
+ insertExclusiveTestMessages(nbrOfTestExecutions, nbrOfTestMessagesPerExecution);
+
+ JobExecutor jobExecutor = getEnvironmentFactory().get(JobExecutor.class);
+ jobExecutor.start();
+ try {
+
+ waitTillNoMoreMessages(jobExecutor, testTimeoutMillis, checkInterval);
+
+ } finally {
+ jobExecutor.stop(true);
+ }
+
+
+ Environment environment = getEnvironmentFactory().openEnvironment();
+ try {
+ // exclusiveMessageIds maps execution keys to a set of thread ids.
+ // the idea is that for each execution, all the exclusive jobs will
+ // be executed by 1 thread sequentially.
+
+ // in the end, each set should contain exactly 1 element
+ Map<String, Set<Long>> exclusiveThreadIds = (Map) environment.get("exclusiveThreadIds");
+
+ for (int i=0; i<nbrOfTestExecutions; i++) {
+ String executionKey = "execution-"+i;
+ Set<Long> threadIds = exclusiveThreadIds.get(executionKey);
+ assertNotNull("no thread id set for "+executionKey+" in: "+exclusiveThreadIds, threadIds);
+ assertEquals("exclusive messages for "+executionKey+" have been executed by multiple threads: "+threadIds,
+ 1,
+ threadIds.size());
+ }
+ } finally {
+ environment.close();
+ }
+
+ }
+
+ public void testFailOnceMessages() {
+ int nbrOfTestMessages = 7;
+ int testTimeoutMillis = 10000;
+ int checkInterval = 500;
+
+ List<Integer> failOnceMessageIds = (List<Integer>) getEnvironmentFactory().get("failOnceMessageIds");
+ failOnceMessageIds.clear();
+
+ JobExecutor jobExecutor = getEnvironmentFactory().get(JobExecutor.class);
+ jobExecutor.start();
+ try {
+ insertFailOnceTestMessages(nbrOfTestMessages);
+ waitTillNoMoreMessages(jobExecutor, testTimeoutMillis, checkInterval);
+
+ } finally {
+ jobExecutor.stop(true);
+ }
+
+ for (int i=0; i<nbrOfTestMessages; i++) {
+ assertTrue("message "+i+" is not failed once: "+failOnceMessageIds, failOnceMessageIds.contains(i));
+ }
+ assertEquals(nbrOfTestMessages, failOnceMessageIds.size());
+
+ Environment environment = getEnvironmentFactory().openEnvironment();
+ try {
+ Session session = environment.get(Session.class);
+ List<Comment> comments = session.createQuery("from org.jbpm.pvm.internal.model.CommentImpl").list();
+
+ for (Comment comment: comments) {
+ Integer messageId = new Integer(comment.getMessage());
+ assertTrue("message "+messageId+" committed twice", failOnceMessageIds.remove(messageId));
+ // clean up for next tests
+ session.delete(comment);
+ }
+
+ assertTrue("not all messages made a successful commit: "+failOnceMessageIds, failOnceMessageIds.isEmpty());
+ } finally {
+ environment.close();
+ }
+ }
+
+ public void testFailedMessageProcessing() {
+ int testTimeoutMillis = 3000;
+ int checkInterval = 400;
+
+ JobExecutor jobExecutor = getEnvironmentFactory().get(JobExecutor.class);
+ jobExecutor.start();
+ try {
+ Environment environment = getEnvironmentFactory().openEnvironment();
+ try {
+ MessageSession messageSession = environment.get(MessageSession.class);
+ messageSession.send(new FailingTestMessage());
+ } finally {
+ environment.close();
+ }
+
+ waitTillNoMoreMessages(jobExecutor, testTimeoutMillis, checkInterval);
+
+ } finally {
+ jobExecutor.stop(true);
+ }
+
+ Environment environment = getEnvironmentFactory().openEnvironment();
+ try {
+ PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+ List<Job> deadJobs = pvmDbSession.findDeadJobs();
+ assertEquals("there should be one dead jobImpl", 1, deadJobs.size());
+
+ Session session = environment.get(Session.class);
+ List commands = session.createQuery("from org.jbpm.pvm.internal.model.CommentImpl").list();
+ assertTrue("command insertion should have been rolled back", commands.isEmpty());
+ } finally {
+ environment.close();
+ }
+ }
+
+ // helper methods ///////////////////////////////////////////////////////////
+
+ void insertTestMessages(int nbrOfTestMessages) {
+ Environment environment = getEnvironmentFactory().openEnvironment();
+ try {
+ MessageSession messageSession = environment.get(MessageSession.class);
+ for (int i=0; i<nbrOfTestMessages; i++) {
+ TestMessage testMessage = new TestMessage(i);
+ messageSession.send(testMessage);
+ }
+ } catch (RuntimeException e) {
+ environment.get(Transaction.class).setRollbackOnly();
+ throw e;
+ } finally {
+ environment.close();
+ }
+ }
+
+ void insertExclusiveTestMessages(int nbrOfTestExecutions, int nbrOfTestMessagesPerExecution) {
+ Environment environment = getEnvironmentFactory().openEnvironment();
+ try {
+ PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+ ClientProcessDefinition processDefinition = new ProcessDefinitionImpl();
+ pvmDbSession.save(processDefinition);
+
+ MessageSession messageSession = environment.get(MessageSession.class);
+ for (int i=0; i<nbrOfTestExecutions; i++) {
+ ClientProcessInstance execution = processDefinition.beginProcessInstance("execution-"+i);
+ pvmDbSession.save(execution);
+
+ for (int j=0; j<nbrOfTestMessagesPerExecution; j++) {
+
+ ExclusiveTestMessage testMessage = new ExclusiveTestMessage(execution);
+ messageSession.send(testMessage);
+ }
+ }
+ } catch (RuntimeException e) {
+ environment.get(Transaction.class).setRollbackOnly();
+ throw e;
+ } finally {
+ environment.close();
+ }
+ }
+
+ void insertFailOnceTestMessages(int nbrOfTestMessages) {
+ Environment environment = getEnvironmentFactory().openEnvironment();
+ try {
+ MessageSession messageSession = environment.get(MessageSession.class);
+ for (int i=0; i<nbrOfTestMessages; i++) {
+ FailOnceTestMessage testMessage = new FailOnceTestMessage(i);
+ messageSession.send(testMessage);
+ }
+ } catch (RuntimeException e) {
+ environment.get(Transaction.class).setRollbackOnly();
+ throw e;
+ } finally {
+ environment.close();
+ }
+ }
+
+
+ private void waitTillNoMoreMessages(JobExecutor jobExecutor, int maxWait, int checkInterval) {
+
+ // install a timer that will interrupt if it takes too long
+ // if that happens, it will lead to an interrupted exception and the test will fail
+ TimerTask interruptTask = new TimerTask() {
+ Thread testThread = Thread.currentThread();
+ public void run() {
+ log.debug("test "+getName()+" took too long. going to interrupt..."+testThread);
+ testThread.interrupt();
+ }
+ };
+ Timer timer = new Timer();
+ timer.schedule(interruptTask, maxWait);
+
+ try {
+ boolean jobsAvailable = true;
+ while (jobsAvailable) {
+ log.debug("going to sleep for "+checkInterval+" millis, waiting for the jobImpl executor to process more jobs");
+ Thread.sleep(checkInterval);
+ jobsAvailable = areJobsAvailable();
+ }
+
+ } catch (InterruptedException e) {
+ fail("test execution exceeded treshold of "+maxWait+" milliseconds");
+ } finally {
+ timer.cancel();
+ }
+ }
+
+ boolean areJobsAvailable() {
+ Environment environment = getEnvironmentFactory().openEnvironment();
+ try {
+ JobDbSession jobDbSession = environment.get(JobDbSession.class);
+
+ JobImpl<?> firstAcquirableJob = jobDbSession.findFirstAcquirableJob();
+ if (firstAcquirableJob!=null) {
+ log.debug("found more jobs to process");
+ return true;
+ }
+ } catch (RuntimeException e) {
+ environment.get(Transaction.class).setRollbackOnly();
+ throw e;
+ } finally {
+ environment.close();
+ }
+ log.debug("no more jobs to process");
+ return false;
+ }
+}
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/JobExecutorTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Added: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/JobExecutorTests.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/JobExecutorTests.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/JobExecutorTests.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.jobexecutor;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JobExecutorTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Test for org.jbpm.pvm.jobexecutor");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(JobExecutorTimerSessionTest.class);
+ suite.addTestSuite(JobExecutorTest.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/JobExecutorTimerSessionTest.java (from rev 1726, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/jobexecutor/JobExecutorTimerSessionTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/JobExecutorTimerSessionTest.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/JobExecutorTimerSessionTest.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -0,0 +1,398 @@
+/**
+ * Copyright (C) 2007 Bull S. A. S.
+ * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
+ * This library is free software; you can redistribute it and/or modify it under the terms
+ * of the GNU Lesser General Public License as published by the Free Software Foundation
+ * version 2.1 of the License.
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA 02110-1301, USA.
+ **/
+package org.jbpm.pvm.jobexecutor;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.jbpm.pvm.test.base.DbTestCase;
+import org.jbpm.pvm.PvmException;
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.job.TimerImpl;
+import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
+import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.job.Job;
+import org.jbpm.pvm.job.Timer;
+import org.jbpm.pvm.session.PvmDbSession;
+import org.jbpm.pvm.session.TimerSession;
+
+/**
+ * @author Pascal Verdage
+ */
+public class JobExecutorTimerSessionTest extends DbTestCase
+{
+
+ public void setUp() throws Exception {
+ super.setUp();
+ getVariables().clear();
+ // launch jobExecutor
+ Environment.getCurrent().get(JobExecutor.class).setIdleInterval(500000);
+ Environment.getCurrent().get(JobExecutor.class).start();
+ }
+
+ public void tearDown() throws Exception {
+ Environment.getCurrent().get(JobExecutor.class).stop();
+ super.tearDown();
+ }
+
+ /* GETTERS */
+ @SuppressWarnings("unchecked")
+ public static Map<String, Integer> getVariables() {
+ return (Map<String, Integer>) Environment.getCurrent()
+ .getEnvironmentFactory().get("timerVariables");
+ }
+
+ /** get TimerSession if an environment is open */
+ protected static TimerSession getTimerSession() {
+ assertNotNull(Environment.getCurrent());
+ return Environment.getCurrent().get(TimerSession.class);
+ }
+
+ /** get JobDbSession if an environment is open */
+ protected static JobDbSession getJobDbSession() {
+ assertNotNull(Environment.getCurrent());
+ return Environment.getCurrent().get(JobDbSession.class);
+ }
+
+ /** get PvmDbSession if an environment is open */
+ protected static PvmDbSession getPvmDbSession() {
+ assertNotNull(Environment.getCurrent());
+ return Environment.getCurrent().get(PvmDbSession.class);
+ }
+
+ /* Test assertion tools */
+ /** return the number of timers among active jobs */
+ private static int getNbTimer() {
+ int result = 0;
+ List<Timer> timers = getPvmDbSession().findTimers();
+ if (timers != null) {
+ for (Job job : timers) {
+ if (job instanceof TimerImpl) {
+ result++;
+ }
+ }
+ }
+ // List<JobImpl<?>> deadJobs = getPvmDbSession().findAllJobs();
+ // if (deadJobs != null) {
+ // for (JobImpl<?> jobImpl : deadJobs) {
+ // if (jobImpl instanceof TimerImpl) {
+ // result++;
+ // }
+ // }
+ // }
+ return result;
+ }
+
+ private static int TIMEOUT = 60 * 1000; // 1 minutes
+
+ /** This method change the transaction */
+ protected void waitUntilNbTimerEquals(int expected) {
+ int rate = 500; // check every rate millis
+ int result = Integer.MAX_VALUE;
+
+ for (int i = 0; i < TIMEOUT / rate; i++) {
+ try {
+ Thread.sleep(rate);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ fail();
+ }
+ newTransaction();
+ result = getNbTimer();
+ if (result == expected) {
+ break;
+ }
+ }
+ // if false, then the timeout occurred
+ assertEquals(expected, result);
+ }
+
+ protected static void assertNbTimersEquals(int expected) {
+ assertEquals(expected, getNbTimer());
+ }
+
+ /* TimerImpl manipulation tools */
+
+ /** @return the first due timer or null if none */
+ protected TimerImpl findFirstDueTimer() {
+ TimerImpl result = null;
+ JobImpl<?> firstJob = getJobDbSession().findFirstDueJob();
+ if (firstJob instanceof TimerImpl) {
+ result = (TimerImpl) firstJob;
+ } else {
+ List<Timer> timers = getPvmDbSession().findTimers();
+ if (timers != null) {
+ Date dueDate = new Date(Long.MAX_VALUE);
+ for (Timer timer : timers) {
+ if (timer instanceof TimerImpl && timer.getDueDate().before(dueDate)) {
+ dueDate = timer.getDueDate();
+ result = (TimerImpl) timer;
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ /** create a timer that should not be executed */
+ private TimerImpl createForbiddenTimer(String name, long delay) {
+ return new TestTimer(name, delay, 0);
+ }
+ /** create a timer that should be executed once */
+ private TimerImpl createTimer(String name, Date dueDate) {
+ return new TestTimer(name, dueDate, 1);
+ }
+ /** create a timer that should be executed once */
+ private TimerImpl createTimer(String name, long delay) {
+ return new TestTimer(name, delay, 1);
+ }
+ /** create a timer that should be executed nbExecution times */
+ private TimerImpl createTimer(String name, long delay, long repeatDelay, int nbExecution) {
+ TimerImpl timerImpl = new TestTimer(name, delay, nbExecution);
+ timerImpl.setRepeat(Long.toString(repeatDelay) + " millis");
+ return timerImpl;
+ }
+
+ /* Functionnal tests */
+
+ /** Test all use cases that should throw PvmException for method schedule */
+ public void testScheduleIllegalArgument() {
+ TimerSession timerSession = getTimerSession();
+ TimerImpl timerImpl;
+
+ // null TimerImpl
+ try {
+ timerSession.schedule(null);
+ fail("Should not happen");
+ } catch (PvmException e) {
+ assertTextPresent("null timer", e.getMessage());
+ }
+
+ // no execution
+ try {
+ timerImpl = new TimerImpl();
+ timerSession.schedule(timerImpl);
+ // clean before failure
+ timerSession.cancel(timerImpl);
+ fail("Should not happen");
+ } catch (PvmException e) {
+ assertTextPresent("no execution", e.getMessage());
+ }
+
+ ExecutionImpl execution = new ExecutionImpl();
+
+ // no signal or event
+ try {
+ timerImpl = new TimerImpl();
+ timerImpl.setExecution(execution);
+ timerSession.schedule(timerImpl);
+ // clean before failure
+ timerSession.cancel(timerImpl);
+ fail("Should not happen");
+ } catch (PvmException e) {
+ assertTextPresent("no signalName or eventName", e.getMessage());
+ }
+
+ // a signalName with no activityInstance to signal is valid
+
+ // null dueDate
+ try {
+ timerImpl = createTimer("schedule error 1", null);
+ timerImpl.setExecution(execution);
+
+ timerImpl.setSignalName("timeout");
+ timerSession.schedule(timerImpl);
+ // clean before failure
+ timerSession.cancel(timerImpl);
+ fail("Should not happen");
+ } catch (PvmException e) {
+ assertTextPresent("null date", e.getMessage());
+ }
+
+ // date.getTime() negative
+ try {
+ timerImpl = createTimer("schedule error 2", new Date(-10));
+ timerImpl.setExecution(execution);
+
+ timerImpl.setSignalName("timeout");
+ timerSession.schedule(timerImpl);
+ // clean before failure
+ timerSession.cancel(timerImpl);
+ fail("Should not happen");
+ } catch (PvmException e) {
+ assertTextPresent("negative date", e.getMessage());
+ }
+ }
+
+ /** Test the method cancel */
+ public void testCancel() {
+ TimerSession timerSession;
+ TimerImpl timerImpl;
+
+ // null jobImpl
+ try {
+ getTimerSession().cancel(null);
+ fail();
+ } catch (PvmException e) {
+ // OK
+ }
+
+ // non scheduled jobImpl
+ timerSession = getTimerSession();
+ timerImpl = createForbiddenTimer("cancel 1", 500);
+ timerSession.cancel(timerImpl);
+ assertNbTimersEquals(0);
+
+ // scheduled non-executed jobImpl
+ ExecutionImpl execution = new ExecutionImpl();
+ getPvmDbSession().save(execution);
+
+ timerSession = getTimerSession();
+ timerImpl = createForbiddenTimer("cancel 2", 500);
+ timerImpl.setSignalName("timeout");
+ timerImpl.setExecution(execution);
+
+ timerSession.schedule(timerImpl);
+ newTransaction();
+ assertNbTimersEquals(1);
+ timerSession = getTimerSession();
+ timerSession.cancel(findFirstDueTimer());
+
+ newTransaction();
+ assertNbTimersEquals(0);
+
+ execution = getPvmDbSession().get(ExecutionImpl.class, execution.getDbid());
+ getPvmDbSession().delete(execution);
+
+ /*
+ * scheduled jobImpl with repeat
+ * This is not necessary because in the test, a timer scheduled with
+ * a repeat will be deleted by the instance. So this case is covered
+ * by the test testScheduleRepeatDelay
+ */
+ }
+
+ /** Schedule a jobImpl in the past */
+ public void testSchedulePastJob() {
+ ExecutionImpl execution = new ExecutionImpl();
+ execution = reload(execution);
+ try {
+ TimerImpl timerImpl = createTimer("schedule past jobImpl", -500);
+ timerImpl.setExecution(execution);
+ timerImpl.setEventName("timeout");
+ getTimerSession().schedule(timerImpl);
+ assertNbTimersEquals(1);
+ newTransaction();
+ waitUntilNbTimerEquals(0);
+ } finally {
+ execution = getPvmDbSession().get(ExecutionImpl.class, execution.getDbid());
+ getPvmDbSession().delete(execution);
+ newTransaction();
+ }
+ }
+
+ /** Schedule a jobImpl in the future */
+ public void testScheduleFutureJob() {
+ ExecutionImpl execution = new ExecutionImpl();
+ execution = reload(execution);
+ try {
+ TimerImpl timerImpl = createTimer("schedule future jobImpl", 500);
+ timerImpl.setExecution(execution);
+ timerImpl.setEventName("timeout");
+ getTimerSession().schedule(timerImpl);
+ assertNbTimersEquals(1);
+ newTransaction();
+ waitUntilNbTimerEquals(0);
+ } finally {
+ execution = getPvmDbSession().get(ExecutionImpl.class, execution.getDbid());
+ getPvmDbSession().delete(execution);
+ newTransaction();
+ }
+ }
+
+ /** Test the method schedule with a repeated jobImpl */
+ public void testScheduleRepeatDelay() {
+ ExecutionImpl execution = new ExecutionImpl();
+ execution = reload(execution);
+ try {
+ TimerImpl timerImpl = createTimer("schedule repeat delay", 200, 400, 3);
+ timerImpl.setExecution(execution);
+ timerImpl.setEventName("timeout");
+ getTimerSession().schedule(timerImpl);
+ assertNbTimersEquals(1);
+ newTransaction();
+ waitUntilNbTimerEquals(0);
+ } finally {
+ execution = getPvmDbSession().get(ExecutionImpl.class, execution.getDbid());
+ getPvmDbSession().delete(execution);
+ newTransaction();
+ }
+ }
+
+
+ /* Concurrent tests */
+
+ /** create a timer that should be executed once and increment a variable */
+ private TimerImpl createIncrementingTimer(String name, Date dueDate, String variable) {
+ TestTimer timer = new TestTimer(name, dueDate, 1);
+ timer.setVariableName(variable);
+ timer.setEventName("incrementation");
+ return timer;
+ }
+
+ private void testManyTimers(int nbTimer, long delayBetweenTimers) {
+ ExecutionImpl execution = new ExecutionImpl();
+ execution = reload(execution);
+ try {
+ long startTime = System.currentTimeMillis();
+ for (int i=0; i<nbTimer; i++) {
+ Date dueDate = new Date(startTime + 1000 + i*delayBetweenTimers);
+ String name = "timer " + i;
+ TimerImpl timerImpl = createIncrementingTimer(name, dueDate, name);
+ timerImpl.setExecution(execution);
+ getTimerSession().schedule(timerImpl);
+ }
+
+ newTransaction();
+ assertNbTimersEquals(nbTimer);
+ waitUntilNbTimerEquals(0);
+ int sum = 0;
+ Map<String, Integer> variables = getVariables();
+ if (variables != null) {
+ for (Entry<String, Integer> variable : variables.entrySet()) {
+ assertEquals(variable.getKey(), 1, (int)variable.getValue());
+ sum += variable.getValue();
+ }
+ }
+ assertEquals(nbTimer, sum);
+ } finally {
+ execution = getPvmDbSession().get(ExecutionImpl.class, execution.getDbid());
+ getPvmDbSession().delete(execution);
+ newTransaction();
+ }
+ }
+
+ public void testSeveralTimer() {
+ testManyTimers(20, 100);
+ }
+
+ public void testSimultaneousTimer() {
+ testManyTimers(20, 0);
+ }
+
+}
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/JobExecutorTimerSessionTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/TestMessage.java (from rev 1726, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/jobexecutor/TestMessage.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/TestMessage.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/TestMessage.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.jobexecutor;
+
+import java.util.List;
+import java.util.Random;
+
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.log.Log;
+import org.jbpm.pvm.session.DbSession;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TestMessage extends MessageImpl<Object> {
+
+ private static final long serialVersionUID = 1L;
+ private static final Log log = Log.getLog(TestMessage.class.getName());
+ static Random random = new Random();
+
+ int messageId;
+
+ public TestMessage() {
+ }
+
+ public TestMessage(int messageId) {
+ this.messageId = messageId;
+ }
+
+ public Object execute(Environment environment) throws Exception {
+ List<Integer> messageNumberCollector = (List<Integer>) environment.get("processedMessageIds");
+ messageNumberCollector.add(messageId);
+
+ // let's assume that an average jobImpl takes between 0 and 150 millis to complete.
+ int workTime = random.nextInt(150);
+ log.debug("executing test message "+messageId+". this is going to take "+workTime+"ms");
+ try {
+ Thread.sleep(workTime);
+ } catch (RuntimeException e) {
+ log.debug("sleeping was interrupted");
+ }
+
+ DbSession dbSession = environment.get(DbSession.class);
+ dbSession.delete(this);
+ return null;
+ }
+}
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/TestMessage.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/TestTimer.java (from rev 1726, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/jobexecutor/TestTimer.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/TestTimer.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/TestTimer.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.jobexecutor;
+
+import java.util.Date;
+import java.util.Map;
+
+import org.jbpm.pvm.test.base.JbpmTestCase;
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.internal.job.TimerImpl;
+import org.jbpm.pvm.session.TimerSession;
+
+/**
+ * @author Tom Baeyens
+ * @author Pascal Verdage
+ */
+public class TestTimer extends TimerImpl {
+ private static final long serialVersionUID = 1L;
+
+ private String name;
+ private int nbMaxExecution;
+ // used to increment a variable
+ private String variableName;
+
+ private int nbExecution = 0;
+
+ protected TestTimer() {}
+
+ public TestTimer(String name, long delay, int nbMaxExecution) {
+ this(name, new Date(System.currentTimeMillis() + delay), nbMaxExecution);
+ }
+
+ public TestTimer(String name, Date dueDate, int nbMaxExecution) {
+ this.name = name;
+ this.dueDate = dueDate;
+ this.nbMaxExecution = nbMaxExecution;
+ }
+
+ public Boolean execute(Environment environment) throws Exception {
+ Date now = new Date();
+ JbpmTestCase.assertTrue(name+" is executing too soon", now.after(dueDate));
+ nbExecution++;
+ JbpmTestCase.assertTrue(name+" should not be executed",
+ nbExecution <= nbMaxExecution);
+
+ if (variableName != null) {
+ Map<String, Integer> variables =
+ JobExecutorTimerSessionTest.getVariables();
+ if (variables != null) {
+ Integer n = variables.get(variableName);
+ if (n == null) {
+ n = 0;
+ }
+ n++;
+ variables.put(variableName, n);
+ }
+ }
+
+ // reschedule if necessary
+ boolean deleteThisJob = super.execute(environment);
+
+ // cancel the timer if necessary
+ if (nbExecution == nbMaxExecution) {
+ JbpmTestCase.assertNotNull(Environment.getCurrent());
+ TimerSession timerSession = Environment.getCurrent().get(TimerSession.class);
+ JbpmTestCase.assertNotNull(timerSession);
+ timerSession.cancel(this);
+ }
+
+ return deleteThisJob;
+ }
+
+ public void setVariableName(String variableName) {
+ this.variableName = variableName;
+ }
+}
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/TestTimer.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/cron (from rev 1726, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/jobexecutor/cron)
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/cron
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/cron/CronExpression.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/jobexecutor/cron/CronExpression.java 2008-07-25 12:29:12 UTC (rev 1726)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/cron/CronExpression.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -1,4 +1,4 @@
-package org.jbpm.jobexecutor.cron;
+package org.jbpm.pvm.jobexecutor.cron;
import java.io.Serializable;
import java.text.ParseException;
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/cron/CronTrigger.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/jobexecutor/cron/CronTrigger.java 2008-07-25 12:29:12 UTC (rev 1726)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/jobexecutor/cron/CronTrigger.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -18,7 +18,7 @@
/*
* Previously Copyright (c) 2001-2004 James House
*/
-package org.jbpm.jobexecutor.cron;
+package org.jbpm.pvm.jobexecutor.cron;
import java.text.ParseException;
import java.util.Calendar;
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/msg (from rev 1726, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/msg)
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/msg
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/msg/MemJobExecutor.java (from rev 1726, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/svc/memory/MemJobExecutor.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/msg/MemJobExecutor.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/msg/MemJobExecutor.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.msg;
+
+import java.util.Queue;
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.env.EnvironmentFactory;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.log.Log;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class MemJobExecutor {
+
+ private static final Log log = Log.getLog(MemJobExecutor.class.getName());
+
+ Queue<JobImpl<?>> queue;
+ EnvironmentFactory environmentFactory;
+
+ public void executeAvailableJobs() {
+ while (! queue.isEmpty()) {
+ JobImpl<?> job = queue.poll();
+ if (job!=null) {
+ executeJob(job);
+ }
+ }
+ }
+
+ protected void executeJob(JobImpl<?> job) {
+ Environment environment = environmentFactory.openEnvironment();
+ try {
+ log.trace("processing jobImpl "+job);
+ job.execute(environment);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ environment.close();
+ }
+ }
+
+ public void startExecutingJobs() {
+ }
+
+ public void stopExecutingJobs() {
+ }
+}
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/msg/MemJobExecutor.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/msg/MemMessageService.java (from rev 1726, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/svc/memory/MemMessageService.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/msg/MemMessageService.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/msg/MemMessageService.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.msg;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Queue;
+import org.jbpm.pvm.env.Environment;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.log.Log;
+import org.jbpm.pvm.internal.tx.Resource;
+import org.jbpm.pvm.session.MessageSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class MemMessageService implements MessageSession, Resource {
+
+ private static final long serialVersionUID = 1L;
+ private static final Log log = Log.getLog(MemMessageService.class.getName());
+
+ Environment environment; // injected
+ Queue<JobImpl<?>> queue = null;
+ List<JobImpl<?>> producedMessages = null;
+
+ public void send(MessageImpl<?> message) {
+ log.trace("adding message "+message);
+ if (producedMessages==null) {
+ producedMessages = new ArrayList<JobImpl<?>>();
+ }
+ producedMessages.add(message);
+ }
+
+ public void prepare() {
+ }
+
+ public void commit() {
+ if (producedMessages!=null) {
+ queue.addAll(producedMessages);
+ }
+ }
+
+ public void rollback() {
+ producedMessages = null;
+ }
+
+ public void close() {
+ }
+
+ public void flush() {
+ }
+}
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/msg/MemMessageService.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/msg/MemMessageServiceTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/msg/MemMessageServiceTest.java 2008-07-25 12:29:12 UTC (rev 1726)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/msg/MemMessageServiceTest.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -1,34 +1,19 @@
-package org.jbpm.msg;
+package org.jbpm.pvm.msg;
import java.util.Queue;
-import org.jbpm.pvm.test.base.JbpmTestCase;
import org.jbpm.pvm.env.Environment;
import org.jbpm.pvm.env.EnvironmentFactory;
import org.jbpm.pvm.env.PvmEnvironmentFactory;
import org.jbpm.pvm.env.Transaction;
import org.jbpm.pvm.internal.job.JobImpl;
import org.jbpm.pvm.internal.job.MessageImpl;
-import org.jbpm.svc.memory.MemMessageService;
+import org.jbpm.pvm.test.base.EnvironmentFactoryTestCase;
-public class MemMessageServiceTest extends JbpmTestCase
-{
+public class MemMessageServiceTest extends EnvironmentFactoryTestCase {
public void testSendJob() {
- EnvironmentFactory environmentFactory = PvmEnvironmentFactory.parseXmlString(
- "<contexts>" +
- " <environment-factory>" +
- " <object name='queue' class='java.util.concurrent.LinkedBlockingQueue' />" +
- " </environment-factory>" +
- " <environment>" +
- " <transaction name='tx' />" +
- " <object name='messageService' class='"+MemMessageService.class.getName()+"' auto-wire='enabled'>" +
- " <enlist transaction='tx'/>" +
- " </object>" +
- // queue gets auto-wired into the message service
- " </environment>" +
- "</contexts>"
- );
+ EnvironmentFactory environmentFactory = getEnvironmentFactory();
MessageImpl<?> message = new MessageImpl<Object>() {
private static final long serialVersionUID = 1L;
@@ -38,6 +23,7 @@
};
Queue<JobImpl<?>> queue = (Queue<JobImpl<?>>) ((PvmEnvironmentFactory)environmentFactory).get("queue");
+ queue.clear();
Environment environment = environmentFactory.openEnvironment();
MemMessageService msgService = (MemMessageService) environment.get("messageService");
@@ -51,18 +37,7 @@
}
public void testSendJobAndRollback() {
- EnvironmentFactory environmentFactory = PvmEnvironmentFactory.parseXmlString(
- "<contexts>" +
- " <environment-factory>" +
- " <object name='queue' class='java.util.concurrent.LinkedBlockingQueue' />" +
- " </environment-factory>" +
- " <environment>" +
- " <transaction name='tx' />" +
- " <object name='messageService' class='"+MemMessageService.class.getName()+"' auto-wire='enabled'/>" +
- // queue gets auto-wired into the message service
- " </environment>" +
- "</contexts>"
- );
+ EnvironmentFactory environmentFactory = getEnvironmentFactory();
MessageImpl<?> message = new MessageImpl<Object>() {
private static final long serialVersionUID = 1L;
@@ -72,6 +47,7 @@
};
Queue<JobImpl<?>> queue = (Queue<JobImpl<?>>) ((PvmEnvironmentFactory)environmentFactory).get("queue");
+ queue.clear();
Environment environment = environmentFactory.openEnvironment();
MemMessageService msgService = (MemMessageService) environment.get("messageService");
Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/svc/memory/MemJobExecutor.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/svc/memory/MemJobExecutor.java 2008-07-25 13:01:49 UTC (rev 1728)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/svc/memory/MemJobExecutor.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.svc.memory;
-
-import java.util.Queue;
-import org.jbpm.pvm.env.Environment;
-import org.jbpm.pvm.env.EnvironmentFactory;
-import org.jbpm.pvm.internal.job.JobImpl;
-import org.jbpm.pvm.internal.log.Log;
-
-
-/**
- * @author Tom Baeyens
- */
-public class MemJobExecutor {
-
- private static final Log log = Log.getLog(MemJobExecutor.class.getName());
-
- Queue<JobImpl<?>> queue;
- EnvironmentFactory environmentFactory;
-
- public void executeAvailableJobs() {
- while (! queue.isEmpty()) {
- JobImpl<?> job = queue.poll();
- if (job!=null) {
- executeJob(job);
- }
- }
- }
-
- protected void executeJob(JobImpl<?> job) {
- Environment environment = environmentFactory.openEnvironment();
- try {
- log.trace("processing jobImpl "+job);
- job.execute(environment);
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- environment.close();
- }
- }
-
- public void startExecutingJobs() {
- }
-
- public void stopExecutingJobs() {
- }
-}
Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/svc/memory/MemMessageService.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/svc/memory/MemMessageService.java 2008-07-25 13:01:49 UTC (rev 1728)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/svc/memory/MemMessageService.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -1,73 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.svc.memory;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Queue;
-import org.jbpm.pvm.env.Environment;
-import org.jbpm.pvm.internal.job.JobImpl;
-import org.jbpm.pvm.internal.job.MessageImpl;
-import org.jbpm.pvm.internal.log.Log;
-import org.jbpm.pvm.internal.tx.Resource;
-import org.jbpm.pvm.session.MessageSession;
-
-
-/**
- * @author Tom Baeyens
- */
-public class MemMessageService implements MessageSession, Resource {
-
- private static final long serialVersionUID = 1L;
- private static final Log log = Log.getLog(MemMessageService.class.getName());
-
- Environment environment; // injected
- Queue<JobImpl<?>> queue = null;
- List<JobImpl<?>> producedMessages = null;
-
- public void send(MessageImpl<?> message) {
- log.trace("adding message "+message);
- if (producedMessages==null) {
- producedMessages = new ArrayList<JobImpl<?>>();
- }
- producedMessages.add(message);
- }
-
- public void prepare() {
- }
-
- public void commit() {
- if (producedMessages!=null) {
- queue.addAll(producedMessages);
- }
- }
-
- public void rollback() {
- producedMessages = null;
- }
-
- public void close() {
- }
-
- public void flush() {
- }
-}
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/wire/ConcurrentWiringTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/wire/ConcurrentWiringTest.java 2008-07-25 13:01:49 UTC (rev 1728)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/wire/ConcurrentWiringTest.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -116,7 +116,15 @@
}
for (Thread collector: collectors) {
- collector.join();
+ boolean isJoined = false;
+ while (collector.isAlive() && !isJoined) {
+ try {
+ collector.join();
+ isJoined = true;
+ } catch (InterruptedException e) {
+ log.info("ignoring interrupted exception while joining "+collector);
+ }
+ }
}
Object a = wireContext.get("a");
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/wire/WireTests.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/wire/WireTests.java 2008-07-25 13:01:49 UTC (rev 1728)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/wire/WireTests.java 2008-07-25 13:32:48 UTC (rev 1729)
@@ -33,27 +33,27 @@
public static Test suite() {
TestSuite suite = new TestSuite("Test for org.jbpm.wire");
//$JUnit-BEGIN$
+ suite.addTestSuite(AutoWireTest.class);
+ suite.addTestSuite(BasicTypeWireTest.class);
+ suite.addTestSuite(ClassWireTest.class);
+ suite.addTestSuite(ConcurrentWiringTest.class);
suite.addTestSuite(ContextBlockSubscriptionTest.class);
- suite.addTestSuite(EagerInitTest.class);
suite.addTestSuite(ContextTest.class);
+ suite.addTestSuite(DelayedInitTest.class);
suite.addTestSuite(DependencyTest.class);
- suite.addTestSuite(BasicTypeWireTest.class);
+ suite.addTestSuite(EagerInitTest.class);
+ suite.addTestSuite(EnvWireTest.class);
suite.addTestSuite(HibernateSessionFactoryWireTest.class);
- suite.addTestSuite(SetWireTest.class);
- suite.addTestSuite(ObjectWireTest.class);
- suite.addTestSuite(TypeLookupTest.class);
+ suite.addTestSuite(ListWireTest.class);
+ suite.addTestSuite(MapWireTest.class);
suite.addTestSuite(MethodSubscriptionTest.class);
suite.addTestSuite(RefWireTest.class);
- suite.addTestSuite(AutoWireTest.class);
- suite.addTestSuite(ClassWireTest.class);
- suite.addTestSuite(EnvWireTest.class);
- suite.addTestSuite(ConcurrentWiringTest.class);
+ suite.addTestSuite(ObjectSubscriptionTest.class);
+ suite.addTestSuite(ObjectWireTest.class);
suite.addTestSuite(PropertiesWireTest.class);
- suite.addTestSuite(MapWireTest.class);
- suite.addTestSuite(ObjectSubscriptionTest.class);
+ suite.addTestSuite(SetWireTest.class);
+ suite.addTestSuite(TypeLookupTest.class);
suite.addTestSuite(WireEventsSubscriptionTest.class);
- suite.addTestSuite(ListWireTest.class);
- suite.addTestSuite(DelayedInitTest.class);
//$JUnit-END$
return suite;
}
Copied: jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/enterprise (from rev 1726, jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/enterprise)
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/enterprise
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/enterprise/custom/Phrase.hbm.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/enterprise/custom/Phrase.hbm.xml 2008-07-25 12:29:12 UTC (rev 1726)
+++ jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/enterprise/custom/Phrase.hbm.xml 2008-07-25 13:32:48 UTC (rev 1729)
@@ -2,7 +2,7 @@
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-access="field" auto-import="false">
- <class name="org.jbpm.enterprise.custom.Phrase" table="TEST_PHRASE">
+ <class name="org.jbpm.pvm.enterprise.custom.Phrase" table="TEST_PHRASE">
<id name="id" column="ID_">
<generator class="native" />
</id>
Copied: jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/jobexecutor (from rev 1726, jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/jobexecutor)
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/jobexecutor
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/jobexecutor/environment.cfg.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/jobexecutor/environment.cfg.xml 2008-07-25 12:29:12 UTC (rev 1726)
+++ jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/jobexecutor/environment.cfg.xml 2008-07-25 13:32:48 UTC (rev 1729)
@@ -12,7 +12,7 @@
<hibernate-configuration>
<properties resource="hibernate.properties" />
<mappings resource="org/jbpm/pvm/pvm.hibernate.mappings.xml" />
- <mapping resource="org/jbpm/jobexecutor/mappings.hbm.xml" />
+ <mapping resource="org/jbpm/pvm/jobexecutor/mappings.hbm.xml" />
<cache-configuration resource="org/jbpm/pvm/pvm.cache.xml" usage="nonstrict-read-write" />
</hibernate-configuration>
Modified: jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/jobexecutor/mappings.hbm.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/jobexecutor/mappings.hbm.xml 2008-07-25 12:29:12 UTC (rev 1726)
+++ jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/jobexecutor/mappings.hbm.xml 2008-07-25 13:32:48 UTC (rev 1729)
@@ -4,7 +4,7 @@
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-<hibernate-mapping package="org.jbpm.jobexecutor" default-access="field">
+<hibernate-mapping package="org.jbpm.pvm.jobexecutor" default-access="field">
<subclass name="TestMessage" extends="org.jbpm.pvm.internal.job.MessageImpl" discriminator-value="T">
<property name="messageId" />
Added: jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/msg/environment.cfg.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/msg/environment.cfg.xml (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/msg/environment.cfg.xml 2008-07-25 13:32:48 UTC (rev 1729)
@@ -0,0 +1,11 @@
+<contexts>
+ <environment-factory>
+ <object name="queue" class="java.util.concurrent.LinkedBlockingQueue" />
+ </environment-factory>
+ <environment>
+ <transaction name="tx" />
+ <object name="messageService" class="org.jbpm.pvm.msg.MemMessageService" auto-wire="enabled">
+ <enlist transaction="tx"/>
+ </object>
+ </environment>
+</contexts>
17 years, 9 months
JBoss JBPM SVN: r1728 - in jbossbpm/spec/trunk/modules: dialects/api10/src/main/java/org/jboss/bpm/dialect/api10 and 5 other directories.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-07-25 09:01:49 -0400 (Fri, 25 Jul 2008)
New Revision: 1728
Added:
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/GatewayBuilder.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GateImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayBuilderImpl.java
Modified:
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Gateway.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ProcessBuilder.java
jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/TaskBuilder.java
jbossbpm/spec/trunk/modules/dialects/api10/src/main/java/org/jboss/bpm/dialect/api10/ProcessUnmarshaller.java
jbossbpm/spec/trunk/modules/dialects/jpdl32/src/main/java/org/jboss/bpm/dialect/jpdl32/ProcessDefinitionAdapter.java
jbossbpm/spec/trunk/modules/dialects/stp/src/main/java/org/jboss/bpm/dialect/stp/ProcessUnmarshaller.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ComplexGatewayImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/FlowObjectImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/InclusiveGatewayImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ParallelGatewayImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ProcessBuilderImpl.java
jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ReceiveTaskImpl.java
jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java
jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/parallelsplit/ParallelSplitTest.java
Log:
Add GateImpl
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Gateway.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Gateway.java 2008-07-25 12:49:54 UTC (rev 1727)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/Gateway.java 2008-07-25 13:01:49 UTC (rev 1728)
@@ -35,7 +35,7 @@
* @author thomas.diesler(a)jboss.com
* @since 08-Jul-2008
*/
-public interface Gateway extends FlowObject, NameSupport, MultipleOutFlowSupport, MultipleInFlowSupport
+public interface Gateway extends FlowObject, NameSupport, MultipleInFlowSupport
{
/**
* The GatewayType
Added: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/GatewayBuilder.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/GatewayBuilder.java (rev 0)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/GatewayBuilder.java 2008-07-25 13:01:49 UTC (rev 1728)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.model;
+
+
+//$Id$
+
+/**
+ * The GatewayBuilder can be used to build a {@link Gateway} dynamically.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public interface GatewayBuilder extends ProcessBuilder
+{
+ GatewayBuilder addGate(String targetName);
+
+}
\ No newline at end of file
Property changes on: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/GatewayBuilder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ProcessBuilder.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ProcessBuilder.java 2008-07-25 12:49:54 UTC (rev 1727)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/ProcessBuilder.java 2008-07-25 13:01:49 UTC (rev 1728)
@@ -21,6 +21,7 @@
*/
package org.jboss.bpm.model;
+import org.jboss.bpm.model.Gateway.GatewayType;
import org.jboss.bpm.model.Task.TaskType;
import org.jboss.bpm.runtime.ExecutionHandler;
import org.jboss.bpm.runtime.FlowHandler;
@@ -86,24 +87,9 @@
/**
* Add an {@link ExclusiveGateway} with a given name
*/
- ProcessBuilder addExclusiveDataBasedGateway(String name);
+ ProcessBuilder addGateway(String name, GatewayType type);
/**
- * Add an {@link InclusiveGateway} with a given name
- */
- ProcessBuilder addInclusiveGateway(String name);
-
- /**
- * Add a {@link ComplexGateway} with a given name
- */
- ProcessBuilder addComplexGateway(String name);
-
- /**
- * Add a {@link ParallelGateway} with a given name
- */
- ProcessBuilder addParallelGateway(String name);
-
- /**
* Add an {@link ExecutionHandler} with a given Class
*/
ProcessBuilder addExecutionHandler(Class<?> clazz);
Modified: jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/TaskBuilder.java
===================================================================
--- jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/TaskBuilder.java 2008-07-25 12:49:54 UTC (rev 1727)
+++ jbossbpm/spec/trunk/modules/api/src/main/java/org/jboss/bpm/model/TaskBuilder.java 2008-07-25 13:01:49 UTC (rev 1728)
@@ -25,7 +25,7 @@
//$Id$
/**
- * The ProcessBuilder can be used to build a {@link Process} dynamically.
+ * The TaskBuilder can be used to build a {@link Task} dynamically.
*
* @author thomas.diesler(a)jboss.com
* @since 08-Jul-2008
Modified: jbossbpm/spec/trunk/modules/dialects/api10/src/main/java/org/jboss/bpm/dialect/api10/ProcessUnmarshaller.java
===================================================================
--- jbossbpm/spec/trunk/modules/dialects/api10/src/main/java/org/jboss/bpm/dialect/api10/ProcessUnmarshaller.java 2008-07-25 12:49:54 UTC (rev 1727)
+++ jbossbpm/spec/trunk/modules/dialects/api10/src/main/java/org/jboss/bpm/dialect/api10/ProcessUnmarshaller.java 2008-07-25 13:01:49 UTC (rev 1728)
@@ -48,6 +48,7 @@
import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.ProcessBuilder;
import org.jboss.bpm.model.ProcessBuilderFactory;
+import org.jboss.bpm.model.Gateway.GatewayType;
import org.jboss.bpm.model.Task.TaskType;
@@ -124,28 +125,28 @@
private void adaptExclusiveGateway(ProcessBuilder builder, JAXBExclusiveGateway jaxb)
{
- builder.addExclusiveDataBasedGateway(jaxb.getName());
+ builder.addGateway(jaxb.getName(), GatewayType.Exclusive);
for(JAXBFlow flow : jaxb.getOutFlows())
builder.addSequenceFlow(flow.getTargetName());
}
private void adaptInclusiveGateway(ProcessBuilder builder, JAXBInclusiveGateway jaxb)
{
- builder.addInclusiveGateway(jaxb.getName());
+ builder.addGateway(jaxb.getName(), GatewayType.Inclusive);
for(JAXBFlow flow : jaxb.getOutFlows())
builder.addSequenceFlow(flow.getTargetName());
}
private void adaptComplexGateway(ProcessBuilder builder, JAXBComplexGateway jaxb)
{
- builder.addComplexGateway(jaxb.getName());
+ builder.addGateway(jaxb.getName(), GatewayType.Complex);
for(JAXBFlow flow : jaxb.getOutFlows())
builder.addSequenceFlow(flow.getTargetName());
}
private void adaptParallelGateway(ProcessBuilder builder, JAXBParallelGateway jaxb)
{
- builder.addParallelGateway(jaxb.getName());
+ builder.addGateway(jaxb.getName(), GatewayType.Parallel);
for(JAXBFlow flow : jaxb.getOutFlows())
builder.addSequenceFlow(flow.getTargetName());
}
Modified: jbossbpm/spec/trunk/modules/dialects/jpdl32/src/main/java/org/jboss/bpm/dialect/jpdl32/ProcessDefinitionAdapter.java
===================================================================
--- jbossbpm/spec/trunk/modules/dialects/jpdl32/src/main/java/org/jboss/bpm/dialect/jpdl32/ProcessDefinitionAdapter.java 2008-07-25 12:49:54 UTC (rev 1727)
+++ jbossbpm/spec/trunk/modules/dialects/jpdl32/src/main/java/org/jboss/bpm/dialect/jpdl32/ProcessDefinitionAdapter.java 2008-07-25 13:01:49 UTC (rev 1728)
@@ -37,6 +37,7 @@
import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.ProcessBuilder;
import org.jboss.bpm.model.ProcessBuilderFactory;
+import org.jboss.bpm.model.Gateway.GatewayType;
import org.jboss.bpm.model.Task.TaskType;
import org.jboss.bpm.runtime.ExecutionHandler;
@@ -123,7 +124,7 @@
private void adaptFork(ProcessBuilder builder, JPDL32Fork jpdlObj)
{
- builder.addParallelGateway(jpdlObj.getName());
+ builder.addGateway(jpdlObj.getName(), GatewayType.Parallel);
adaptTransitions(builder, jpdlObj.getScriptOrDescriptionOrEvent());
}
Modified: jbossbpm/spec/trunk/modules/dialects/stp/src/main/java/org/jboss/bpm/dialect/stp/ProcessUnmarshaller.java
===================================================================
--- jbossbpm/spec/trunk/modules/dialects/stp/src/main/java/org/jboss/bpm/dialect/stp/ProcessUnmarshaller.java 2008-07-25 12:49:54 UTC (rev 1727)
+++ jbossbpm/spec/trunk/modules/dialects/stp/src/main/java/org/jboss/bpm/dialect/stp/ProcessUnmarshaller.java 2008-07-25 13:01:49 UTC (rev 1728)
@@ -45,6 +45,7 @@
import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.ProcessBuilder;
import org.jboss.bpm.model.ProcessBuilderFactory;
+import org.jboss.bpm.model.Gateway.GatewayType;
import org.jboss.bpm.model.Task.TaskType;
import org.jboss.util.xml.DOMUtils;
import org.w3c.dom.Document;
@@ -172,13 +173,13 @@
else if (activityType == ActivityType.GATEWAY_DATA_BASED_EXCLUSIVE)
{
String name = stpActivity.getLabel();
- builder.addExclusiveDataBasedGateway(name);
+ builder.addGateway(name, GatewayType.Exclusive);
adaptOutgoingEdges(builder, stpActivity);
}
else if (activityType == ActivityType.GATEWAY_PARALLEL)
{
String name = stpActivity.getLabel();
- builder.addParallelGateway(name);
+ builder.addGateway(name, GatewayType.Parallel);
adaptOutgoingEdges(builder, stpActivity);
}
else
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ComplexGatewayImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ComplexGatewayImpl.java 2008-07-25 12:49:54 UTC (rev 1727)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ComplexGatewayImpl.java 2008-07-25 13:01:49 UTC (rev 1728)
@@ -23,12 +23,9 @@
//$Id$
-import java.util.List;
-
import org.jboss.bpm.NotImplementedException;
import org.jboss.bpm.model.ComplexGateway;
import org.jboss.bpm.model.Expression;
-import org.jboss.bpm.model.Gate;
/**
* A Complex Gateway handles situations that are not easily handled through the other types of Gateways. Complex
@@ -45,26 +42,21 @@
super(name);
}
- public Expression getIncommingCondition()
+ public GatewayType getGatewayType()
{
- throw new NotImplementedException();
+ return GatewayType.Complex;
}
- public Expression getOutgoingCondition()
+ public Expression getIncommingCondition()
{
throw new NotImplementedException();
}
- public List<Gate> getGates()
+ public Expression getOutgoingCondition()
{
throw new NotImplementedException();
}
- public GatewayType getGatewayType()
- {
- throw new NotImplementedException();
- }
-
public String toString()
{
return "ComplexGateway[" + getName() + "]";
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/FlowObjectImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/FlowObjectImpl.java 2008-07-25 12:49:54 UTC (rev 1727)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/FlowObjectImpl.java 2008-07-25 13:01:49 UTC (rev 1728)
@@ -25,6 +25,8 @@
import org.jboss.bpm.NameNotUniqueException;
import org.jboss.bpm.model.Flow;
import org.jboss.bpm.model.FlowObject;
+import org.jboss.bpm.model.Gate;
+import org.jboss.bpm.model.Gateway;
import org.jboss.bpm.model.MultipleInFlowSupport;
import org.jboss.bpm.model.MultipleOutFlowSupport;
import org.jboss.bpm.model.NameSupport;
@@ -80,9 +82,18 @@
for (Flow flow : mof.getOutFlows())
{
outFlow = flow;
- initFlow(proc, (FlowImpl)flow);
+ initFlow(proc, (FlowImpl)outFlow);
}
}
+ else if (this instanceof Gateway)
+ {
+ Gateway gateway = (Gateway)this;
+ for (Gate gate : gateway.getGates())
+ {
+ outFlow = gate.getOutgoingSequenceFlow();
+ initFlow(proc, (FlowImpl)outFlow);
+ }
+ }
Flow inFlow = null;
if (this instanceof SingleInFlowSupport)
Added: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GateImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GateImpl.java (rev 0)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GateImpl.java 2008-07-25 13:01:49 UTC (rev 1728)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.model.internal;
+
+//$Id$
+
+import java.util.List;
+
+import org.jboss.bpm.NotImplementedException;
+import org.jboss.bpm.model.Assignment;
+import org.jboss.bpm.model.Gate;
+import org.jboss.bpm.model.Gateway;
+import org.jboss.bpm.model.SequenceFlow;
+
+/**
+ * A {@link Gate} associated with a {@link Gateway}.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public class GateImpl extends SupportingElementImpl implements Gate
+{
+ private SequenceFlow seqFlow;
+
+ public GateImpl(String targetName)
+ {
+ seqFlow = new SequenceFlowImpl(targetName);
+ }
+
+ public SequenceFlow getOutgoingSequenceFlow()
+ {
+ return seqFlow;
+ }
+
+ public List<Assignment> getAssignments()
+ {
+ throw new NotImplementedException();
+ }
+}
Property changes on: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GateImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayBuilderImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayBuilderImpl.java (rev 0)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayBuilderImpl.java 2008-07-25 13:01:49 UTC (rev 1728)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bpm.model.internal;
+
+//$Id$
+
+import org.jboss.bpm.model.Gate;
+import org.jboss.bpm.model.Gateway;
+import org.jboss.bpm.model.GatewayBuilder;
+
+/**
+ * The GatewayBuilder can be used to build a {@link Gateway} dynamically.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public class GatewayBuilderImpl extends ProcessBuilderImpl implements GatewayBuilder
+{
+ private Gate gate;
+
+ public GatewayBuilderImpl(ProcessImpl proc, FlowObjectImpl flowObject)
+ {
+ super(proc, flowObject);
+ }
+
+ public GatewayBuilder addGate(String targetName)
+ {
+ gate = new GateImpl(targetName);
+ getGateway().addGate(gate);
+ return this;
+ }
+
+ private GatewayImpl getGateway()
+ {
+ if (flowObject instanceof Gateway == false)
+ throw new IllegalStateException("Last added flow object is not a Gateway");
+ return (GatewayImpl)flowObject;
+ }
+}
\ No newline at end of file
Property changes on: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayBuilderImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayImpl.java 2008-07-25 12:49:54 UTC (rev 1727)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/GatewayImpl.java 2008-07-25 13:01:49 UTC (rev 1728)
@@ -49,17 +49,17 @@
* @author thomas.diesler(a)jboss.com
* @since 08-Jul-2008
*/
-public abstract class GatewayImpl extends FlowObjectImpl implements Gateway, HandlerSetterSupport, MultipleInFlowSetterSupport, MultipleOutFlowSetterSupport
+public abstract class GatewayImpl extends FlowObjectImpl implements Gateway, HandlerSetterSupport, MultipleInFlowSetterSupport
{
// provide logging
private static final Log log = LogFactory.getLog(GatewayImpl.class);
private String name;
protected List<Flow> inFlows = new ArrayList<Flow>();
- protected List<Flow> outFlows = new ArrayList<Flow>();
private ExecutionHandler executionHandler;
private FlowHandler flowHandler;
private SignalHandler signalHandler;
+ private List<Gate> gates = new ArrayList<Gate>();
public GatewayImpl(String name)
{
@@ -73,19 +73,14 @@
public List<Gate> getGates()
{
- throw new NotImplementedException();
+ return Collections.unmodifiableList(gates);
}
- public List<Flow> getOutFlows()
+ public void addGate(Gate gate)
{
- return Collections.unmodifiableList(outFlows);
+ gates.add(gate);
}
-
- public void addOutFlow(Flow flow)
- {
- outFlows.add(flow);
- }
-
+
public List<Flow> getInFlows()
{
return Collections.unmodifiableList(inFlows);
@@ -120,13 +115,13 @@
public FlowHandler getFlowHandler()
{
FlowHandler handler = flowHandler;
- if (handler == null && outFlows.size() == 1)
+ if (handler == null && gates.size() == 1)
{
handler = new FlowHandler()
{
public void execute(FlowScheduler scheduler, Token token)
{
- Tuple tuple = new Tuple(outFlows.get(0), token);
+ Tuple tuple = new Tuple(gates.get(0).getOutgoingSequenceFlow(), token);
scheduler.scheduleTuple(tuple);
}
};
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/InclusiveGatewayImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/InclusiveGatewayImpl.java 2008-07-25 12:49:54 UTC (rev 1727)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/InclusiveGatewayImpl.java 2008-07-25 13:01:49 UTC (rev 1728)
@@ -28,6 +28,7 @@
import org.jboss.bpm.NotImplementedException;
import org.jboss.bpm.model.Gate;
import org.jboss.bpm.model.InclusiveGateway;
+import org.jboss.bpm.model.Gateway.GatewayType;
@@ -46,21 +47,16 @@
super(name);
}
- public Gate getDefaultGate()
+ public GatewayType getGatewayType()
{
- throw new NotImplementedException();
+ return GatewayType.Inclusive;
}
- public List<Gate> getGates()
+ public Gate getDefaultGate()
{
throw new NotImplementedException();
}
- public GatewayType getGatewayType()
- {
- throw new NotImplementedException();
- }
-
public String toString()
{
return "InclusiveGateway[" + getName() + "]";
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ParallelGatewayImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ParallelGatewayImpl.java 2008-07-25 12:49:54 UTC (rev 1727)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ParallelGatewayImpl.java 2008-07-25 13:01:49 UTC (rev 1728)
@@ -48,14 +48,9 @@
super(name);
}
- public List<Gate> getGates()
- {
- throw new NotImplementedException();
- }
-
public GatewayType getGatewayType()
{
- throw new NotImplementedException();
+ return GatewayType.Parallel;
}
/**
@@ -70,9 +65,9 @@
{
public void execute(FlowScheduler scheduler, Token token)
{
- for(Flow outFlow : getOutFlows())
+ for(Gate gate : getGates())
{
- Tuple tuple = new Tuple(outFlow, token.createCopy());
+ Tuple tuple = new Tuple(gate.getOutgoingSequenceFlow(), token.createCopy());
scheduler.scheduleTuple(tuple);
}
}
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ProcessBuilderImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ProcessBuilderImpl.java 2008-07-25 12:49:54 UTC (rev 1727)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ProcessBuilderImpl.java 2008-07-25 13:01:49 UTC (rev 1728)
@@ -24,9 +24,12 @@
//$Id$
import org.jboss.bpm.NotImplementedException;
+import org.jboss.bpm.model.Gateway;
+import org.jboss.bpm.model.GatewayBuilder;
import org.jboss.bpm.model.Process;
import org.jboss.bpm.model.ProcessBuilder;
import org.jboss.bpm.model.TaskBuilder;
+import org.jboss.bpm.model.Gateway.GatewayType;
import org.jboss.bpm.model.Task.TaskType;
import org.jboss.bpm.runtime.ExecutionHandler;
import org.jboss.bpm.runtime.FlowHandler;
@@ -75,18 +78,23 @@
return this;
}
- public ProcessBuilder addSequenceFlow(String name)
+ public ProcessBuilder addSequenceFlow(String targetName)
{
if (flowObject instanceof SingleOutFlowSetterSupport)
{
SingleOutFlowSetterSupport outFlow = (SingleOutFlowSetterSupport)flowObject;
- outFlow.setOutFlow(new SequenceFlowImpl(name));
+ outFlow.setOutFlow(new SequenceFlowImpl(targetName));
}
else if (flowObject instanceof MultipleOutFlowSetterSupport)
{
MultipleOutFlowSetterSupport outFlow = (MultipleOutFlowSetterSupport)flowObject;
- outFlow.addOutFlow(new SequenceFlowImpl(name));
+ outFlow.addOutFlow(new SequenceFlowImpl(targetName));
}
+ else if (flowObject instanceof Gateway)
+ {
+ GatewayBuilder gwBuilder = new GatewayBuilderImpl(proc, flowObject);
+ gwBuilder.addGate(targetName);
+ }
else
{
throw new IllegalStateException("Cannot add a sequence flow to: " + flowObject);
@@ -94,17 +102,17 @@
return this;
}
- public ProcessBuilder addMessageFlow(String name)
+ public ProcessBuilder addMessageFlow(String targetName)
{
if (flowObject instanceof SingleOutFlowSetterSupport)
{
SingleOutFlowSetterSupport outFlow = (SingleOutFlowSetterSupport)flowObject;
- outFlow.setOutFlow(new MessageFlowImpl(name));
+ outFlow.setOutFlow(new MessageFlowImpl(targetName));
}
else if (flowObject instanceof MultipleOutFlowSetterSupport)
{
MultipleOutFlowSetterSupport outFlow = (MultipleOutFlowSetterSupport)flowObject;
- outFlow.addOutFlow(new MessageFlowImpl(name));
+ outFlow.addOutFlow(new MessageFlowImpl(targetName));
}
else
{
@@ -152,34 +160,28 @@
return new TaskBuilderImpl(proc, flowObject);
}
- public ProcessBuilder addExclusiveDataBasedGateway(String name)
+ public ProcessBuilder addGateway(String name, GatewayType type)
{
- flowObject = new ExclusiveGatewayDataBasedImpl(name);
+ if (GatewayType.Exclusive == type)
+ {
+ flowObject = new ExclusiveGatewayDataBasedImpl(name);
+ }
+ else if (GatewayType.Inclusive == type)
+ {
+ flowObject = new InclusiveGatewayImpl(name);
+ }
+ else if (GatewayType.Parallel == type)
+ {
+ flowObject = new ParallelGatewayImpl(name);
+ }
+ else if (GatewayType.Complex == type)
+ {
+ flowObject = new ComplexGatewayImpl(name);
+ }
addFlowObject();
return this;
}
-
- public ProcessBuilder addInclusiveGateway(String name)
- {
- flowObject = new InclusiveGatewayImpl(name);
- addFlowObject();
- return this;
- }
-
- public ProcessBuilder addComplexGateway(String name)
- {
- flowObject = new ComplexGatewayImpl(name);
- addFlowObject();
- return this;
- }
-
- public ProcessBuilder addParallelGateway(String name)
- {
- flowObject = new ParallelGatewayImpl(name);
- addFlowObject();
- return this;
- }
-
+
public ProcessBuilder addExecutionHandler(Class<?> clazz)
{
return addHandler(clazz);
Modified: jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ReceiveTaskImpl.java
===================================================================
--- jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ReceiveTaskImpl.java 2008-07-25 12:49:54 UTC (rev 1727)
+++ jbossbpm/spec/trunk/modules/ri/src/main/java/org/jboss/bpm/model/internal/ReceiveTaskImpl.java 2008-07-25 13:01:49 UTC (rev 1728)
@@ -21,6 +21,9 @@
*/
package org.jboss.bpm.model.internal;
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.bpm.InvalidProcessException;
@@ -54,7 +57,7 @@
// A Web service is the default technology
private Implementation implementation = Implementation.WebService;
private Message messageRef;
- private Message receivedMessage;
+ private List<Message> messages = new ArrayList<Message>();
public ReceiveTaskImpl(String name)
{
@@ -98,7 +101,7 @@
if (message.getProperty(name) == null)
throw new IllegalArgumentException("Received message does not contain expected property: " + name);
}
- this.receivedMessage = message;
+ messages.add(message);
}
else
{
@@ -120,7 +123,7 @@
// Wait for the message to arrive
long now = System.currentTimeMillis();
long until = now + RECEIVE_TIMEOUT;
- while (receivedMessage == null && now < until)
+ while (messages.size() == 0 && now < until)
{
try
{
@@ -134,16 +137,17 @@
}
// Timeout if the message did not arrive
- if (receivedMessage == null)
+ if (messages.size() == 0)
throw new ProcessTimeoutException("Message receive timeout in: " + task);
// Copy the expected properties from the
// received message to the execution context
ExecutionContext exContext = token.getExecutionContext();
+ Message msg = messages.remove(0);
for (Property prop : messageRef.getProperties())
{
String key = prop.getName();
- Expression value = receivedMessage.getProperty(key).getValue();
+ Expression value = msg.getProperty(key).getValue();
exContext.addAttachment(key, value);
}
}
Modified: jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java
===================================================================
--- jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java 2008-07-25 12:49:54 UTC (rev 1727)
+++ jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/airticket/AirticketTest.java 2008-07-25 13:01:49 UTC (rev 1728)
@@ -95,7 +95,7 @@
addMessageProperty("Seats", null, true).
addSequenceFlow("End");
- Process proc = procBuilder.addEndEvent("End").getProcess();
+ Process proc = procBuilder.addGateway("Validate", null).addEndEvent("End").getProcess();
// Register the Process with the ProcessManager
ProcessManager pm = ProcessManager.locateProcessManager();
Modified: jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/parallelsplit/ParallelSplitTest.java
===================================================================
--- jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/parallelsplit/ParallelSplitTest.java 2008-07-25 12:49:54 UTC (rev 1727)
+++ jbossbpm/spec/trunk/modules/testsuite/src/test/java/org/jboss/bpm/samples/parallelsplit/ParallelSplitTest.java 2008-07-25 13:01:49 UTC (rev 1728)
@@ -33,6 +33,7 @@
import org.jboss.bpm.model.ProcessBuilder;
import org.jboss.bpm.model.ProcessBuilderFactory;
import org.jboss.bpm.model.Signal;
+import org.jboss.bpm.model.Gateway.GatewayType;
import org.jboss.bpm.test.DefaultEngineTestCase;
/**
@@ -71,7 +72,7 @@
{
// Create a Process through the ProcessBuilder
ProcessBuilder procBuilder = ProcessBuilderFactory.newInstance().newProcessBuilder();
- Process proc = procBuilder.addProcess(getName()).addStartEvent().addSequenceFlow("gateway").addParallelGateway("gateway").
+ Process proc = procBuilder.addProcess(getName()).addStartEvent().addSequenceFlow("gateway").addGateway("gateway", GatewayType.Parallel).
addSequenceFlow("endA").addSequenceFlow("endB").addEndEvent("endA").addEndEvent("endB").getProcess();
// Register the Process with the ProcessManager
17 years, 9 months
JBoss JBPM SVN: r1727 - in jbpm4/pvm/trunk/modules/core/src: test/java/org/jbpm and 2 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-07-25 08:49:54 -0400 (Fri, 25 Jul 2008)
New Revision: 1727
Added:
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env/
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env/EnvironmentTests.java
Removed:
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/env/
Modified:
jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/wire.xsd
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/NonDbTests.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env/BasicEnvironmentTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env/EnvironmentClassLoaderTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env/EnvironmentSearchOrderTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env/EnvironmentTypeLookupTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env/NestedEnvironmentTest.java
Log:
renamed environment test package
Modified: jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/wire.xsd
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/wire.xsd 2008-07-25 12:29:12 UTC (rev 1726)
+++ jbpm4/pvm/trunk/modules/core/src/main/resources/org/jbpm/pvm/wire.xsd 2008-07-25 12:49:54 UTC (rev 1727)
@@ -827,7 +827,7 @@
</element>
<element name="transaction-ref">
- <annotation><documentation>Reference to the org.jbpm.env.tx.Transaction in the
+ <annotation><documentation>Reference to the org.jbpm.pvm.env.Transaction in the
current environment.
</documentation></annotation>
</element>
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/NonDbTests.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/NonDbTests.java 2008-07-25 12:29:12 UTC (rev 1726)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/NonDbTests.java 2008-07-25 12:49:54 UTC (rev 1727)
@@ -25,6 +25,7 @@
import junit.framework.TestSuite;
import org.jbpm.pvm.basicfeatures.PvmClientTests;
+import org.jbpm.pvm.env.EnvironmentTests;
import org.jbpm.wire.WireTests;
@@ -36,6 +37,7 @@
public static Test suite() {
TestSuite suite = new TestSuite("Test for org.jbpm.pvm");
//$JUnit-BEGIN$
+ suite.addTest(EnvironmentTests.suite());
suite.addTest(PvmClientTests.suite());
suite.addTest(WireTests.suite());
//$JUnit-END$
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env (from rev 1720, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/env)
Property changes on: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env/BasicEnvironmentTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/env/BasicEnvironmentTest.java 2008-07-25 09:50:20 UTC (rev 1720)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env/BasicEnvironmentTest.java 2008-07-25 12:49:54 UTC (rev 1727)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jbpm.env;
+package org.jbpm.pvm.env;
import org.jbpm.pvm.test.base.JbpmTestCase;
import org.jbpm.pvm.env.Context;
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env/EnvironmentClassLoaderTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/env/EnvironmentClassLoaderTest.java 2008-07-25 09:50:20 UTC (rev 1720)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env/EnvironmentClassLoaderTest.java 2008-07-25 12:49:54 UTC (rev 1727)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jbpm.env;
+package org.jbpm.pvm.env;
import org.jbpm.pvm.test.base.JbpmTestCase;
import org.jbpm.pvm.env.Environment;
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env/EnvironmentSearchOrderTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/env/EnvironmentSearchOrderTest.java 2008-07-25 09:50:20 UTC (rev 1720)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env/EnvironmentSearchOrderTest.java 2008-07-25 12:49:54 UTC (rev 1727)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jbpm.env;
+package org.jbpm.pvm.env;
import org.jbpm.pvm.test.base.JbpmTestCase;
import org.jbpm.pvm.env.Environment;
Added: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env/EnvironmentTests.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env/EnvironmentTests.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env/EnvironmentTests.java 2008-07-25 12:49:54 UTC (rev 1727)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.env;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class EnvironmentTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Test for org.jbpm.pvm.env");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(EnvironmentTypeLookupTest.class);
+ suite.addTestSuite(NestedEnvironmentTest.class);
+ suite.addTestSuite(BasicEnvironmentTest.class);
+ suite.addTestSuite(EnvironmentSearchOrderTest.class);
+ suite.addTestSuite(EnvironmentClassLoaderTest.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env/EnvironmentTypeLookupTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/env/EnvironmentTypeLookupTest.java 2008-07-25 09:50:20 UTC (rev 1720)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env/EnvironmentTypeLookupTest.java 2008-07-25 12:49:54 UTC (rev 1727)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jbpm.env;
+package org.jbpm.pvm.env;
import org.jbpm.pvm.test.base.JbpmTestCase;
import org.jbpm.pvm.env.Environment;
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env/NestedEnvironmentTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/env/NestedEnvironmentTest.java 2008-07-25 09:50:20 UTC (rev 1720)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/env/NestedEnvironmentTest.java 2008-07-25 12:49:54 UTC (rev 1727)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jbpm.env;
+package org.jbpm.pvm.env;
import org.jbpm.pvm.test.base.JbpmTestCase;
import org.jbpm.pvm.env.Environment;
17 years, 9 months
JBoss JBPM SVN: r1726 - jbpm4/pvm/trunk/modules/core.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-07-25 08:29:12 -0400 (Fri, 25 Jul 2008)
New Revision: 1726
Modified:
jbpm4/pvm/trunk/modules/core/pom.xml
Log:
excluded transitive dependencies for seam
Modified: jbpm4/pvm/trunk/modules/core/pom.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/pom.xml 2008-07-25 12:09:19 UTC (rev 1725)
+++ jbpm4/pvm/trunk/modules/core/pom.xml 2008-07-25 12:29:12 UTC (rev 1726)
@@ -94,6 +94,16 @@
<dependency>
<groupId>org.jboss.seam</groupId>
<artifactId>jboss-seam</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.el</groupId>
+ <artifactId>jboss-el</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
17 years, 9 months