<?xml version="1.0" encoding="UTF-8"?>
<chapter id="ch.core-examples"
         version="5.0"
         xsi:schemaLocation="http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd http://www.w3.org/1999/xlink http://www.docbook.org/xml/5.0/xsd/xlink.xsd"
         xml:base="../" xmlns="http://docbook.org/ns/docbook" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xlink="http://www.w3.org/1999/xlink"
         xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:ns="http://docbook.org/ns/docbook">

  <title>Core Engine: Examples</title>

  <para></para>

  <section>
    <title>jBPM Examples</title>

    <para>There is a separate jBPM examples module that contains a set of example processes
    that show how to use the jBPM engine and the behavior or the different process constructs
    as defined by the BPMN 2.0 specification.</para>
    
    <para>To start using these, simply unzip the file somewhere and open up your Eclipse
    development environment with all required plugins installed.  If you don't know how to do 
    this yet, take a look at the installer chapter, where you can learn how to create a demo
    environment, including a fully configured Eclipse IDE, using the jBPM installer.  You can also
    take a look at the Eclipse plugin chapter if you want to learn how to manually install and
    configure this.</para>
    
    <para>To take a look at the examples, simply import the downloaded examples project into
    Eclipse (File -> Import ... -> Under General: Existing Projects into Workspace), browse to
    the folder where you unzipped the jBPM examples artefact and click finish.  This should
    import the examples project in your workspace, so you can start looking at the processes
    and executing the classes.</para>

  </section>
  
  <section>
    <title>Examples</title>
    
    <para>The examples module contains a number of examples, from basic to advanced:
      <itemizedlist>
        <listitem>Looping: An example that shows how you can use exclusive gateways to
        loop a part your process until the loop condition is no longer valid.  The process
        takes the 'count' (the number of times the loop needs to be repeated) as input and
        simply prints out a statement during every loop until the process is completed.</listitem>
        <listitem>MultiInstance: This example shows how to execute a sub-process for each
        element in a collection.  The process takes a collection of names as input and
        creates a review task for a sales representative for each person in that list.  The
        process completes if the task has been executed for every person on that list.</listitem>
        <listitem>Evaluation: A performance evaluation process that shows how to integrate
        human actors in the process.  While the basic example simply shows tasks assigned
        to predefined users, the more advanced version shows data passing from the process
        to the task and back, group assignment, task delegation, etc.</listitem>
        <listitem>HumanTask: An advanced example when using human tasks.  It shows how
        to do data passing between tasks, task forms, swimlanes, etc.  This example can also
        be deployed to the Guvnor repository (including all the forms etc.) and executed
        on the jBPM console out-of-the-box.</listitem>
        <listitem>Request: An advanced example that shows various ways in which processes
        and rules can work together, like a rule task for invoking validation rules, rules
        as expression language for constraints inside the process, rules for exception handling,
        event processing for monitoring, ad hoc rules for more flexible processes, etc.</listitem>
      </itemizedlist>
    </para>
    
  </section>
  
  <section>
    <title>Unit tests</title>
    
    <para>The examples project contains a large number of simple BPMN2 processes for each
    of the different node types that are supported by jBPM5.  In the junit folder under
    src/main/resources you can for example find process examples for constructs like a
    conditional start event, exclusive diverging gateways using default connections, etc.
    So if you're looking for a simple working example that shows the behavior of one specific
    element, you can probably find one here.  The folder already contains well over 50 sample
    processes.  Simply double-click them to open them in the graphical editor.</para>
    
    <para>Each of those processes is also accompanied by a small junit test that tests the
    implementation of that construct.  The org.jbpm.examples.junit.BPMN2JUnitTests class
    contains one test for each of the processes in the junit resources folder.  You can
    execute these tests yourself by selecting the method you want to execute (or the entire
    class) and right-click and then Run as -> JUnit test.</para>
    
  </section>

  <para>Check out the chapter on testing and debugging if you want to learn more how to
  debug these example processes.</para>
  
</chapter>
