### Eclipse Workspace Patch 1.0 #P jbpm4 Index: modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml =================================================================== --- modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml (revision 6555) +++ modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml (working copy) @@ -529,6 +529,17 @@ arrived at the join, causing a process deadlock. + + gateway-type + {parallel, exclusive} + parallel + optional + indicates type of the gateway that this join is converging. Since jBPM has + several types of nodes that diverges (fork, for-each, decision) and only one that converge, + there is a need to distinguish them to perform additional operations + (ending forked but not joined executions when fork or for-each was used). + + Index: modules/api/src/main/resources/jpdl-4.5.xsd =================================================================== --- modules/api/src/main/resources/jpdl-4.5.xsd (revision 6588) +++ modules/api/src/main/resources/jpdl-4.5.xsd (working copy) @@ -291,6 +291,14 @@ + + + + + + + + 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,111 @@ +/* + * 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 testForkWithNestedDecisionWrongGatewayType() { + + try { + deployJpdlXmlString(" " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " "); + + + executionService.startProcessInstanceByKey("ForkJoinTest"); + + fail("Should fail since pararrer in not valid gateway type"); + + } catch (Exception e) { + assertEquals("error: pararrer is not a valid gateway type", e.getMessage().trim()); + } + } + +} 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/JoinBinding.java =================================================================== --- modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinBinding.java (revision 6596) +++ modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinBinding.java (working copy) @@ -37,6 +37,8 @@ private static final String MULTIPLICITY = "multiplicity"; private static final String LOCKMODE = "lockmode"; + + private static final String GATEWAY_TYPE = "gateway-type"; public JoinBinding() { super("join"); @@ -60,6 +62,14 @@ joinActivity.setLockMode(lockModeText); } } + + if (element.hasAttribute(GATEWAY_TYPE)) { + String gatewayType = element.getAttribute(GATEWAY_TYPE); + if (!JoinActivity.EXCLUSIVE_GATEWAY_TYPE.equalsIgnoreCase(gatewayType) && !JoinActivity.PARALLEL_GATEWAY_TYPE.equalsIgnoreCase(gatewayType)) { + parse.addProblem(gatewayType + " is not a valid gateway type", element); + } + joinActivity.setGatewayType(gatewayType); + } return joinActivity; } 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); @@ -77,7 +82,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()) { @@ -160,4 +165,8 @@ public void setMultiplicity(Expression multiplicity) { this.multiplicity = multiplicity; } + public void setGatewayType(String gatewayType) { + this.gatewayType = gatewayType; + } + }