### Eclipse Workspace Patch 1.0 #P jbpm4 Index: modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ForkActivity.java =================================================================== --- modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ForkActivity.java (revision 6403) +++ modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ForkActivity.java (working copy) @@ -92,7 +92,9 @@ } for (Entry entry : concurrentExecutions.entrySet()) { - entry.getValue().take(entry.getKey()); + if (!entry.getValue().isEnded()) { + entry.getValue().take(entry.getKey()); + } if (concurrentRoot.isEnded()) break; } } Index: modules/test-db/src/test/java/org/jbpm/test/activity/forkjoin/ForkDecisionJoinTest.java =================================================================== --- modules/test-db/src/test/java/org/jbpm/test/activity/forkjoin/ForkDecisionJoinTest.java (revision 0) +++ modules/test-db/src/test/java/org/jbpm/test/activity/forkjoin/ForkDecisionJoinTest.java (revision 0) @@ -0,0 +1,141 @@ +/* + * 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.test.activity.forkjoin; + +import org.jbpm.api.ProcessInstance; +import org.jbpm.test.JbpmTestCase; + +/** + * + * @author Maciej Swiderski + * + */ +public class ForkDecisionJoinTest extends JbpmTestCase { + + public void testForkWithNestedDecision() { + deployJpdlXmlString(" " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " "); + + ProcessInstance pi = executionService.startProcessInstanceByKey("ForkJoinTest"); + + assertProcessInstanceEnded(pi); + } + + public void testForkWithNestedForkWithTasks() { + deployJpdlXmlString(" " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " "); + + ProcessInstance pi = executionService.startProcessInstanceByKey("ForkJoinTest"); + taskService.completeTask(taskService.createTaskQuery().list().get(0).getId()); + assertProcessInstanceEnded(pi); + } + + public void testForkWithNestedFork() { + deployJpdlXmlString(" " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " "); + + ProcessInstance pi = executionService.startProcessInstanceByKey("ForkJoinTest"); + + assertProcessInstanceEnded(pi); + } + +} Property changes on: modules\test-db\src\test\java\org\jbpm\test\activity\forkjoin\ForkDecisionJoinTest.java ___________________________________________________________________ Added: svn:keywords + Id Revision Added: svn:eol-style + LF Index: modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java =================================================================== --- modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java (revision 6596) +++ modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java (working copy) @@ -38,13 +38,18 @@ /** * @author Tom Baeyens + * @author Maciej Swiderski */ public class JoinActivity extends JpdlActivity { private static final long serialVersionUID = 1L; + + public static final String PARALLEL_GATEWAY_TYPE = "parallel"; + public static final String EXCLUSIVE_GATEWAY_TYPE = "exclusive"; private String lockMode = "UPGRADE"; private Expression multiplicity; + private String gatewayType = PARALLEL_GATEWAY_TYPE; public void execute(ActivityExecution execution) { execute((ExecutionImpl)execution); @@ -52,7 +57,10 @@ public void execute(ExecutionImpl execution) { ActivityImpl activity = execution.getActivity(); - + + // discover gateway type + discoverGatewayType(activity); + // if this is a single, non concurrent root if (Execution.STATE_ACTIVE_ROOT.equals(execution.getState())) { // just pass through @@ -77,7 +85,7 @@ if (isComplete(execution, joinedExecutions)) { endExecutions(joinedExecutions); // if multiplicity was used - if (multiplicity != null) { + if (multiplicity != null && PARALLEL_GATEWAY_TYPE.equalsIgnoreCase(gatewayType)) { // collect concurrent executions still active List danglingExecutions = new ArrayList(); for (ExecutionImpl concurrentExecution : concurrentRoot.getExecutions()) { @@ -110,6 +118,15 @@ } } + private void discoverGatewayType(ActivityImpl activity) { + List< ? extends Transition> incoming = activity.getIncomingTransitions(); + for (Transition t : incoming) { + if("decision".equalsIgnoreCase(t.getSource().getType())) { + gatewayType = EXCLUSIVE_GATEWAY_TYPE; + } + } + } + protected boolean isComplete(ExecutionImpl execution, List joinedExecutions) { int executionsToJoin; if (multiplicity != null) { @@ -160,4 +177,5 @@ public void setMultiplicity(Expression multiplicity) { this.multiplicity = multiplicity; } + }