[jbpm-commits] JBoss JBPM SVN: r2253 - in jbpm4/pvm/trunk/modules: core/src/test/resources and 3 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Sep 15 11:12:00 EDT 2008


Author: tom.baeyens at jboss.com
Date: 2008-09-15 11:12:00 -0400 (Mon, 15 Sep 2008)
New Revision: 2253

Modified:
   jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/basicfeatures/BasicExecutionFlowTest.java
   jbpm4/pvm/trunk/modules/core/src/test/resources/environment.cfg.xml
   jbpm4/pvm/trunk/modules/manual/pom.xml
   jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/master.xml
   jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/ch02-ExecutionModes.xml
Log:
started docs for persistent execution mode

Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/basicfeatures/BasicExecutionFlowTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/basicfeatures/BasicExecutionFlowTest.java	2008-09-15 14:58:48 UTC (rev 2252)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/basicfeatures/BasicExecutionFlowTest.java	2008-09-15 15:12:00 UTC (rev 2253)
@@ -28,6 +28,8 @@
 import org.jbpm.pvm.activity.Activity;
 import org.jbpm.pvm.activity.ActivityExecution;
 import org.jbpm.pvm.activity.ExternalActivity;
+import org.jbpm.pvm.api.db.embedded.AutomaticActivity;
+import org.jbpm.pvm.api.db.embedded.WaitState;
 import org.jbpm.pvm.client.ClientExecution;
 import org.jbpm.pvm.client.ClientProcessDefinition;
 import org.jbpm.pvm.client.ClientProcessInstance;
@@ -75,62 +77,69 @@
     AutomaticActivity automaticActivity = new AutomaticActivity(recordedEvents);
     WaitState waitState = new WaitState(recordedEvents);
 
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(automaticActivity)
-        .transition().to("b")
-      .node("b").behaviour(automaticActivity)
-        .transition().to("c")
-      .node("c").behaviour(waitState)
-        .transition().to("d")
-      .node("d").behaviour(waitState)
-        .transition().to("e")
-      .node("e").behaviour(automaticActivity)
-        .transition().to("f")
-      .node("f").behaviour(automaticActivity)
+    ClientProcessDefinition processDefinition = ProcessFactory.build("loan")
+      .node("submit loan request").initial().behaviour(automaticActivity)
+        .transition().to("evaluate")
+      .node("evaluate").behaviour(waitState)
+        .transition("approve").to("wire money")
+        .transition("reject").to("end")
+      .node("wire money").behaviour(automaticActivity)
+        .transition().to("archive")
+      .node("archive").behaviour(waitState)
+        .transition().to("end")
+      .node("end").behaviour(waitState)
     .done();
 
-    ClientExecution processInstance = processDefinition.startProcessInstance();
+    ClientExecution execution = processDefinition.startProcessInstance();
     
     List<String> expectedEvents = new ArrayList<String>();
     
-    expectedEvents.add("execute[a]");
-    expectedEvents.add("execute[b]");
-    expectedEvents.add("execute[c]");
+    expectedEvents.add("execute[submit loan request]");
+    expectedEvents.add("execute[evaluate]");
 
-    assertEquals("c", processInstance.getNodeName());
-    assertFalse(processInstance.isEnded());
+    assertEquals("evaluate", execution.getNodeName());
     assertEquals(expectedEvents, recordedEvents);
 
-    processInstance.signal();
+    execution.signal("approve");
 
-    expectedEvents.add("signal[c]");
-    expectedEvents.add("execute[d]");
+    expectedEvents.add("signal[evaluate]");
+    expectedEvents.add("execute[wire money]");
+    expectedEvents.add("execute[archive]");
 
-    assertEquals("d", processInstance.getNodeName());
-    assertFalse(processInstance.isEnded());
+    assertEquals("archive", execution.getNodeName());
     assertEquals(expectedEvents, recordedEvents);
 
-    processInstance.signal();
+    execution.signal();
 
-    expectedEvents.add("signal[d]");
-    expectedEvents.add("execute[e]");
-    expectedEvents.add("execute[f]");
+    expectedEvents.add("signal[archive]");
+    expectedEvents.add("execute[end]");
 
