[jbpm-commits] JBoss JBPM SVN: r4982 - in jbpm4/trunk/modules: examples/src/test/java/org/jbpm/examples/eventlistener and 4 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Jun 3 10:32:39 EDT 2009


Author: tom.baeyens at jboss.com
Date: 2009-06-03 10:32:39 -0400 (Wed, 03 Jun 2009)
New Revision: 4982

Modified:
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/end/processinstance/EndProcessInstanceTest.java
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/eventlistener/EventListenerTest.java
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/decision/expression/process.jpdl.xml
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/decision/handler/process.jpdl.xml
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/end/state/process.jpdl.xml
   jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Services.xml
   jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml
Log:
JBPM-2252 update docs and examples to proper usage of API

Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/end/processinstance/EndProcessInstanceTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/end/processinstance/EndProcessInstanceTest.java	2009-06-03 14:26:29 UTC (rev 4981)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/end/processinstance/EndProcessInstanceTest.java	2009-06-03 14:32:39 UTC (rev 4982)
@@ -21,7 +21,7 @@
  */
 package org.jbpm.examples.end.processinstance;
 
-import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessInstance;
 import org.jbpm.test.JbpmTestCase;
 
 
@@ -47,7 +47,7 @@
   }
 
   public void testEndProcessInstance() {
-    Execution execution = executionService.startProcessInstanceByKey("EndProcessInstance");
-    assertTrue(execution.isEnded());
+    ProcessInstance processInstance = executionService.startProcessInstanceByKey("EndProcessInstance");
+    assertTrue(processInstance.isEnded());
   }
 }

Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/eventlistener/EventListenerTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/eventlistener/EventListenerTest.java	2009-06-03 14:26:29 UTC (rev 4981)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/eventlistener/EventListenerTest.java	2009-06-03 14:32:39 UTC (rev 4982)
@@ -4,6 +4,7 @@
 import java.util.List;
 
 import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessInstance;
 import org.jbpm.test.JbpmTestCase;
 
 
