[jbpm-commits] JBoss JBPM SVN: r6115 - in jbpm4/trunk/modules: devguide/src/main/docbook/en/modules and 4 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Jan 21 09:27:20 EST 2010


Author: jbarrez
Date: 2010-01-21 09:27:19 -0500 (Thu, 21 Jan 2010)
New Revision: 6115

Added:
   jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.intermediate.timer.png
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/
   jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/IntermediateTimerTest.java
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/
   jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/intermediate_catch_timer_event.bpmn.xml
Modified:
   jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml
Log:
JBPM-2727: documented intermediate catch timer event

Added: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.intermediate.timer.png
===================================================================
(Binary files differ)


Property changes on: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.intermediate.timer.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml	2010-01-21 12:06:28 UTC (rev 6114)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml	2010-01-21 14:27:19 UTC (rev 6115)
@@ -1212,6 +1212,141 @@
   
   </section> <!-- End of basic constructs section -->
   
+  <section id="advancedConstructs">
+  
+    <title>Advanced constructs</title>
+    
+    <section id="intermediateEvents">
+    
+      <title>Intermediate events</title>
+      
+      <para>
+        An intermediate event is used to model something that happens during a process (ie. after
+        the process has started and before it is ended). Intermediate events are visualized as
+        a circle with a double border, with an icon indicating the event type within the circle.
+      </para>
+      
+      <para>
+        There are several intermediate event types, such as a timer event, signal event, escalation
+        event, etc. Intermediate events can be either throwing or catching:
+        <itemizedlist>
+          <listitem>
+            <emphasis role="bold">Throwing: </emphasis>when an execution arrives in the event, it 
+            immediately fires a certain trigger (a signal, an error, etc.). Throwing events can
+            be graphically recognized by the icon that is filled in with black.
+          </listitem>
+           <listitem>
+            <emphasis role="bold">Catching: </emphasis>when an execution arrives in the event,
+            it will wait for a certain trigger to happen (an error, a timer, etc.). Catching events
+            can be graphically recognized by the icon that is not filled with black (ie. white inside).
+          </listitem>
+        </itemizedlist>
+      </para>
+    
+    </section> <!-- end of intermediate events -->
+    
+    <section id="intermediateCatchTimer">
+    
+      <title>Intermediate catch event: Timer </title>
+      
+      <para>
+        An intermediate timer event is used to represent a <emphasis role="bold">delay</emphasis>
+        in the process. Straightfoward use cases are for example polling of data, executing
+        heavy logic only at night when nobody is working, etc.
+      </para>
+      
+      <para>
+        Note that an intermediate timer only can be used as a catch event (throwing a timer event
+        makes no sense). The following diagram shows how the intermediate timer event is visualized.
+        <mediaobject><imageobject><imagedata align="center" fileref="images/bpmn2.intermediate.timer.png"/></imageobject></mediaobject>
+        Defining an intermediate timer event is done in XML as follows:
+        <programlisting>
+&lt;intermediateCatchEvent id=&quot;myTimer&quot; name=&quot;Wait for an hour&quot;&gt;
+  &lt;timerEventDefinition&gt;
+    &lt;timeCycle&gt;1 hour&lt;/timeCycle&gt;
+  &lt;/timerEventDefinition&gt;
+&lt;/intermediateCatchEvent&gt;        
+        </programlisting>
+        There are two ways to specify the delay, using either a <emphasis role="bold">timeCycle
+        or a timeDate</emphasis>. In the example above, a timeCycle is used.
+      </para>
+      
+      <para>
+        Following delay definitions are possible.
+        <itemizedlist>
+          <listitem>
+            <emphasis role="bold">timeDate: </emphasis>specifies a fixed date when the timer will
+            fire and the process continues. The default format of the date specification is
+            &quot;dd/MM/yyyy hh:mm:ss&quot;. This can engine-wide be changed by setting the 
+            <emphasis role="bold">jbpm.duedatetime.format</emphasis> property in the configuration.
+            <programlisting>
+&lt;intermediateCatchEvent id=&quot;myTimer&quot; &gt;
+  &lt;timerEventDefinition&gt;
+    <emphasis role="bold">&lt;timeDate&gt;10/10/2099 00:00:00&lt;/timeDate&gt;</emphasis>
+  &lt;/timerEventDefinition&gt;
+&lt;/intermediateCatchEvent&gt;           
+            </programlisting>
+          </listitem>
+          <listitem>
+            <emphasis role="bold">timeCycle: </emphasis>specifies a delay duration relative to the
+            time when the execution enters the timer event. Two possible definitions are possible
+
+            <para>
+                <emphasis role="bold">Duration expression: </emphasis> 
+                <programlisting>
+quantity [business] {second | seconds | minute | minutes | 
+                     hour | hours | day | days | week | 
+                     weeks | month | months | year | years}                
+                </programlisting>
+                 This is completely similar to a timer duration definition in JPDL. Note that the 
+                 BPMN2 intermediate timer event also understands &quot;business time&quot;. This
+                 allows for example to define a &quot;business day&quot; as an interval from
+                 9am to 5pm. Timers that are started at 4pm with a duration of 2 hours, will fire
+                 at 10am the next business day. Please refer to the JPDL userguide for more details
+                 on how this business calendar can be customized.
+                 <programlisting>
+&lt;intermediateCatchEvent id=&quot;intermediateTimer&quot; &gt;
+  &lt;timerEventDefinition&gt;
+    <emphasis role="bold">&lt;timeCycle&gt;5 hours&lt;/timeCycle&gt;</emphasis>
+  &lt;/timerEventDefinition&gt;
+&lt;/intermediateCatchEvent&gt;               
+                 </programlisting>
+              </para>
+              <para>
+	              <emphasis role="bold">Cron expression: </emphasis>altough duration expressions cover
+	              already a great deal of delay definitions, sometimes they are not easy to use. When
+	              for example the process should be delayed until Friday night 23pm such that the
+	              processes can be executed in the weekend, duration expressions are hard to use
+	              (you need something like &quot;#{calculated_value} seconds&quot;, where you need
+	              to calculate the value first).
+	            </para>
+	            <para>
+	             <ulink url="http://en.wikipedia.org/wiki/CRON_expression">Cron expressions</ulink>
+	             allow to define delays in a way many people know (since cron expressions
+	             are used to define scheduled task on Unix machines). Note that a cron expression
+	             typically is used to define repetion. In this context however, the 
+	             <emphasis role="bold">first point in time where the cron expression is satisfied</emphasis>
+	             is used to set the due date of the timer event (so no repetition). The following example
+	             shows how an intermediate timer event can be specified to continue the process
+	             the next friday night at 23pm.
+	             <programlisting>
+&lt;intermediateCatchEvent id=&quot;intermediateTimer&quot; &gt;
+  &lt;timerEventDefinition&gt;
+    <emphasis role="bold">&lt;timeCycle&gt;0 0 23 ? * FRI&lt;/timeCycle&gt;</emphasis>
+      &lt;/timerEventDefinition&gt;
+&lt;/intermediateCatchEvent&gt;               
+	             </programlisting>
+	            </para>
+          </listitem>
+        </itemizedlist>
+      </para>
+    
+    </section> <!-- end of intermediate catch event -->
+    
+  </section> <!-- End of advanced constructs -->
+    
+    
+      
   <section id="completeExample">
   
     <title>Complete example (including console task forms)</title>

Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/IntermediateTimerTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/IntermediateTimerTest.java	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/event/timer/IntermediateTimerTest.java	2010-01-21 14:27:19 UTC (rev 6115)
@@ -0,0 +1,65 @@
+/*
+ * 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.bpmn.event.timer;
+
+import java.util.Date;
+
+import org.jbpm.api.NewDeployment;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.job.Job;
+import org.jbpm.pvm.internal.util.Clock;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * 
+ * @author Joram Barrez
+ */
+public class IntermediateTimerTest extends JbpmTestCase {
+
+  @Override
+  protected void setUp() throws Exception {
+    super.setUp();
+    NewDeployment deployment = repositoryService.createDeployment();
+    deployment.addResourceFromClasspath("org/jbpm/examples/bpmn/event/timer/intermediate_catch_timer_event.bpmn.xml");
+    registerDeployment(deployment.deploy());
+  }
+  
+  @Override
+  protected void tearDown() throws Exception {
+    super.tearDown();
+    Clock.setCurrentTime(null);
+  }
+
+  public void testIntermediateTimerWithDuration() {
+    Clock.setCurrentTime(new Date(0));
+    
+    ProcessInstance processInstance = executionService.startProcessInstanceByKey("intermediateTimerCatch");
+    Job timerJob = managementService.createJobQuery()
+                                    .processInstanceId(processInstance.getId())
+                                    .uniqueResult();
+    assertEquals(timerJob.getDuedate().getTime(), new Date(60 * 60 *1000).getTime());
+    
+    managementService.executeJob(timerJob.getId());
+    assertProcessInstanceEnded(processInstance);
+  }
+
+}

Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/intermediate_catch_timer_event.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/intermediate_catch_timer_event.bpmn.xml	                        (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/event/timer/intermediate_catch_timer_event.bpmn.xml	2010-01-21 14:27:19 UTC (rev 6115)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions 
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://schema.omg.org/spec/BPMN/2.0 ../../../../../../../../../../bpmn/src/main/resources/BPMN20.xsd"
+	xmlns="http://schema.omg.org/spec/BPMN/2.0" typeLanguage="http://www.w3.org/2001/XMLSchema"
+	expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://jbpm.org/example/bpmn2/intermediateTimerCatch">
+
+	<process id="intermediateTimerCatch" name="Bpmn 2.0 example intermediate timer catch event">
+
+   	<startEvent id="theStart" />
+   	
+   	<sequenceFlow id="flow1" sourceRef="theStart" targetRef="myTimer" />	
+   	
+   	<intermediateCatchEvent id="myTimer" name="Wait for an hour">
+   	  <timerEventDefinition>
+   	    <timeCycle xsi:type="tFormalExpression">1 hour</timeCycle>
+   	  </timerEventDefinition>
+   	</intermediateCatchEvent>
+   	
+   	<sequenceFlow id="flow2" sourceRef="myTimer" targetRef="theEnd" />  
+
+		<endEvent id="theEnd"  />
+		
+	</process>
+</definitions>



More information about the jbpm-commits mailing list