-    assertEquals("f", processInstance.getNodeName());
-    assertTrue(processInstance.isEnded());
+    assertEquals("end", execution.getNodeName());
     assertEquals(expectedEvents, recordedEvents);
   }
   
   public void testDelayedBegin() {
     List<String> recordedEvents = new ArrayList<String>(); 
+    AutomaticActivity automaticActivity = new AutomaticActivity(recordedEvents);
+    WaitState waitState = new WaitState(recordedEvents);
 
-    ClientProcessDefinition processDefinition = ProcessFactory.build()
-      .node("a").initial().behaviour(new WaitState(recordedEvents))
+    ClientProcessDefinition processDefinition = ProcessFactory.build("loan")
+      .node("submit loan request").initial().behaviour(automaticActivity)
+        .transition().to("evaluate")
+      .node("evaluate").behaviour(waitState)
+        .transition("approve").to("wire money")
+        .transition("reject").to("end")
+      .node("wire money").behaviour(automaticActivity)
+        .transition().to("archive")
+      .node("archive").behaviour(waitState)
+        .transition().to("end")
+      .node("end").behaviour(waitState)
     .done();
+  
     
     ClientProcessInstance processInstance = processDefinition.createProcessInstance();
     
-    // here, inbetween create and begin of a process instance, the variables can be initialized  
+    // here, inbetween create and start of a process instance, the variables can be initialized  
     // or subprocessinstance-superprocessinstance relation can be set up
 
     // so we verify that the process execution didn't start yet
@@ -139,7 +148,10 @@
     
     processInstance.start();
 
-    expectedEvents.add("execute[a]");
+    expectedEvents.add("execute[submit loan request]");
+    expectedEvents.add("execute[evaluate]");
+
+    assertEquals("evaluate", processInstance.getNodeName());
     assertEquals(expectedEvents, recordedEvents);
   }
 }

Modified: jbpm4/pvm/trunk/modules/core/src/test/resources/environment.cfg.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/resources/environment.cfg.xml	2008-09-15 14:58:48 UTC (rev 2252)
+++ jbpm4/pvm/trunk/modules/core/src/test/resources/environment.cfg.xml	2008-09-15 15:12:00 UTC (rev 2253)
@@ -25,7 +25,8 @@
     <hibernate-configuration>
       <properties resource="hibernate.properties" />
       <mappings resource="org/jbpm/pvm/pvm.hibernate.mappings.xml" />
-      <cache-configuration resource="org/jbpm/pvm/pvm.cache.xml" usage="nonstrict-read-write" />
+      <cache-configuration resource="org/jbpm/pvm/pvm.cache.xml" 
+                           usage="nonstrict-read-write" />
     </hibernate-configuration>
     
     <hibernate-session-factory />

Modified: jbpm4/pvm/trunk/modules/manual/pom.xml
===================================================================
--- jbpm4/pvm/trunk/modules/manual/pom.xml	2008-09-15 14:58:48 UTC (rev 2252)
+++ jbpm4/pvm/trunk/modules/manual/pom.xml	2008-09-15 15:12:00 UTC (rev 2253)
@@ -117,9 +117,9 @@
             <version>1.1.0</version>
           </dependency>
           <dependency>
-            <groupId>org.jboss</groupId>
-            <artifactId>jbossorg-jdocbook-style</artifactId>
-            <version>1.1.0</version>
+            <groupId>org.jbpm.jbpm4</groupId>
+            <artifactId>docbook-style</artifactId>
+            <version>1.0.0</version>
             <type>jdocbook-style</type>
           </dependency>
         </dependencies>

Modified: jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/master.xml
===================================================================
--- jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/master.xml	2008-09-15 14:58:48 UTC (rev 2252)
+++ jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/master.xml	2008-09-15 15:12:00 UTC (rev 2253)
@@ -10,7 +10,7 @@
 <book lang="en">
 
   <bookinfo>
-    <title>The Process Virtual Machine: Reference Manual</title>
+    <title>The Process Virtual Machine</title>
     <subtitle>A library for building executable state machines.  It can  
     serve as the foundation for any form of BPM, workflow and orchestration.
     </subtitle>

Modified: jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/ch02-ExecutionModes.xml
===================================================================
--- jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/ch02-ExecutionModes.xml	2008-09-15 14:58:48 UTC (rev 2252)
+++ jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/ch02-ExecutionModes.xml	2008-09-15 15:12:00 UTC (rev 2253)
@@ -47,28 +47,120 @@
       </para>
       <para>The <literal>processDefinition</literal> object serves as a factory for process 
       instance objects.  A process instance represents one execution of the process definition.
+      More precise, the process instance is the main path of execution.  
       </para>
       <programlisting>ClientExecution execution = processDefinition.startProcessInstance();</programlisting>
-      <para>The <literal>execution</literal> can be seen as a state machine.  
+      <para>A process instance 
+      itself is also an <literal>Execution</literal>.  Potentially, an execution can have 
+      child executions to represent concurrent paths of execution.
+      </para>  
+      <para>The <literal>execution</literal> can be seen as a state machine that operates as 
+      described in the process definition.  Starting a process 
+      instance means that the initial node of the process definition is executed.
+      Since this is an automatic activity, the execution will proceed to the 
+      <literal>evaluate</literal> node.  The <literal>evaluate</literal> node is a wait state.
+      When the execution arrived at the evaluate node, the method <literal>startProcessInstance</literal>
+      will return and waits until an external signal is provided with the <literal>signal</literal>
+      method.  So after the <literal>startProcessInstance</literal> we can verify if the 
+      execution is positioned in the evaluate node. 
       </para>
