[jbpm-commits] JBoss JBPM SVN: r3344 - in jbpm4/trunk/modules: api/src/main/java/org/jbpm/activity and 25 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Thu Dec 11 11:47:49 EST 2008
Author: tom.baeyens at jboss.com
Date: 2008-12-11 11:47:48 -0500 (Thu, 11 Dec 2008)
New Revision: 3344
Added:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/end/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/end/multiple/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/end/processinstance/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/end/state/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/exclusive/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/exclusive/conditions/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/exclusive/conditions/ExclusiveConditionsTest.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/exclusive/expression/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/exclusive/handler/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/state/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/state/choice/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/state/choice/StateChoiceTest.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/states/StateSequenceTest.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/exclusive/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/exclusive/conditions/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/exclusive/conditions/process.jpdl.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/state/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/state/choice/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/state/choice/process.jpdl.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/states/process.jpdl.xml
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/Execution.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/activity/ActivityExecution.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/client/ClientExecution.java
jbpm4/trunk/modules/api/src/main/resources/jpdl.xsd
jbpm4/trunk/modules/examples/
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/EndActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/EndBinding.java
jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.hbm.xml
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/EventTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ExecutionStateTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/SubProcessTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionBasedConcurrencyTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ExclusiveTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ProcessServiceTest.java
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml
Log:
more examples
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/Execution.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/Execution.java 2008-12-11 16:44:51 UTC (rev 3343)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/Execution.java 2008-12-11 16:47:48 UTC (rev 3344)
@@ -90,19 +90,12 @@
* of the constants. */
String STATE_INACTIVE = "inactive";
- /** this execution has ended normally. Make sure that comparisons are
+ /** this execution has ended. Make sure that comparisons are
* done with .equals and not with '==' because if executions are
* loaded from persistent storage, a new string is created instead
* of the constants. */
String STATE_ENDED = "ended";
- /** this execution was cancelled with the {@link #cancel()}
- * method before normal execution ended. Make sure that comparisons are
- * done with .equals and not with '==' because if executions are
- * loaded from persistent storage, a new string is created instead
- * of the constants. */
- String STATE_CANCELLED = "cancelled";
-
/** indicates that this execution is temporary suspended with the
* {@link #suspend()} method. Human tasks of a suspended execution
* shouldn't show up in people's task list and timers of suspended
@@ -144,10 +137,7 @@
/** is this execution {@link #lock(String) locked} ? This is the inverse of {@link #isActive()}. */
boolean isLocked();
- /** is this execution ended or cancelled ? */
- boolean isFinished();
-
- /** is this execution ended normally ? */
+ /** is this execution ended */
boolean isEnded();
/** is this execution suspended ? */
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/activity/ActivityExecution.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/activity/ActivityExecution.java 2008-12-11 16:44:51 UTC (rev 3343)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/activity/ActivityExecution.java 2008-12-11 16:47:48 UTC (rev 3344)
@@ -200,12 +200,8 @@
*
* <p>This method should not be called in {@link Activity}s. It can be called from
* outside the process execution and in {@link ExternalActivity}s. </p> */
- void stop();
+ void end();
- /** ends this execution and assigns the state {@link #STATE_CANCELLED}.
- * @see #stop(String) */
- void cancel();
-
/** ends this execution and all it's child executions with a user defined
* status.
*
@@ -214,8 +210,15 @@
* side effects.</p>
*
* <p>The execution will be removed from it's parent.</p> */
- void stop(String state);
+ void end(String state);
+ /** ends the given execution and all it's child executions. */
+ void end(OpenExecution executionToEnd);
+
+ /** ends the given execution and all it's child executions with a user defined
+ * status. */
+ void end(OpenExecution executionToEnd, String state);
+
// firing events ////////////////////////////////////////////////////////////
/** fires the event on the given eventSource and then propagates the event
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/client/ClientExecution.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/client/ClientExecution.java 2008-12-11 16:44:51 UTC (rev 3343)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/client/ClientExecution.java 2008-12-11 16:47:48 UTC (rev 3344)
@@ -36,30 +36,20 @@
*/
public interface ClientExecution extends OpenExecution {
- // stop /////////////////////////////////////////////////////////////////////
-
// ending an execution //////////////////////////////////////////////////////
/** ends this execution and all of its child executions.
*
- * <p>All child executions will be stopped and removed. This execution
+ * <p>All child executions will be ended and removed. This execution
* will not be removed from its parent.</p>
*
* <p>This method should not be called in {@link Activity}s. It can be called from
* outside the process execution and in {@link ExternalActivity}s. </p> */
- void stop();
+ void end();
- /** ends this execution and assigns the state {@link #STATE_CANCELLED}.
- * @see #stop(String) */
- void cancel();
-
/** ends this execution and all it's child executions with a user defined
- * status.
- *
- *
- *
- * Giving states {@link */
- void stop(String state);
+ * status. */
+ void end(String state);
// signal ///////////////////////////////////////////////////////////////////
Modified: jbpm4/trunk/modules/api/src/main/resources/jpdl.xsd
===================================================================
--- jbpm4/trunk/modules/api/src/main/resources/jpdl.xsd 2008-12-11 16:44:51 UTC (rev 3343)
+++ jbpm4/trunk/modules/api/src/main/resources/jpdl.xsd 2008-12-11 16:47:48 UTC (rev 3344)
@@ -118,6 +118,9 @@
</restriction>
</simpleType>
</attribute>
+ <attribute name="state" default="ended" type="string">
+ <annotation><documentation>sets the state of the execution explicitely</documentation></annotation>
+ </attribute>
</complexType>
</element>
@@ -148,7 +151,9 @@
</documentation></annotation>
<complexType>
<sequence>
- <element ref="tns:flow" minOccurs="0" maxOccurs="unbounded" />
+ <element ref="tns:flow" minOccurs="0" maxOccurs="unbounded">
+ <!-- TODO add conditions -->
+ </element>
<element ref="tns:on" minOccurs="0" maxOccurs="unbounded">
<annotation><documentation>Events on which listeners can be registered.</documentation></annotation>
</element>
Property changes on: jbpm4/trunk/modules/examples
___________________________________________________________________
Name: svn:ignore
+ target
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/exclusive/conditions/ExclusiveConditionsTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/exclusive/conditions/ExclusiveConditionsTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/exclusive/conditions/ExclusiveConditionsTest.java 2008-12-11 16:47:48 UTC (rev 3344)
@@ -0,0 +1,63 @@
+/*
+ * 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.exclusive.conditions;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.Execution;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveConditionsTest extends DbTestCase {
+
+ public void testExclusiveConditionsGood() {
+ deployJpdlResource("org/jbpm/examples/exclusive/conditions/process.jpdl.xml");
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("content", "good");
+ Execution execution = executionService.startExecutionByKey("ExclusiveConditions", variables);
+ assertEquals("submit document", execution.getNodeName());
+ }
+
+ public void testExclusiveConditionsBad() {
+ deployJpdlResource("org/jbpm/examples/exclusive/conditions/process.jpdl.xml");
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("content", "bad");
+ Execution execution = executionService.startExecutionByKey("ExclusiveConditions", variables);
+ assertEquals("try again", execution.getNodeName());
+ }
+
+ public void testExclusiveConditionsUgly() {
+ deployJpdlResource("org/jbpm/examples/exclusive/conditions/process.jpdl.xml");
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("content", "ugly");
+ Execution execution = executionService.startExecutionByKey("ExclusiveConditions", variables);
+ assertEquals("give up", execution.getNodeName());
+ }
+
+}
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/state/choice/StateChoiceTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/state/choice/StateChoiceTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/state/choice/StateChoiceTest.java 2008-12-11 16:47:48 UTC (rev 3344)
@@ -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.examples.state.choice;
+
+import org.jbpm.Execution;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StateChoiceTest extends DbTestCase {
+
+ public void testStateChoiceAccept() {
+ deployJpdlResource("org/jbpm/examples/state/choice/process.jpdl.xml");
+
+ Execution execution = executionService.startExecutionByKey("StateChoice");
+ String executionId = execution.getId();
+ execution = executionService.signalExecutionById(executionId, "accept");
+ assertEquals("submit document", execution.getNodeName());
+ }
+
+ public void testStateChoiceReject() {
+ deployJpdlResource("org/jbpm/examples/state/choice/process.jpdl.xml");
+
+ Execution execution = executionService.startExecutionByKey("StateChoice");
+ String executionId = execution.getId();
+ execution = executionService.signalExecutionById(executionId, "reject");
+ assertEquals("try again", execution.getNodeName());
+ }
+}
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/states/StateSequenceTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/states/StateSequenceTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/states/StateSequenceTest.java 2008-12-11 16:47:48 UTC (rev 3344)
@@ -0,0 +1,47 @@
+/*
+ * 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.state.sequence;
+
+import org.jbpm.Execution;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class StateSequenceTest extends DbTestCase {
+
+ public void testWaitStatesSequence() {
+ deployJpdlResource("org/jbpm/examples/state/sequence/process.jpdl.xml");
+
+ Execution execution = executionService.startExecutionByKey("StateSequence");
+ assertEquals("a", execution.getNodeName());
+
+ String executionId = execution.getId();
+ execution = executionService.signalExecutionById(executionId);
+ assertEquals("b", execution.getNodeName());
+
+ execution = executionService.signalExecutionById(executionId);
+ assertEquals("c", execution.getNodeName());
+ }
+
+}
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/exclusive/conditions/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/exclusive/conditions/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/exclusive/conditions/process.jpdl.xml 2008-12-11 16:47:48 UTC (rev 3344)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="ExclusiveConditions" >
+
+ <start>
+ <flow to="evaluate document" />
+ </start>
+
+ <exclusive name="evaluate document">
+ <flow to="submit document">
+ <condition expr="#{content=="good"}" />
+ </flow>
+ <flow to="try again">
+ <condition expr="#{content=="bad"}" />
+ </flow>
+ <flow to="give up" />
+ </exclusive>
+
+ <state name="submit document" />
+
+ <state name="try again" />
+
+ <state name="give up" />
+
+</process>
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/state/choice/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/state/choice/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/state/choice/process.jpdl.xml 2008-12-11 16:47:48 UTC (rev 3344)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="StateChoice" xmlns="http://jbpm.org/4/jpdl">
+
+ <start>
+ <flow to="wait for response" />
+ </start>
+
+ <state name="wait for response">
+ <flow name="accept" to="submit document" />
+ <flow name="reject" to="try again" />
+ </state>
+
+ <state name="submit document" />
+
+ <state name="try again" />
+
+</process>
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/states/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/states/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/states/process.jpdl.xml 2008-12-11 16:47:48 UTC (rev 3344)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="StateSequence" xmlns="http://jbpm.org/4/jpdl">
+
+ <start>
+ <flow to="a" />
+ </start>
+
+ <state name="a">
+ <flow to="b" />
+ </state>
+
+ <state name="b">
+ <flow to="c" />
+ </state>
+
+ <state name="c" />
+
+</process>
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/EndActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/EndActivity.java 2008-12-11 16:44:51 UTC (rev 3343)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/activity/EndActivity.java 2008-12-11 16:47:48 UTC (rev 3344)
@@ -22,6 +22,7 @@
package org.jbpm.jpdl.activity;
import org.jbpm.activity.ActivityExecution;
+import org.jbpm.model.OpenExecution;
/**
@@ -30,8 +31,30 @@
public class EndActivity extends JpdlActivity {
private static final long serialVersionUID = 1L;
+
+ protected boolean endProcessInstance = true;
+ protected String state = null;
+ public EndActivity() {
+ }
+
+ public EndActivity(boolean endProcessInstance, String state) {
+ this.endProcessInstance = endProcessInstance;
+ this.state = state;
+ }
+
public void execute(ActivityExecution execution) {
- execution.stop();
+ OpenExecution executionToEnd = null;
+ if (endProcessInstance) {
+ executionToEnd = execution.getProcessInstance();
+ } else {
+ executionToEnd = execution;
+ }
+
+ if (state==null) {
+ execution.end(executionToEnd);
+ } else {
+ execution.end(executionToEnd, state);
+ }
}
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/EndBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/EndBinding.java 2008-12-11 16:44:51 UTC (rev 3343)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/xml/EndBinding.java 2008-12-11 16:47:48 UTC (rev 3344)
@@ -22,6 +22,7 @@
package org.jbpm.jpdl.xml;
import org.jbpm.jpdl.activity.EndActivity;
+import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
@@ -37,6 +38,15 @@
}
public Object parse(Element element, Parse parse, Parser parser) {
- return new EndActivity();
+
+ boolean endProcessInstance = true;
+ String ends = XmlUtil.attribute(element, "ends", false, parse);
+ if ("execution".equalsIgnoreCase(ends)) {
+ endProcessInstance = false;
+ }
+
+ String state = XmlUtil.attribute(element, "state", false, parse);
+
+ return new EndActivity(endProcessInstance, state);
}
}
Modified: jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.hbm.xml
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.hbm.xml 2008-12-11 16:44:51 UTC (rev 3343)
+++ jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.hbm.xml 2008-12-11 16:47:48 UTC (rev 3344)
@@ -23,7 +23,7 @@
<property name="lang" column="LANG_" />
</subclass>
<subclass name="org.jbpm.jpdl.activity.ExclusiveHandlerActivity" discriminator-value="excl-handler">
- <property name="exclusiveHandlerName" column="EXCLNAME_" />
+ <property name="exclusiveHandlerName" column="TEXT_" />
<many-to-one name="exclusiveHandlerDescriptor"
column="EXCLDESCR_"
cascade="all"
@@ -32,7 +32,10 @@
index="IDX_ACT_EXCLDESCR" />
</subclass>
<subclass name="org.jbpm.jpdl.activity.StateActivity" discriminator-value="state" />
- <subclass name="org.jbpm.jpdl.activity.EndActivity" discriminator-value="end" />
+ <subclass name="org.jbpm.jpdl.activity.EndActivity" discriminator-value="end">
+ <property name="endProcessInstance" column="ENDPI_" />
+ <property name="state" column="TEXT_" />
+ </subclass>
</class>
</hibernate-mapping>
\ No newline at end of file
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2008-12-11 16:44:51 UTC (rev 3343)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2008-12-11 16:47:48 UTC (rev 3344)
@@ -269,7 +269,7 @@
getParent().setPreviousTransition(getPreviousTransition());
getParent().setPreviousNode(getPreviousNode());
- stop();
+ end();
parent.removeExecution(this);
return parent;
@@ -289,11 +289,11 @@
// execution method : end ///////////////////////////////////////////////////
- public void stop() {
- stop(Execution.STATE_ENDED);
+ public void end() {
+ end(Execution.STATE_ENDED);
}
- public void stop(String state) {
+ public void end(String state) {
if (state==null) {
throw new JbpmException("state is null");
}
@@ -316,7 +316,7 @@
// end all child executions
if (executions!=null) {
for (ExecutionImpl child: executions) {
- child.stop(state);
+ child.end(state);
}
}
@@ -342,11 +342,16 @@
}
}
}
+
+ public void end(OpenExecution executionToEnd) {
+ ((ExecutionImpl)executionToEnd).end();
+ }
- public void cancel() {
- stop(Execution.STATE_CANCELLED);
+ public void end(OpenExecution executionToEnd, String state) {
+ ((ExecutionImpl)executionToEnd).end(state);
}
+
// execution method : suspend and resume ////////////////////////////////////
/** @see Execution#suspend() */
@@ -505,7 +510,7 @@
// throw new PvmException("don't know how to proceed");
// or to end the execution. Because of convenience for testing,
// I opted to end the execution.
- stop();
+ end();
}
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java 2008-12-11 16:44:51 UTC (rev 3343)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java 2008-12-11 16:47:48 UTC (rev 3344)
@@ -116,7 +116,7 @@
}
public void createVariable(String key, Object value, String typeName, Type type) {
- if (isFinished()) {
+ if (isEnded()) {
throw new JbpmException("can't create variable '"+key+"' on "+this+": "+state);
}
@@ -174,7 +174,7 @@
}
public void setVariable(String key, Object value) {
- if (isFinished()) {
+ if (isEnded()) {
throw new JbpmException("can't update variable '"+key+"' on "+this+": "+state);
}
Variable variable = getVariableObject(key);
@@ -277,7 +277,7 @@
}
public boolean removeVariable(String key) {
- if (isFinished()) {
+ if (isEnded()) {
throw new JbpmException("can't remove variable '"+key+"' on "+this+": "+state);
}
@@ -451,12 +451,6 @@
return Execution.STATE_ENDED.equals(state);
}
- /** @see Execution#isFinished() */
- public boolean isFinished() {
- return Execution.STATE_ENDED.equals(state)
- || Execution.STATE_CANCELLED.equals(state);
- }
-
// customizable methods /////////////////////////////////////////////////////
public ExecutionImpl getProcessInstance() {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java 2008-12-11 16:44:51 UTC (rev 3343)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java 2008-12-11 16:47:48 UTC (rev 3344)
@@ -306,10 +306,19 @@
/** convenience method to combine extraction of a string attribute value.
*
+ * If the attribute exists, it is returned. If the attribute is not present, null
+ * is returned. The attribute is not present and it is required,
+ * a problem will be added to the parse. */
+ public static String attribute(Element element, String attributeName, boolean required, Parse parse) {
+ return attribute(element, attributeName, required, parse, null);
+ }
+
+ /** convenience method to combine extraction of a string attribute value.
+ *
* If the attribute exists, it is returned. If the attribute is not present, the
* defaultValue is returned. The attribute is not present and it is required,
* a problem will be added to the parse. */
- public static String attribute(Element element, String attributeName, boolean required, Parse parse) {
+ public static String attribute(Element element, String attributeName, boolean required, Parse parse, String defaultValue) {
if (element.hasAttribute(attributeName)) {
String value = element.getAttribute(attributeName);
if (required && "".equals(value)) {
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/EventTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/EventTest.java 2008-12-11 16:44:51 UTC (rev 3343)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/EventTest.java 2008-12-11 16:47:48 UTC (rev 3344)
@@ -224,7 +224,7 @@
public static class EndState implements Activity {
private static final long serialVersionUID = 1L;
public void execute(ActivityExecution execution) throws Exception {
- execution.stop();
+ execution.end();
}
}
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ExecutionStateTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ExecutionStateTest.java 2008-12-11 16:44:51 UTC (rev 3343)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/ExecutionStateTest.java 2008-12-11 16:47:48 UTC (rev 3344)
@@ -122,7 +122,7 @@
}
}
- public void testCancel() {
+ public void testCustomEndState() {
ClientProcessDefinition processDefinition = ProcessFactory.build()
.node("a").initial().behaviour(new AutomaticActivity())
.transition().to("b")
@@ -133,32 +133,8 @@
ClientProcessInstance processInstance = processDefinition.createProcessInstance();
processInstance.start();
- processInstance.cancel();
+ processInstance.end("error");
- assertEquals(Execution.STATE_CANCELLED, processInstance.getState());
-
- try {
- processInstance.signal();
- fail("expected exception");
- } catch (JbpmException e) {
- // OK
- assertTextPresent("process-instance is not active: cancelled", e.getMessage());
- }
- }
-
- public void testCustomState() {
- ClientProcessDefinition processDefinition = ProcessFactory.build()
- .node("a").initial().behaviour(new AutomaticActivity())
- .transition().to("b")
- .node("b").behaviour(new WaitState())
- .transition().to("c")
- .node("c").behaviour(new AutomaticActivity())
- .done();
-
- ClientProcessInstance processInstance = processDefinition.createProcessInstance();
- processInstance.start();
- processInstance.stop("error");
-
assertEquals("error", processInstance.getState());
try {
@@ -183,35 +159,35 @@
processInstance.start();
try {
- processInstance.stop("active");
+ processInstance.end("active");
fail("expected exception");
} catch (JbpmException e) {
// OK
assertTextPresent("invalid end state: active", e.getMessage());
}
try {
- processInstance.stop("suspended");
+ processInstance.end("suspended");
fail("expected exception");
} catch (JbpmException e) {
// OK
assertTextPresent("invalid end state: suspended", e.getMessage());
}
try {
- processInstance.stop("created");
+ processInstance.end("created");
fail("expected exception");
} catch (JbpmException e) {
// OK
assertTextPresent("invalid end state: created", e.getMessage());
}
try {
- processInstance.stop("async");
+ processInstance.end("async");
fail("expected exception");
} catch (JbpmException e) {
// OK
assertTextPresent("invalid end state: async", e.getMessage());
}
try {
- processInstance.stop("inactive");
+ processInstance.end("inactive");
fail("expected exception");
} catch (JbpmException e) {
// OK
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/SubProcessTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/SubProcessTest.java 2008-12-11 16:44:51 UTC (rev 3343)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/SubProcessTest.java 2008-12-11 16:47:48 UTC (rev 3344)
@@ -70,7 +70,7 @@
public static class EndState implements Activity {
public void execute(ActivityExecution execution) throws Exception {
- execution.stop();
+ execution.end();
}
}
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionBasedConcurrencyTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionBasedConcurrencyTest.java 2008-12-11 16:44:51 UTC (rev 3343)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/api/basicfeatures/TransitionBasedConcurrencyTest.java 2008-12-11 16:47:48 UTC (rev 3344)
@@ -48,7 +48,7 @@
public void execute(ActivityExecution execution) throws Exception {
// end the child execution execution
// this will also remove the execution from it's parent
- execution.stop();
+ execution.end();
Node join = execution.getNode();
List<OpenExecution> joinedExecutions = findJoinedExecutions(execution, join);
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ExclusiveTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ExclusiveTest.java 2008-12-11 16:44:51 UTC (rev 3343)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/ExclusiveTest.java 2008-12-11 16:47:48 UTC (rev 3344)
@@ -60,42 +60,6 @@
assertEquals("Small car", execution.getNodeName());
}
- public static class DistanceHandler implements ExclusiveHandler {
- public String select(OpenExecution execution) {
- String distance = (String) execution.getVariable("distance");
- if (new Integer(distance) < 10) {
- return "nearby";
- }
- return "far";
- }
- }
-
- public void testExclusiveHandler() {
- deployJpdlXmlString(
- "<process name='Poolcar'>" +
- " <start>" +
- " <flow to='How far?' />" +
- " </start>" +
- " <exclusive name='How far?'>" +
- " <handler class='"+DistanceHandler.class.getName()+"' />" +
- " <flow name='far' to='Big car' />" +
- " <flow name='nearby' to='Small car' />" +
- " </exclusive>" +
- " <state name='Big car' />" +
- " <state name='Small car' />" +
- "</process>"
- );
-
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("distance", "69");
- Execution execution = executionService.startExecutionByKey("Poolcar", variables);
- assertEquals("Big car", execution.getNodeName());
-
- variables.put("distance", "3");
- execution = executionService.startExecutionByKey("Poolcar", variables);
- assertEquals("Small car", execution.getNodeName());
- }
-
public void testExclusiveWithConditions() {
deployJpdlXmlString(
"<process name='Poolcar'>" +
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ProcessServiceTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ProcessServiceTest.java 2008-12-11 16:44:51 UTC (rev 3343)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/svc/ProcessServiceTest.java 2008-12-11 16:47:48 UTC (rev 3344)
@@ -339,7 +339,6 @@
assertEquals("end", execution.getNodeName());
assertTrue(execution.isEnded());
- assertTrue(execution.isFinished());
assertFalse(execution.isActive());
}
@@ -353,7 +352,6 @@
Execution execution = executionService.startExecutionByKey("minimal");
assertTrue(execution.isEnded());
- assertTrue(execution.isFinished());
assertFalse(execution.isActive());
}
}
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml 2008-12-11 16:44:51 UTC (rev 3343)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml 2008-12-11 16:47:48 UTC (rev 3344)
@@ -168,9 +168,76 @@
<section id="state">
<title><literal>state</literal></title>
<para>A wait state. Process execution will wait until an external trigger is
- provided through the API.
+ provided through the API. Apart from the <link linkend="commonactivitycontent">
+ common activity content</link>, <literal>state</literal> doesn't have any extra
+ attributes or elements.
</para>
- <para>Example: TODO</para>
+ <section id="statesequence">
+ <title><literal>state</literal> sequence</title>
+ <para>Let's look at an example which shows states connected with flows
+ as a sequence</para>
+ <programlisting><process name="StateSequence" xmlns="http://jbpm.org/4/jpdl">
+
+ <start>
+ <flow to="a" />
+ </start>
+
+ <state name="a">
+ <flow to="b" />
+ </state>
+
+ <state name="b">
+ <flow to="c" />
+ </state>
+
+ <state name="c" />
+
+</process></programlisting>
+ <para>After you start an execution like this:</para>
+ <programlisting>Execution execution = executionService.startExecutionByKey("StateSequence");</programlisting>
+ <para>the created process instance will be positioned in
+ state <literal>a</literal>. Providing an external trigger can
+ be done with the <literal>signalExecution</literal> methods.</para>
+ <programlisting>String executionId = execution.getId();
+execution = executionService.signalExecutionById(executionId);</programlisting>
+ </section>
+ <section id="statechoice">
+ <title><literal>state</literal> choice</title>
+ <para>In this second example with states, we'll show how you can use a
+ <literal>state</literal> can be used to feed in an external choice of
+ the path to take.
+ </para>
+ <programlisting><process name="StateChoice" xmlns="http://jbpm.org/4/jpdl">
+
+ <start>
+ <flow to="wait for response" />
+ </start>
+
+ <state name="wait for response">
+ <flow name="accept" to="submit document" />
+ <flow name="reject" to="try again" />
+ </state>
+
+ <state name="submit document" />
+
+ <state name="try again" />
+
+</process></programlisting>
+ <para>Let's start a new process instance for this process definition:</para>
+ <programlisting>Execution execution = executionService.startExecutionByKey("StateSequence");</programlisting>
+ <para>Now, the execution is arrived in the <literal>wait for response</literal>.
+ The execution will wait there until an external trigger is given. In case
+ a <literal>state</literal> has multiple outgoing flows, the signalName given
+ in the external trigger will be matched against the name of the outgoing flow
+ to take. So when we provide signalName <literal>accept</literal> like this:
+ </para>
+ <programlisting>executionService.signalExecutionById(executionId, "accept");</programlisting>
+ <para>Then the execution will continue over the outgoing flow named
+ <literal>accept</literal>. Analogue, when signalName <literal>reject</literal>
+ is given in the signalExecutionXxx methods, the execution will continue over
+ the outgoing flow named reject.
+ </para>
+ </section>
</section>
<section id="exclusive">
@@ -181,6 +248,73 @@
</para>
<para>An exclusive activity should be configured in one of the three following ways:
</para>
+
+ <section id="exclusiveconditions">
+ <title>Exclusive conditions</title>
+ <para>An exclusive with conditions on the flows evaluates the condition in each flow.
+ The first flow for which the nested condition expression resolves to true or which does
+ not have a condition is taken.
+ </para>
+ <table><title><literal>exclusive.flow.condition</literal> attributes:</title>
+ <tgroup cols="5" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Attribute</entry>
+ <entry>Type</entry>
+ <entry>Default</entry>
+ <entry>Required?</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>expr</literal></entry>
+ <entry>expression</entry>
+ <entry></entry>
+ <entry><emphasis role="bold">required</emphasis></entry>
+ <entry>script that will be evaluated in the specified
+ expression language.
+ </entry>
+ </row>
+ <row>
+ <entry><literal>lang</literal></entry>
+ <entry>expression language</entry>
+ <entry>the <literal>default-expression-language</literal> taken from the <link linkend="scripting"><literal>script-manager</literal> configuration</link></entry>
+ <entry>optional</entry>
+ <entry>the language in which <literal>expr</literal> is
+ to be evaluated.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>Example:
+ </para>
+ <programlisting><process name="ExclusiveConditions" >
+
+ <start>
+ <flow to="evaluate document" />
+ </start>
+
+ <exclusive name="evaluate document">
+ <flow to="submit document">
+ <emphasis role="bold"><condition expr="#{content=="good"}" /></emphasis>
+ </flow>
+ <flow to="try again">
+ <emphasis role="bold"><condition expr="#{content=="not so good"}" /></emphasis>
+ </flow>
+ <flow to="give up" />
+ </exclusive>
+
+ <state name="submit document" />
+
+ <state name="try again" />
+
+ <state name="give up" />
+
+</process></programlisting>
+ </section>
+
<section id="exclusiveexpression">
<title>Exclusive expression</title>
<para>An exclusive expression evaluates to a String representing the name of
@@ -200,7 +334,7 @@
<tbody>
<row>
<entry><literal>expr</literal></entry>
- <entry>script</entry>
+ <entry>expression</entry>
<entry></entry>
<entry><emphasis role="bold">required</emphasis></entry>
<entry>script that will be evaluated in the specified
@@ -232,19 +366,121 @@
<state name="Big car" />
<state name="Small car" />
</process></programlisting>
- </section>
- <para>When you start an new process instance like this
- </para>
- <programlisting>Map<String, Object> variables = new HashMap<String, Object>();
+ <para>When you start an new process instance like this
+ </para>
+ <programlisting>Map<String, Object> variables = new HashMap<String, Object>();
variables.put("distance", "far");
Execution execution = executionService.startExecutionByKey("Poolcar", variables);</programlisting>
- <para>then the new execution will go to node <literal>Big car</literal>.</para>
+ <para>then the new execution will go to node <literal>Big car</literal>.</para>
+ </section>
+
+ <section id="exclusivehandler">
+ <title>Exclusive handler</title>
+ <para>An exclusive handler is a java class that implements the
+ <literal>ExclusiveHandler</literal> interface. The exclusive handler
+ will be responsible for selecting the name of the outgoing flow.
+ </para>
+ <programlisting>public interface ExclusiveHandler {
+ String select(OpenExecution execution);
+}</programlisting>
+ <para>The handler is specified as a sub element of the exclusive</para>
+ <table><title><literal>exclusive.handler</literal> attributes:</title>
+ <tgroup cols="5" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Attribute</entry>
+ <entry>Type</entry>
+ <entry>Default</entry>
+ <entry>Required?</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>class</literal></entry>
+ <entry>classname</entry>
+ <entry></entry>
+ <entry><emphasis role="bold">required</emphasis></entry>
+ <entry>fully qualified classname of the handler implementation class.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>Here's an example process of an exclusive using an ExclusiveHandler:</para>
+ <programlisting><process name="ExclusiveHandler">
+
+ <start>
+ <flow to="evaluate document" />
+ </start>
+
+ <exclusive name="evaluate document">
+ <handler class="org.jbpm.examples.exclusive.handler.ContentEvaluation" />
+ <flow name="good" to="submit document" />
+ <flow name="bad" to="try again" />
+ <flow name="ugly" to="give up" />
+ </exclusive>
+
+ <state name="submit document" />
+
+ <state name="try again" />
+
+ <state name="give up" />
+
+</process></programlisting>
+ <para>The ContentEvaluation class looks like this</para>
+ <programlisting>public class ContentEvaluation implements ExclusiveHandler {
+
+ public String select(OpenExecution execution) {
+ String content = (String) execution.getVariable("content");
+ if (content.equals("you're great")) {
+ return "good";
+ }
+ if (content.equals("you gotta improve")) {
+ return "bad";
+ }
+ return "ugly";
+ }
+}</programlisting>
+ <para>Now, when we start a process instance and supply value
+ <literal>you're great</literal> for variable content, then the
+ ContentEvaluation will return String <literal>good</literal> and
+ the process instance will arrive in node <literal>Submit document</literal>.
+ </para>
+ </section>
+
</section>
<section id="end">
<title><literal>end</literal></title>
<para>Ends the execution.
</para>
+ <section id="endprocessinstance">
+ <title><literal>end</literal> process instance</title>
+ <para>By default, an end activity will end the complete
+ process instance. In case multiple concurrent executions
+ are still active within the same process instance, all of
+ them will be ended.
+ </para>
+ </section>
+ <section id="endexecution">
+ <title><literal>end</literal> execution</title>
+ <para>Only the execution that arrives in the
+ end activity will be ended and other concurrent executions
+ should be left active. To get this behaviour, set
+ attribute <literal>ends="execution"</literal>
+ </para>
+ </section>
+ <section id="endmultiple">
+ <title><literal>end</literal> multiple</title>
+ <para>TODO
+ </para>
+ </section>
+ <section id="endstate">
+ <title><literal>end</literal> state</title>
+ <para>TODO
+ </para>
+ </section>
</section>
<section id="commonactivitycontents">
More information about the jbpm-commits
mailing list