[jbpm-commits] JBoss JBPM SVN: r4869 - in jbpm4/trunk/modules: examples/src/test/java/org/jbpm/examples/async/fork and 6 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu May 21 06:49:13 EDT 2009
Author: tom.baeyens at jboss.com
Date: 2009-05-21 06:49:13 -0400 (Thu, 21 May 2009)
New Revision: 4869
Added:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/Application.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/AsyncForkTest.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/activity/process.png
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/fork/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/fork/process.jpdl.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/fork/process.png
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/AsyncContinuations.java
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.async.activity.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.async.fork.png
Modified:
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/activity/process.jpdl.xml
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivityMessage.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivityMessage.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivityMessage.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTakeMessage.java
Log:
JBPM-2256 async fork
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/Application.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/Application.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/Application.java 2009-05-21 10:49:13 UTC (rev 4869)
@@ -0,0 +1,35 @@
+/*
+ * 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.examples.async.fork;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Application {
+
+ public void shipGoods() {
+ }
+
+ public void sendBill() {
+ }
+}
Property changes on: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/Application.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/AsyncForkTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/AsyncForkTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/AsyncForkTest.java 2009-05-21 10:49:13 UTC (rev 4869)
@@ -0,0 +1,72 @@
+/*
+ * 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.examples.async.fork;
+
+import java.util.List;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.job.Job;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AsyncForkTest extends JbpmTestCase {
+
+ long deploymentDbid;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ deploymentDbid = repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/examples/async/fork/process.jpdl.xml")
+ .deploy();
+ }
+
+ protected void tearDown() throws Exception {
+ repositoryService.deleteDeploymentCascade(deploymentDbid);
+
+ super.tearDown();
+ }
+
+ public void testAsyncFork() {
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncFork");
+ String processInstanceId = processInstance.getId();
+
+ List<Job> jobs = managementService.createJobQuery()
+ .processInstanceId(processInstanceId)
+ .list();
+
+ System.out.println(jobs);
+
+ assertEquals(2, jobs.size());
+
+ Job job = jobs.get(0);
+
+ managementService.executeJob(job.getDbid());
+
+ job = jobs.get(1);
+
+ managementService.executeJob(job.getDbid());
+ }
+}
Property changes on: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/AsyncForkTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/activity/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/activity/process.jpdl.xml 2009-05-21 10:22:53 UTC (rev 4868)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/activity/process.jpdl.xml 2009-05-21 10:49:13 UTC (rev 4869)
@@ -22,6 +22,6 @@
<transition to="end"/>
</java>
- <end name="end" g="452,28,80,40"/>
+ <end name="end" g="330,28,80,40"/>
</process>
\ No newline at end of file
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/activity/process.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/activity/process.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/fork/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/fork/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/fork/process.jpdl.xml 2009-05-21 10:49:13 UTC (rev 4869)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="AsyncFork" xmlns="http://jbpm.org/4.0/jpdl">
+
+ <start g="22,69,80,40">
+ <transition to="fork"/>
+ </start>
+
+ <fork g="99,68,80,40" name="fork">
+ <on event="end" continue="exclusive" />
+ <transition g="122,41:" to="ship goods"/>
+ <transition g="123,142:" to="send bill"/>
+ </fork>
+
+ <java class="org.jbpm.examples.async.fork.Application" g="159,17,98,50" method="shipGoods" name="ship goods">
+ <transition g="297,42:" to="join"/>
+ </java>
+
+ <java class="org.jbpm.examples.async.fork.Application" g="159,117,98,50" method="sendBill" name="send bill">
+ <transition g="297,141:" to="join"/>
+ </java>
+
+ <join g="274,66,80,40" name="join">
+ <transition to="end"/>
+ </join>
+
+ <end g="353,67,48,48" name="end"/>
+
+</process>
Property changes on: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/fork/process.jpdl.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/fork/process.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/fork/process.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java 2009-05-21 10:22:53 UTC (rev 4868)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java 2009-05-21 10:49:13 UTC (rev 4869)
@@ -54,6 +54,9 @@
if (Execution.STATE_ACTIVE_ROOT.equals(execution.getState())) {
// just pass through
Transition transition = activity.getDefaultOutgoingTransition();
+ if (transition==null) {
+ throw new JbpmException("join must have an outgoing transition");
+ }
execution.take(transition);
} else if (Execution.STATE_ACTIVE_CONCURRENT.equals(execution.getState())) {
@@ -78,6 +81,9 @@
execution.setActivity(activity, outgoingExecution);
Transition transition = activity.getDefaultOutgoingTransition();
+ if (transition==null) {
+ throw new JbpmException("join must have an outgoing transition");
+ }
outgoingExecution.take(transition);
}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/AsyncContinuations.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/AsyncContinuations.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/AsyncContinuations.java 2009-05-21 10:49:13 UTC (rev 4869)
@@ -0,0 +1,43 @@
+/*
+ * 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.internal.model.op;
+
+import org.jbpm.api.Execution;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class AsyncContinuations {
+
+ public static void restoreState(ExecutionImpl execution) {
+ ExecutionImpl parent = execution.getParent();
+ if ( (parent!=null)
+ && (Execution.STATE_INACTIVE_CONCURRENT_ROOT.equals(parent.getState()))
+ ) {
+ execution.setState(Execution.STATE_ACTIVE_CONCURRENT);
+ } else {
+ execution.setState(Execution.STATE_ACTIVE_ROOT);
+ }
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/AsyncContinuations.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivityMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivityMessage.java 2009-05-21 10:22:53 UTC (rev 4868)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivityMessage.java 2009-05-21 10:49:13 UTC (rev 4869)
@@ -21,7 +21,6 @@
*/
package org.jbpm.pvm.internal.model.op;
-import org.jbpm.api.Execution;
import org.jbpm.api.env.Environment;
import org.jbpm.pvm.internal.job.MessageImpl;
import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
@@ -42,7 +41,7 @@
}
public Object execute(Environment environment) throws Exception {
- execution.setState(Execution.STATE_ACTIVE_ROOT);
+ AsyncContinuations.restoreState(execution);
execution.performAtomicOperationSync(ExecutionImpl.EXECUTE_ACTIVITY);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivityMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivityMessage.java 2009-05-21 10:22:53 UTC (rev 4868)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivityMessage.java 2009-05-21 10:49:13 UTC (rev 4869)
@@ -42,7 +42,7 @@
}
public Object execute(Environment environment) throws Exception {
- execution.setState(Execution.STATE_ACTIVE_ROOT);
+ AsyncContinuations.restoreState(execution);
execution.performAtomicOperationSync(ExecutionImpl.TRANSITION_END_ACTIVITY);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivityMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivityMessage.java 2009-05-21 10:22:53 UTC (rev 4868)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivityMessage.java 2009-05-21 10:49:13 UTC (rev 4869)
@@ -42,7 +42,8 @@
}
public Object execute(Environment environment) throws Exception {
- execution.setState(Execution.STATE_ACTIVE_ROOT);
+ AsyncContinuations.restoreState(execution);
+
execution.performAtomicOperationSync(ExecutionImpl.TRANSITION_START_ACTIVITY);
JobDbSession jobDbSession = environment.get(JobDbSession.class);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTakeMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTakeMessage.java 2009-05-21 10:22:53 UTC (rev 4868)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTakeMessage.java 2009-05-21 10:49:13 UTC (rev 4869)
@@ -43,7 +43,8 @@
}
public Object execute(Environment environment) throws Exception {
- execution.setState(Execution.STATE_ACTIVE_ROOT);
+ AsyncContinuations.restoreState(execution);
+
execution.performAtomicOperationSync(ExecutionImpl.TRANSITION_TAKE);
JobDbSession jobDbSession = environment.get(JobDbSession.class);
Added: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.async.activity.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.async.activity.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.async.fork.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.async.fork.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
More information about the jbpm-commits
mailing list