+      <programlisting>assertEquals("evaluate", processInstance.getNodeName());</programlisting>
+      <para>To make the process execute further, we provide an external trigger with the 
+      <literal>signal</literal> method.  The result of the evaluation will be given as the 
+      signalName parameter like this:
+      </para>
+      <programlisting>execution.signal("approve");</programlisting>
+      <para>The <literal>WaitState</literal> activity implementation will take the transition 
+      that corresponds to the given signalName.  So the execution will first execute 
+      the automatic activity <literal>wire money</literal> and then return after entering 
+      the next wait state <literal>archive</literal>.
+      </para>
+      <programlisting>assertEquals("archive", processInstance.getNodeName());</programlisting>
+      <para>When the execution is waiting in the archive node, the default signal will
+      make it take the first unnamed transition.
+      </para>
+      <programlisting>execution.signal();
+assertEquals("end", processInstance.getNodeName());</programlisting>
+      <para>The process has executed in the thread of the client.  The 
+      <literal>startProcessInstance</literal> method only returned when the <literal>evaluate</literal> 
+      node was reached.  In other words, the <literal>ClientProcessDefinition.startProcessInstance</literal>
+      and <literal>ClientExecution.signal</literal> methods are blocking until the next 
+      wait state is reached.
+      </para>
     </section>
     
     <section id="persistentexecutionmode">
       <title>Persistent execution mode</title>
-      <para>Embedded execution mode means that process definitions, the runtime 
-      executions and the history information all is stored in the PVM database
-      schema.
+      <para>The Process Virtual Machine also contains the hibernate mappings to store the 
+      process definitions and executions in any database.  A special session facade called 
+      <literal>ExecutionService</literal> is provided for working with process executions 
+      in such a persistent environment. 
       </para>
-    </section>
+      <para>Two configuration files should be available on the classpath: an environment 
+      configuration file and a <literal>hibernate.properties</literal> file.  A basic  
+      configuration for persistent execution mode in a standard Java environment looks 
+      like this:
+      </para>
+      <literal><emphasis role="bold">environment.cfg.xml</emphasis>:</literal>
+      <programlisting>&lt;contexts xmlns=&quot;http://jbpm.org/pvm/1.0/wire&quot;&gt;
+
+  &lt;environment-factory&gt;
   
-  <section id="persistentexecutionmode">
-    <title>Persistent execution mode</title>
-    <para>Embedded execution mode means that process definitions, the runtime 
-    executions and the history information all is stored in the PVM database
-    schema.
-    </para>
-  </section>
+    &lt;deployer-manager&gt;
+      &lt;language name=&quot;api&quot;&gt;
+        &lt;check-version /&gt;
+        &lt;create-id /&gt;
+        &lt;save-process /&gt;
+      &lt;/language&gt;
+    &lt;/deployer-manager&gt;
+    
+    &lt;process-service /&gt;
+    &lt;execution-service /&gt;
+    &lt;management-service /&gt;
+  
+    &lt;command-service&gt;
+      &lt;retry-interceptor /&gt;
+      &lt;environment-interceptor /&gt;
+      &lt;standard-transaction-interceptor /&gt;
+    &lt;/command-service&gt;
+    
+    &lt;hibernate-configuration&gt;
+      &lt;properties resource=&quot;hibernate.properties&quot; /&gt;
+      &lt;mappings resource=&quot;org/jbpm/pvm/pvm.hibernate.mappings.xml&quot; /&gt;
+      &lt;cache-configuration resource=&quot;org/jbpm/pvm/pvm.cache.xml&quot; 
+                           usage=&quot;nonstrict-read-write&quot; /&gt;
+    &lt;/hibernate-configuration&gt;
+    
+    &lt;hibernate-session-factory /&gt;
+    
+    &lt;id-generator /&gt;
+    
+    &lt;variable-types resource=&quot;org/jbpm/pvm/pvm.types.xml&quot; /&gt;
 
+    &lt;job-executor auto-start=&quot;false&quot; /&gt;
+  
+  &lt;/environment-factory&gt;
+
+  &lt;environment&gt;
+    &lt;hibernate-session /&gt;
+    &lt;transaction /&gt;
+    &lt;pvm-db-session /&gt;
+    &lt;job-db-session /&gt;
+    &lt;message-session /&gt;
+  &lt;/environment&gt;
+
+&lt;/contexts&gt;</programlisting>
+      <para>Then you can obtain the services from the environment factory like this:
+      </para>
+      <programlisting>EnvironmentFactory environmentFactory = new PvmEnvironmentFactory(&quot;environment.cfg.xml&quot;);
+
+processService = environmentFactory.get(ProcessService.class);
+executionService = environmentFactory.get(ExecutionService.class);
+managementService = environmentFactory.get(ManagementService.class);</programlisting>
+      <para>
+      </para>
+    </section>
+
   <section id="embeddedexecutionmode">
     <title>Embedded execution mode</title>
     <para>Embedded execution mode means that the state of a process is stored 




More information about the jbpm-commits mailing list