@@ -28,7 +29,9 @@
   public void testEventListener() {
     LogListener.logs = new ArrayList<String>();
     
-    Execution execution = executionService.startProcessInstanceByKey("EventListener");
+    ProcessInstance processInstance = executionService.startProcessInstanceByKey("EventListener");
+    
+    Execution execution = processInstance.findActiveExecutionIn("wait");
     executionService.signalExecutionById(execution.getId());
     
     List<String> expectedLogs = new ArrayList<String>();

Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/decision/expression/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/decision/expression/process.jpdl.xml	2009-06-03 14:26:29 UTC (rev 4981)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/decision/expression/process.jpdl.xml	2009-06-03 14:32:39 UTC (rev 4982)
@@ -3,17 +3,17 @@
 <process name="DecisionExpression" xmlns="http://jbpm.org/4.0/jpdl">
 
   <start g="16,102,48,48">
-    <transition to="evaluate document" name=""/>
+    <transition to="evaluate document"/>
   </start>
 
-  <decision expr="#{content}" g="96,102,48,48" name="evaluate document">
-    <transition g="120,60:-36,23" name="good" to="submit document"/>
-    <transition g=":-15,-21" name="bad" to="try again"/>
-    <transition g="120,189:-35,-41" name="ugly" to="give up"/>
+  <decision name="evaluate document" expr="#{content}" g="96,102,48,48">
+    <transition name="good" to="submit document" g="120,60:-36,23" />
+    <transition name="bad"  to="try again" g=":-15,-21" />
+    <transition name="ugly" to="give up" g="120,189:-35,-41" />
   </decision>
 
-  <state g="175,35,122,52" name="submit document"/>
-  <state g="176,100,122,52" name="try again"/>
-  <state g="177,164,122,52" name="give up"/>
+  <state name="submit document" g="175,35,122,52" />
+  <state name="try again" g="176,100,122,52" />
+  <state name="give up" g="177,164,122,52" />
 
 </process>
\ No newline at end of file

Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/decision/handler/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/decision/handler/process.jpdl.xml	2009-06-03 14:26:29 UTC (rev 4981)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/decision/handler/process.jpdl.xml	2009-06-03 14:32:39 UTC (rev 4982)
@@ -6,15 +6,15 @@
     <transition to="evaluate document" name=""/>
   </start>
 
-  <decision g="96,102,48,48" name="evaluate document">
+  <decision name="evaluate document" g="96,102,48,48">
     <handler class="org.jbpm.examples.decision.handler.ContentEvaluation"/>
-    <transition g="120,60:-37,22" name="good" to="submit document"/>
-    <transition g=":-19,-22" name="bad" to="try again"/>
-    <transition g="120,189:-33,-39" name="ugly" to="give up"/>
+    <transition name="good" to="submit document" g="120,60:-37,22" />
+    <transition name="bad" to="try again" g=":-19,-22" />
+    <transition name="ugly" to="give up" g="120,189:-33,-39" />
   </decision>
 
-  <state g="175,35,122,52" name="submit document"/>
-  <state g="176,100,122,52" name="try again"/>
-  <state g="177,164,122,52" name="give up"/>
+  <state name="submit document" g="175,35,122,52" />
+  <state name="try again" g="176,100,122,52" />
+  <state name="give up" g="177,164,122,52" />
 
 </process>
\ No newline at end of file

Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/end/state/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/end/state/process.jpdl.xml	2009-06-03 14:26:29 UTC (rev 4981)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/end/state/process.jpdl.xml	2009-06-03 14:32:39 UTC (rev 4982)
@@ -3,17 +3,17 @@
 <process name="EndState" xmlns="http://jbpm.org/4.0/jpdl">
 
   <start g="16,96,48,48">
-     <transition to="get return code" name=""/>
+     <transition to="get return code"/>
   </start>
 
-  <state g="96,94,110,52" name="get return code">
-    <transition g="150,63:-36,11" name="200" to="ok"/>
-    <transition g=":-16,-27" name="400" to="bad request"/>
-    <transition g="150,177:-33,-32" name="500" to="internal server error"/>
+  <state name="get return code" g="96,94,110,52">
+    <transition name="200" to="ok" g="150,63:-36,11"/>
+    <transition name="400" to="bad request" g=":-16,-27"/>
+    <transition name="500" to="internal server error" g="150,177:-33,-32"/>
   </state>
 
-  <end g="239,40,48,48" name="ok" state="completed"/>
-  <end-cancel g="239,97,48,48" name="bad request"/>
-  <end-error g="240,154,48,48" name="internal server error"/>
+  <end name="ok" state="completed" g="239,40,48,48"/>
+  <end-cancel name="bad request" g="239,97,48,48"/>
+  <end-error name="internal server error" g="240,154,48,48"/>
 
 </process>
\ No newline at end of file

Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Services.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Services.xml	2009-06-03 14:26:29 UTC (rev 4981)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Services.xml	2009-06-03 14:32:39 UTC (rev 4982)
@@ -244,7 +244,7 @@
       <para>Simplest and most common way to start a new process instance for a process 
       definition is like this: 
       </para>
-      <programlisting>executionService.startProcessInstanceByKey("ICL");</programlisting>
+      <programlisting>ProcessInstance processInstance = executionService.startProcessInstanceByKey(&quot;ICL&quot;);</programlisting>
       <para>In this case, the service method will first look up the latest version of 
       the processes with key <literal>ICL</literal>.  Then a new 
       process instance is started in that latest process definition.
@@ -260,7 +260,8 @@
       <para>If instead you want to start a new process instance in a very 
       specific version, you can use the id of the process definition like this:
       </para>
-      <programlisting>executionService.startProcessInstanceById("ICL-1");</programlisting>
+      <programlisting>ProcessInstance processInstance = 
+    executionService.startProcessInstanceById(&quot;ICL-1&quot;);</programlisting>
     </section>
 
     <section id="withakey">
@@ -271,7 +272,8 @@
       to find such a key in the domain of the business process.  For example, an 
       order id or an insurance claim number.
       </para>
-      <programlisting>executionService.startProcessInstanceByKey("ICL", "CL92837");</programlisting>
+      <programlisting>ProcessInstance processInstance = 
+    executionService.startProcessInstanceByKey(&quot;ICL&quot;, &quot;CL92837&quot;);</programlisting>
       <para>The key is used to create the id of the process instance.  
       The format used is <literal>{process-key}.{execution-id}</literal>.  
       With a dot between process-key and execution-id. 
@@ -280,8 +282,9 @@
       </para>  
       <para>If no user defined key is provided, the DB primary key is taken
       as the key.  In that case, the id can be retrieved like this:   
-      <programlisting>Execution execution = executionService.startProcessInstanceByKey("ICL");
-String executionId = execution.getId();</programlisting>
+      <programlisting>ProcessInstance processInstance = 
+    executionService.startProcessInstanceByKey(&quot;ICL&quot;);
+String pid = processInstance.getId();</programlisting>
       </para> 
       <para>We recommend the use of a user defined keys.  Typically in your application 
       code, you'll have the key available.  By providing a user defined key, you can 
@@ -297,51 +300,57 @@
       instance between creation and start of the process instance.
       </para>
       <programlisting>Map&lt;String,Object&gt; variables = new HashMap&lt;String,Object&gt;();
-variables.put("customer", "John Doe");
-variables.put("type", "Accident");
-variables.put("amount", new Float(763.74));
+variables.put(&quot;customer&quot;, &quot;John Doe&quot;);
+variables.put(&quot;type&quot;, &quot;Accident&quot;);
+variables.put(&quot;amount&quot;, new Float(763.74));
 
-executionService.startProcessInstanceByKey("ICL", variables);</programlisting>
+ProcessInstance processInstance = 
+    executionService.startProcessInstanceByKey(&quot;ICL&quot;, variables);</programlisting>
     </section>
   </section>
 
   <section id="singallingawaitingexecution">
     <title>Signalling a waiting execution</title>
-    <para>A process definition describes what must be done in terms of activities.
-    Each activity in a process is either to be performed by the process 
-    system or by an external participant.  When an activity is to be performed 
-    by an external participant, then the execution must wait until the 
-    external participant notifies the process system that the activity is 
-    completed.  So an execution is either executing or waiting on an external 
-    participant.  Typically, you'll see that the processes are mostly 
-    waiting for external participations.  Especially humans tend to be slow :-)
-    The time consumed by the process system between two wait states is 
-    typically very small.
+    <para>When using a <literal>state</literal> activity, the execution (or process instance) 
+    will wait when it arrives in the state, waiting for a signal (aka external trigger).  
+    Methods <literal>signalExecution</literal> can be used for that.  Executions are 
+    referenced by an execution id (String).
     </para>
-    <para>A <literal>state</literal> is the basic activity that represents 
-    something has to be done by an external participant and the execution 
-    must wait until a signal (aka external trigger) is given.
+    <para>In some cases, the execution that arrives in a state will be the process instance 
+    itself.  But that is not always the case.  In case of timers or concurrency, a process 
+    is the root execution of a tree of executions.  So you have to make sure that you signal
+    the right path of execution.
     </para>
-    <para>When an execution is in a wait state, it can be given an external trigger 
-    with one of the signal methods.  The recommended way to reference an execution 
-    is by using the process definition and execution key.  In the next code snippet,
-    <literal>ICL</literal> refers to the process definition key and <literal>82436</literal>
-    refers to the execution key.
+    <para>The preferred way to capture the right execution is by associating an event listener to 
+    the state activity like this:
     </para>
-    <programlisting>executionService.signalExecutionByKey(&quot;ICL&quot;, &quot;82436&quot;);</programlisting>
-    <para>Alternatively, the execution that must be signaled can be referenced
-    by a unique execution id.  In the next snippet, <literal>ICL.82436</literal> 
-    refers to the executionId.</para>
-    <programlisting>executionService.signalExecutionById(&quot;ICL.82436&quot;);</programlisting>
-    <para>Optionally some data can be passed along with a signal: a <literal>signalName</literal> 
-    and <literal>parameters</literal>.  How the signalName gets used depends on 
-    the execution's current activity.  The parameters get stored as process variables.
+    <programlisting>&lt;state name=&quot;wait&quot;&gt;
+  &lt;on event=&quot;start&quot;&gt;
+    &lt;event-listener class=&quot;org.jbpm.examples.StartExternalWork&quot; /&gt;
+  &lt;/on&gt;
+  ...
+&lt;/state&gt;</programlisting>
+    <para>In event listener <literal>StartExternalWork</literal> you can kick off what needs to
+    be done externally.  In that event listener you can also obtain the exact execution id
+    with <literal>execution.getId()</literal>.  It's that executionId that you'll need to provide 
+    the signal later on when the external work is done:
     </para>
-    <programlisting>Map&lt;String,Object&gt; parameters = new HashMap&lt;String,Object&gt;();
-parameters.put(&quot;quality&quot;, &quot;a+&quot;); 
-parameters.put(&quot;target&quot;, &quot;profit&quot;); 
+    <programlisting>executionService.signalExecutionById(executionId);</programlisting>
+    <para>There is an alternatively (less preferrable) way to obtain the executionId 
+    when the execution arrives in the <literal>state</literal> activity.  
+    It's only possible to obtain the execution id this way if you know after which jBPM 
+    API call the execution will have entered the <literal>state</literal> activity:
+    </para>
+    <programlisting>// assume that we know that after the next call
+// the process instance will arrive in <literal>state</literal> external work
 
-executionService.signalExecutionById("ICL/82436", &quot;Accept&quot;, parameters);</programlisting>
+ProcessInstance processInstance = 
+  executionService.startProcessInstanceById(processDefinitionId);
+// or ProcessInstance processInstance = 
+//  executionService.signalProcessInstanceById(executionId);
+
+Execution execution = processInstance.findActiveExecutionIn("external work");
+String executionId = execution.getId();</programlisting>
   </section>
 
   <section id="taskservice">
@@ -370,26 +379,48 @@
     a task means that this user will be set as the assignee.  After that, other users 
     will be blocked from taking the task.
     </para>
-    <programlisting></programlisting>
-    <para>
-    People should not work on 
-    a task unless they are assigned to that task.  The user interface should display 
+    <para>People should not work on 
+    a task unless they are assigned to that task.  The user interface displays 
     forms and allow users to complete tasks if they are assigned to it.
     For unassigned tasks for which the user is a candidate, the only action that 
-    should be exposed is 'take'.  Since taking a task boiles down to setting the 
-    assignee to the current user, we didn't introduce a separate method for that.    
+    should be exposed is 'take'.      
     </para>
-    <para>More on tasks in <xref linkend="tasks" /> </para>
+    <para>More on tasks in <xref linkend="task" /> </para>
   </section>
 
   <section id="historyservice">
     <title>HistoryService</title>
-    <para>TODO</para>
+    <para>During runtime execution of process instances, events are generated.  And from 
+    those events, history information on both running and completed process executions are 
+    collected in the history tables.  The <literal>HistoryService</literal> provides 
+    access to that information. 
+    </para>
+    <para>Querying for all process instances for a specific process definition can be 
+    done like this:</para>
+    <programlisting>List&lt;HistoryProcessInstance&gt; historyProcessInstances = historyService
+  .createHistoryProcessInstanceQuery()
+  .processDefinitionId(&quot;ICL-1&quot;)
+  .orderAsc(HistoryProcessInstanceQuery.PROPERTY_STARTTIME)
+  .list();</programlisting>
+    <para>Also individual activity executions are stored in the history information as 
+    <literal>HistoryActivityInstance</literal>s.
+    </para>
+    <programlisting>List&lt;HistoryActivityInstance&gt; histActInsts = historyService
+    .createHistoryActivityInstanceQuery()
+    .processDefinitionId(&quot;ICL-1&quot;)
+    .activityName(&quot;a&quot;)
+    .list();</programlisting>
+    <para>Convenience methods <literal>avgDurationPerActivity</literal> and 
+    <literal>choiceDistribution</literal> are also available.  See javadocs for more 
+    information on those methods.
+    </para>
   </section>
 
   <section id="managementservice">
     <title>ManagementService</title>
-    <para>TODO</para>
+    <para>The management service is mostly used to manage the jobs.  See javadocs for 
+    more information.  This functionality is also exposed through the console.
+    </para>
   </section>
 
 </chapter>
\ No newline at end of file

Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml	2009-06-03 14:26:29 UTC (rev 4981)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml	2009-06-03 14:32:39 UTC (rev 4982)
@@ -202,12 +202,21 @@
 
 &lt;/process&gt;</programlisting>
         <para>After you start an execution like this:</para>
-        <programlisting>Execution execution = executionService.startProcessInstanceByKey("StateSequence");</programlisting>
+        <programlisting>ProcessInstance processInstance = 
+    executionService.startProcessInstanceByKey("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>
+        <programlisting>Execution executionInA = processInstance.findActiveExecutionIn(&quot;a&quot;);
+assertNotNull(executionInA);
+
+processInstance = executionService.signalExecutionById(executionInA.getId());
+Execution executionInB = processInstance.findActiveExecutionIn(&quot;b&quot;);
+assertNotNull(executionInB);
+
+processInstance = executionService.signalExecutionById(executionInB.getId());
+Execution executionInC = processInstance.findActiveExecutionIn(&quot;c&quot;);
+assertNotNull(executionInC);</programlisting>
       </section>
       <section id="statechoice">
         <title><literal>state</literal> choice</title>
@@ -236,14 +245,21 @@
 
 &lt;/process&gt;</programlisting>
         <para>Let's start a new process instance for this process definition:</para>
-        <programlisting>Execution execution = executionService.startProcessInstanceByKey("StateSequence");</programlisting>
+        <programlisting>ProcessInstance processInstance = executionService
+    .startProcessInstanceByKey(&quot;StateChoice&quot;);</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 transitions, the signalName given 
         in the external trigger will be matched against the name of the outgoing transition 
         to take.  So when we provide signalName <literal>accept</literal> like this:
         </para>
-        <programlisting>executionService.signalExecutionById(executionId, "accept");</programlisting>
+        <programlisting>String executionId = processInstance
+    .findActiveExecutionIn(&quot;wait for response&quot;)
+    .getId();
+
+processInstance = executionService.signalExecutionById(executionId, &quot;accept&quot;);
+
+assertTrue(processInstance.isActive(&quot;submit document&quot;));</programlisting>
         <para>Then the execution will continue over the outgoing transition named 
         <literal>accept</literal>.  Analogue, when signalName <literal>reject</literal> 
         is given in the signalExecutionXxx methods, the execution will continue over 
@@ -329,6 +345,14 @@
   &lt;state name=&quot;give up&quot; /&gt;
 
 &lt;/process&gt;</programlisting>
+        <para>After starting a process instance with <literal>good content</literal></para>
+        <programlisting>Map&lt;String, Object&gt; variables = new HashMap&lt;String, Object&gt;();
+variables.put(&quot;content&quot;, &quot;good&quot;);
+ProcessInstance processInstance = 
+    executionService.startProcessInstanceByKey(&quot;DecisionConditions&quot;, variables);</programlisting>
+        <para>The activity <literal>submit document</literal> will be active</para>
+        <programlisting>assertTrue(processInstance.isActive(&quot;submit document&quot;));</programlisting>
+        <para>See the example unit test for more scenarios.</para>
       </section>
 
       <section id="decisionexpression">
@@ -375,23 +399,32 @@
           <title>The decision expression example process</title>
           <mediaobject><imageobject><imagedata align="center" fileref="images/process.decision.png"/></imageobject></mediaobject>
         </figure>
-        <programlisting>&lt;process name=&quot;Poolcar&quot;&gt;
-  &lt;start&gt;
-    &lt;transition to=&quot;How far?&quot; /&gt;
+        <programlisting>&lt;process name=&quot;DecisionExpression&quot; xmlns=&quot;http://jbpm.org/4.0/jpdl&quot;&gt;
+
+  &lt;start &gt;
+    &lt;transition to=&quot;evaluate document&quot;/&gt;
   &lt;/start&gt;
-  &lt;decision name=&quot;How far?&quot; <emphasis role="bold">expr=&quot;#{distance}&quot;</emphasis>&gt;
-    &lt;transition name=&quot;far&quot;    to=&quot;Big car&quot; /&gt;
-    &lt;transition name=&quot;nearby&quot; to=&quot;Small car&quot; /&gt;
+
+  &lt;decision name=&quot;evaluate document&quot; <emphasis role="bold">expr=&quot;#{content}&quot;</emphasis> &gt;
+    &lt;transition <emphasis role="bold">name=&quot;good&quot;</emphasis> to=&quot;submit document&quot;  /&gt;
+    &lt;transition <emphasis role="bold">name=&quot;bad&quot;</emphasis>  to=&quot;try again&quot;  /&gt;
+    &lt;transition <emphasis role="bold">name=&quot;ugly&quot;</emphasis> to=&quot;give up&quot;  /&gt;
   &lt;/decision&gt;
-  &lt;state name=&quot;Big car&quot; /&gt;
-  &lt;state name=&quot;Small car&quot; /&gt;
+
+  &lt;state name=&quot;submit document&quot;  /&gt;
+  &lt;state name=&quot;try again&quot;  /&gt;
+  &lt;state name=&quot;give up&quot;  /&gt;
+
 &lt;/process&gt;</programlisting>
-        <para>When you start an new process instance like this
+        <para>When you start an new process instance with good content like this
         </para>
         <programlisting>Map&lt;String, Object&gt; variables = new HashMap&lt;String, Object&gt;();
-variables.put("distance", "far");
-Execution execution = executionService.startProcessInstanceByKey(&quot;Poolcar&quot;, variables);</programlisting>
-        <para>then the new execution will go to activity <literal>Big car</literal>.</para>
+variables.put(&quot;content&quot;, &quot;good&quot;);
+ProcessInstance processInstance = 
+    executionService.startProcessInstanceByKey(&quot;DecisionExpression&quot;, variables);</programlisting>
+
+        <para>then the new execution will go to activity <literal>submit document</literal>.</para>
+        <para>See the example unit test for the other scenarios.</para>
       </section>
 
       <section id="decisionhandler">
@@ -651,10 +684,9 @@
         </programlisting>
         <para>Now if we would start an execution and signal it to move out of the <literal>get return code</literal> wait state with the 
         following code, the execution would end with the <literal>bad request</literal> end event.</para>
-        <programlisting>Execution execution = executionService.startProcessInstanceByKey(&quot;EndMultiple&quot;);
-String executionId = execution.getId();
-execution = executionService.signalExecutionById(executionId, &quot;400&quot;);
-        </programlisting>
+        <programlisting>ProcessInstance processInstance = executionService.startProcessInstanceByKey(&quot;EndMultiple&quot;);
+String pid = processInstance.getId();
+processInstance = executionService.signalExecutionById(pid, &quot;400&quot;);</programlisting>
         <para>Likewise, using the value <literal>200</literal> or <literal>500</literal> would cause the execution
         to end with the <literal>ok</literal> or with the <literal>internal server error</literal> end events
         respectively.</para>
@@ -717,9 +749,7 @@
         </programlisting>
         <para>This time, if we would start an execution and signal it to move out of the <literal>get return code</literal> wait state with the 
         following code, the execution would end with the <literal>cancel</literal> state.</para>
-        <programlisting>Execution execution = executionService.startProcessInstanceByKey(&quot;EndState&quot;);
-String executionId = execution.getId();
-execution = executionService.signalExecutionById(executionId, &quot;400&quot;);
+        <programlisting>TODO (paste the code snippit)
         </programlisting>
         <para>Similarly as above, using the value <literal>200</literal> or <literal>500</literal> would cause the execution
         to end with the <literal>completed</literal> or with the <literal>error</literal> states
@@ -816,7 +846,7 @@
           variable.</para>
           <programlisting>Map&lt;String, Object&gt; variables = new HashMap&lt;String, Object&gt;(); 
 variables.put(&quot;order&quot;, new Order(&quot;johndoe&quot;));
-Execution execution = executionService
+ProcessInstance processInstance = executionService
     .startProcessInstanceByKey(&quot;TaskAssignee&quot;, variables);</programlisting>
         <para>Then the task list for <literal>johndoe</literal> can be obtained like this.</para>
         <programlisting>List&lt;Task&gt; taskList = taskService.findPersonalTasks(&quot;johndoe&quot;);</programlisting>
@@ -2415,10 +2445,11 @@
   }
 }</programlisting>
     <para>Next, we start a new process instance.</para>
-    <programlisting>Execution execution = executionService.startProcessInstanceByKey(&quot;EventListener&quot;);</programlisting>
+    <programlisting>ProcessInstance processInstance = executionService.startProcessInstanceByKey(&quot;EventListener&quot;);</programlisting>
     <para>Then the process instance executes up to the wait activity.  So we provide a signal 
     and that will cause it to execute till the end.</para>
-    <programlisting>executionService.signalExecutionById(execution.getId());</programlisting>
+    <programlisting>Execution execution = processInstance.findActiveExecutionIn(&quot;wait&quot;);
+executionService.signalExecutionById(execution.getId());</programlisting>
     <para>The list of log messages will now look like this:</para>
     <programlisting>[event(start) on process(EventListener),
  event(start) on activity(wait),




More information about the jbpm-commits mailing list