@@ -0,0 +1,72 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.salaboy.jbpm5;

/**
*
* @author salaboy
*/
public class OnEntryNodeEvent implements NodeEvent{
private String nodeName;
private String processInstanceId;

public OnEntryNodeEvent() {
}


public OnEntryNodeEvent(String nodeName, String processInstanceId) {
this.nodeName = nodeName;
this.processInstanceId = processInstanceId;
}

public String getNodeName() {
return nodeName;
}

public void setNodeName(String nodeName) {
this.nodeName = nodeName;
}

public String getProcessInstanceId() {
return processInstanceId;
}

public void setProcessInstanceId(String processInstanceId) {
this.processInstanceId = processInstanceId;
}

@Override
public String toString() {
return "OnEntryNodeEvent{" + "nodeName=" + nodeName + ", processInstanceId=" + processInstanceId + '}';
}

@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final OnEntryNodeEvent other = (OnEntryNodeEvent) obj;
if ((this.nodeName == null) ? (other.nodeName != null) : !this.nodeName.equals(other.nodeName)) {
return false;
}
if ((this.processInstanceId == null) ? (other.processInstanceId != null) : !this.processInstanceId.equals(other.processInstanceId)) {
return false;
}
return true;
}

@Override
public int hashCode() {
int hash = 3;
hash = 97 * hash + (this.nodeName != null ? this.nodeName.hashCode() : 0);
hash = 97 * hash + (this.processInstanceId != null ? this.processInstanceId.hashCode() : 0);
return hash;
}


}
@@ -0,0 +1,72 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.salaboy.jbpm5;

/**
*
* @author salaboy
*/
public class OnExitNodeEvent implements NodeEvent{
private String nodeName;
private String processInstanceId;

public OnExitNodeEvent() {
}


public OnExitNodeEvent(String nodeName, String processInstanceId) {
this.nodeName = nodeName;
this.processInstanceId = processInstanceId;
}

public String getNodeName() {
return nodeName;
}

public void setNodeName(String nodeName) {
this.nodeName = nodeName;
}

public String getProcessInstanceId() {
return processInstanceId;
}

public void setProcessInstanceId(String processInstanceId) {
this.processInstanceId = processInstanceId;
}

@Override
public String toString() {
return "OnExitNodeEvent{" + "nodeName=" + nodeName + ", processInstanceId=" + processInstanceId + '}';
}

@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final OnExitNodeEvent other = (OnExitNodeEvent) obj;
if ((this.nodeName == null) ? (other.nodeName != null) : !this.nodeName.equals(other.nodeName)) {
return false;
}
if ((this.processInstanceId == null) ? (other.processInstanceId != null) : !this.processInstanceId.equals(other.processInstanceId)) {
return false;
}
return true;
}

@Override
public int hashCode() {
int hash = 3;
hash = 97 * hash + (this.nodeName != null ? this.nodeName.hashCode() : 0);
hash = 97 * hash + (this.processInstanceId != null ? this.processInstanceId.hashCode() : 0);
return hash;
}


}
@@ -0,0 +1,13 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.salaboy.jbpm5;

/**
*
* @author salaboy
*/
public interface ProcessEvent {

}
@@ -0,0 +1,90 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.salaboy.jbpm5;

/**
*
* @author salaboy
*/
//@PropertySpecific

public class ProcessVariable<T> {
private long processInstanceId;
private String name;
private T value;

public ProcessVariable(long processInstanceId, String name, T value) {
this.processInstanceId = processInstanceId;
this.name = name;
this.value = value;
}

public long getProcessInstanceId() {
return processInstanceId;
}

public void setProcessInstanceId(long processInstanceId) {
this.processInstanceId = processInstanceId;
}


public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public T getValue() {
return value;
}

public void setValue(T value) {
this.value = value;
}

@Override
public String toString() {
return "ProcessVariable{" + "processInstanceId=" + processInstanceId + ", name=" + name + ", value=" + value + '}';
}

@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final ProcessVariable other = (ProcessVariable) obj;
if (this.processInstanceId != other.processInstanceId) {
return false;
}
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
if (this.value != other.value && (this.value == null || !this.value.equals(other.value))) {
return false;
}
return true;
}

@Override
public int hashCode() {
int hash = 3;
hash = 47 * hash + (int) (this.processInstanceId ^ (this.processInstanceId >>> 32));
hash = 47 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 47 * hash + (this.value != null ? this.value.hashCode() : 0);
return hash;
}







}
@@ -0,0 +1,69 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.salaboy.model;

/**
*
* @author salaboy
*/
public class Customer {
public enum CustomerType{STARTER,GOLD, PLATINUM};
private String name;
private CustomerType type;

public Customer(String name, CustomerType type) {
this.name = name;
this.type = type;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public CustomerType getType() {
return type;
}

public void setType(CustomerType type) {
this.type = type;
}

@Override
public String toString() {
return "Customer{" + "name=" + name + ", type=" + type + '}';
}

@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Customer other = (Customer) obj;
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
if (this.type != other.type) {
return false;
}
return true;
}

@Override
public int hashCode() {
int hash = 7;
hash = 71 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 71 * hash + (this.type != null ? this.type.hashCode() : 0);
return hash;
}


}
@@ -0,0 +1,91 @@
package com.salaboy.model;

public class Person {

private String name;
private int age;
private String plan;
private int score;
public Person(String name, int age) {
super();
this.name = name;
this.age = age;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

public String getPlan() {
return plan;
}

public void setPlan(String plan) {
this.plan = plan;
}

public int getScore() {
return score;
}

public void setScore(int score) {
this.score = score;
}

@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Person other = (Person) obj;
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
if (this.age != other.age) {
return false;
}
if ((this.plan == null) ? (other.plan != null) : !this.plan.equals(other.plan)) {
return false;
}
if (this.score != other.score) {
return false;
}
return true;
}

@Override
public int hashCode() {
int hash = 7;
hash = 89 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 89 * hash + this.age;
hash = 89 * hash + (this.plan != null ? this.plan.hashCode() : 0);
hash = 89 * hash + this.score;
return hash;
}

@Override
public String toString() {
return "Person{" + "name=" + name + ", age=" + age + ", plan=" + plan + ", score=" + score + '}';
}






}
@@ -0,0 +1,68 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.salaboy.model;

/**
*
* @author salaboy
*/
public class RatesToday {
private int rateA;
private int rateB;

public RatesToday(int rateA, int rateB) {
this.rateA = rateA;
this.rateB = rateB;
}

public int getRateA() {
return rateA;
}

public void setRateA(int rateA) {
this.rateA = rateA;
}

public int getRateB() {
return rateB;
}

public void setRateB(int rateB) {
this.rateB = rateB;
}

@Override
public String toString() {
return "RatesToday{" + "rateA=" + rateA + ", rateB=" + rateB + '}';
}

@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final RatesToday other = (RatesToday) obj;
if (this.rateA != other.rateA) {
return false;
}
if (this.rateB != other.rateB) {
return false;
}
return true;
}

@Override
public int hashCode() {
int hash = 7;
hash = 23 * hash + this.rateA;
hash = 23 * hash + this.rateB;
return hash;
}


}
@@ -0,0 +1,31 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.salaboy.model;

/**
*
* @author salaboy
*/
public class Resources {
private int available;

public Resources(int available) {
this.available = available;
}

public int getAvailable() {
return available;
}

public void setAvailable(int available) {
this.available = available;
}

@Override
public String toString() {
return "Resources{" + "available=" + available + '}';
}

}
@@ -0,0 +1,145 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="Definition"
targetNamespace="http://www.jboss.org/drools"
typeLanguage="http://www.java.com/javaTypes"
expressionLanguage="http://www.mvel.org/2.0"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"
xmlns:g="http://www.jboss.org/drools/flow/gpd"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
xmlns:tns="http://www.jboss.org/drools">

<itemDefinition id="_personItem" structureRef="com.salaboy.model.Person" />

<process processType="Private" isExecutable="true" id="com.salaboy.process.SimpleDecision" name="Simple Decision Process" tns:packageName="defaultPackage" >

<extensionElements>
<tns:import name="com.salaboy.model.Person" />
<tns:import name="org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl" />
<tns:import name="org.drools.runtime.rule.FactHandle" />
</extensionElements>
<!-- process variables -->
<property id="person" itemSubjectRef="_personItem"/>

<!-- nodes -->
<startEvent id="_1" name="StartProcess" />
<scriptTask id="_2" name="Script 0" >
<script>System.out.println(" ### Script 0: "+kcontext.getVariable("person"));</script>
</scriptTask>
<inclusiveGateway id="_3" name="Gateway" gatewayDirection="Diverging" />
<scriptTask id="_4" name="Script 1" scriptFormat="http://www.java.com/java" >
<script>System.out.println(" ### Script 1: "+kcontext.getVariable("person"));
</script>
</scriptTask>
<scriptTask id="_5" name="Script 2" scriptFormat="http://www.java.com/java" >
<script>System.out.println(" ### Script 2: "+kcontext.getVariable("person"));
</script>
</scriptTask>
<scriptTask id="_6" name="Script 3" scriptFormat="http://www.java.com/java" >
<script>System.out.println(" ### Script 3: "+kcontext.getVariable("person"));
</script>
</scriptTask>
<exclusiveGateway id="_7" name="Gateway" gatewayDirection="Converging" />
<endEvent id="_8" name="End" >
<terminateEventDefinition/>
</endEvent>
<scriptTask id="_9" name="Script 4" >
<script>System.out.println(" ### Script 4: "+kcontext.getVariable("person"));</script>
</scriptTask>

<!-- connections -->
<sequenceFlow id="_1-_2" sourceRef="_1" targetRef="_2" />
<sequenceFlow id="_2-_3" sourceRef="_2" targetRef="_3" />
<sequenceFlow id="_3-_4" sourceRef="_3" targetRef="_4" name="between 18 and 25" tns:priority="1" >
<conditionExpression xsi:type="tFormalExpression" >return (((Person)kcontext.getVariable("person")).getAge() &gt; 18 &amp;&amp; ((Person)kcontext.getVariable("person")).getAge() &lt; 25)</conditionExpression>
</sequenceFlow>
<sequenceFlow id="_3-_5" sourceRef="_3" targetRef="_5" name="between 25 and 40" tns:priority="1" >
<conditionExpression xsi:type="tFormalExpression" >return (((Person)kcontext.getVariable("person")).getAge() &gt; 25 &amp;&amp; ((Person)kcontext.getVariable("person")).getAge() &lt; 40)</conditionExpression>
</sequenceFlow>
<sequenceFlow id="_3-_6" sourceRef="_3" targetRef="_6" name="under 18" tns:priority="1" >
<conditionExpression xsi:type="tFormalExpression" >return (((Person)kcontext.getVariable("person")).getAge() &lt; 18 )</conditionExpression>
</sequenceFlow>
<sequenceFlow id="_4-_7" sourceRef="_4" targetRef="_7" />
<sequenceFlow id="_5-_7" sourceRef="_5" targetRef="_7" />
<sequenceFlow id="_6-_7" sourceRef="_6" targetRef="_7" />
<sequenceFlow id="_9-_8" sourceRef="_9" targetRef="_8" />
<sequenceFlow id="_7-_9" sourceRef="_7" targetRef="_9" />

</process>

<bpmndi:BPMNDiagram>
<bpmndi:BPMNPlane bpmnElement="com.salaboy.process.SimpleDecision" >
<bpmndi:BPMNShape bpmnElement="_1" >
<dc:Bounds x="16" y="96" width="48" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_2" >
<dc:Bounds x="96" y="96" width="80" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_3" >
<dc:Bounds x="208" y="96" width="48" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_4" >
<dc:Bounds x="289" y="16" width="80" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_5" >
<dc:Bounds x="289" y="96" width="80" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_6" >
<dc:Bounds x="289" y="176" width="80" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_7" >
<dc:Bounds x="401" y="96" width="48" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_8" >
<dc:Bounds x="594" y="96" width="48" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_9" >
<dc:Bounds x="482" y="96" width="80" height="48" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="_1-_2" >
<di:waypoint x="40" y="120" />
<di:waypoint x="136" y="120" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_2-_3" >
<di:waypoint x="136" y="120" />
<di:waypoint x="232" y="120" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_3-_4" >
<di:waypoint x="232" y="120" />
<di:waypoint x="329" y="40" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_3-_5" >
<di:waypoint x="232" y="120" />
<di:waypoint x="329" y="120" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_3-_6" >
<di:waypoint x="232" y="120" />
<di:waypoint x="329" y="200" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_4-_7" >
<di:waypoint x="329" y="40" />
<di:waypoint x="425" y="120" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_5-_7" >
<di:waypoint x="329" y="120" />
<di:waypoint x="425" y="120" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_6-_7" >
<di:waypoint x="329" y="200" />
<di:waypoint x="425" y="120" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_9-_8" >
<di:waypoint x="522" y="120" />
<di:waypoint x="618" y="120" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="_7-_9" >
<di:waypoint x="425" y="120" />
<di:waypoint x="522" y="120" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>

</definitions>
@@ -0,0 +1,129 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.salaboy.jbpm5;

import com.salaboy.model.Person;
import com.salaboy.model.RatesToday;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.drools.KnowledgeBase;
import org.drools.KnowledgeBaseFactory;
import org.drools.WorkingMemory;
import org.drools.builder.KnowledgeBuilder;
import org.drools.builder.KnowledgeBuilderError;
import org.drools.builder.KnowledgeBuilderFactory;
import org.drools.builder.ResourceType;
import org.drools.event.*;
import org.drools.event.process.DefaultProcessEventListener;
import org.drools.event.process.ProcessStartedEvent;
import org.drools.impl.StatefulKnowledgeSessionImpl;
import org.drools.io.impl.ClassPathResource;
import org.drools.logger.KnowledgeRuntimeLoggerFactory;
import org.drools.process.instance.WorkItemHandler;
import org.drools.runtime.StatefulKnowledgeSession;
import org.drools.runtime.process.ProcessInstance;
import org.drools.runtime.process.WorkItem;
import org.drools.runtime.process.WorkItemManager;
import org.drools.runtime.rule.FactHandle;
import org.drools.runtime.rule.QueryResults;
import org.drools.runtime.rule.QueryResultsRow;
import org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl;
import org.junit.*;
import static org.junit.Assert.*;

/**
*
* @author salaboy
*/
public class PersistentProcessTest {

public PersistentProcessTest() {
}

@BeforeClass
public static void setUpClass() throws Exception {
}

@AfterClass
public static void tearDownClass() throws Exception {
}

@Before
public void setUp() {
}

@After
public void tearDown() {
}


@Test
public void processPersistenceTest() throws InterruptedException {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(new ClassPathResource("process-java-decision.bpmn"), ResourceType.BPMN2);

if (kbuilder.hasErrors()) {
for (KnowledgeBuilderError error : kbuilder.getErrors()) {
System.out.println(">>> Error:" + error.getMessage());

}
fail(">>> Knowledge couldn't be parsed! ");
}

KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();

kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());

final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);

((StatefulKnowledgeSessionImpl) ksession).getInternalWorkingMemory().addEventListener(
new DefaultAgendaEventListener() {

@Override
public void activationCreated(org.drools.event.ActivationCreatedEvent event, WorkingMemory workingMemory) {
System.out.println("Firing All the Rules! " + event);
workingMemory.fireAllRules();
}

@Override
public void afterRuleFlowGroupActivated(RuleFlowGroupActivatedEvent event, WorkingMemory workingMemory) {
System.out.println("Firing All the Rules! " + event);
workingMemory.fireAllRules();
}
});

((StatefulKnowledgeSessionImpl) ksession).addEventListener(new DefaultProcessEventListener() {
@Override
public void beforeProcessStarted(ProcessStartedEvent event) {
((StatefulKnowledgeSession) event.getKnowledgeRuntime()).fireAllRules();
}
@Override
public void afterProcessStarted(ProcessStartedEvent event) {
((StatefulKnowledgeSession) event.getKnowledgeRuntime()).fireAllRules();
}
});


Person person = new Person("Salaboy", 29);
Map<String, Object> params = new HashMap<String, Object>();
params.put("person", person);

ProcessInstance processInstance = ksession.createProcessInstance("com.salaboy.process.SimpleDecision", params);


ksession.startProcessInstance(processInstance.getId());







}


}
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.salaboy</groupId>
<artifactId>jbpm5-developer-guide</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>chapter07</artifactId>
<name>jBPM5 Developer Guide - Chapter 07</name>
<packaging>pom</packaging>
<url>http://salaboy.com</url>
<modules>
<module>jBPM5-PersistentProcess</module>
</modules>


</project>
@@ -23,23 +23,17 @@
<dependency>
<groupId>org.drools</groupId>
<artifactId>knowledge-api</artifactId>
<version>5.4.0-SNAPSHOT</version>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>5.4.0-SNAPSHOT</version>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>5.4.0-SNAPSHOT</version>
<version>${drools.version}</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jboss</id>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
</repositories>
</project>
@@ -18,17 +18,17 @@
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-flow</artifactId>
<version>5.2.0.Final</version>
<version>${jbpm.version}</version>
</dependency>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-flow-builder</artifactId>
<version>5.2.0.Final</version>
<version>${jbpm.version}</version>
</dependency>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-bpmn2</artifactId>
<version>5.2.0.Final</version>
<version>${jbpm.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
@@ -26,6 +26,7 @@
import org.drools.runtime.process.ProcessInstance;
import org.drools.runtime.rule.ConsequenceException;
import org.drools.runtime.rule.QueryResults;
import org.jbpm.workflow.instance.WorkflowRuntimeException;

import org.junit.Test;

@@ -100,7 +101,7 @@ public void beforeNodeLeft(ProcessNodeLeftEvent event) {
System.out.println(" ----- Process Number : " + i + " Completed ----");
System.out.println(" ----------------- ##### -----------------");
}
} catch (ConsequenceException e) {
} catch (WorkflowRuntimeException e) {
assertEquals(true, e.getCause().getMessage().contains("No More Resources Available = "));
}
}
@@ -23,34 +23,35 @@
<dependency>
<groupId>org.drools</groupId>
<artifactId>knowledge-api</artifactId>
<version>5.4.0-SNAPSHOT</version>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>5.4.0-SNAPSHOT</version>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>5.4.0-SNAPSHOT</version>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.swinglabs</groupId>
<artifactId>swing-layout</artifactId>
<version>1.0.3</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jboss</id>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
<repository>
<url>http://repo1.maven.org/maven2/</url>
<id>swing-layout</id>
<layout>default</layout>
<name>Repository for library Library[swing-layout]</name>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>com.salaboy.jbpm5.events.EventsTesterJFrame</mainClass>
</configuration>
</plugin>
</plugins>

</build>
</project>
@@ -57,7 +57,7 @@ public void testSimpleEvents() {
clock.advanceTime(2, TimeUnit.SECONDS);
assertEquals(1, fired);

// t3 -> 8s
// t4 -> 8s
ksession.insert(new KeyA());
fired = ksession.fireAllRules();
assertEquals(1, fired);
@@ -105,8 +105,6 @@ private StatefulKnowledgeSession createKnowledgeSession(){

KnowledgeBaseConfiguration config = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
config.setOption(EventProcessingOption.STREAM);


KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(config);

kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
@@ -23,17 +23,17 @@
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-flow</artifactId>
<version>5.4.0-SNAPSHOT</version>
<version>${jbpm.version}</version>
</dependency>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-flow-builder</artifactId>
<version>5.4.0-SNAPSHOT</version>
<version>${jbpm.version}</version>
</dependency>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-bpmn2</artifactId>
<version>5.4.0-SNAPSHOT</version>
<version>${jbpm.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
@@ -90,7 +90,7 @@ public void abortWorkItem(WorkItem wi, WorkItemManager wim) {
// do nothing
}
});
((StatefulKnowledgeSessionImpl) processKsession).addEventListener(new DefaultProcessEventListener() {
processKsession.addEventListener(new DefaultProcessEventListener() {

@Override
public void beforeProcessStarted(ProcessStartedEvent event) {
22 pom.xml
@@ -8,13 +8,33 @@
<version>1.0-SNAPSHOT</version>
<url>http://salaboy.com</url>
<packaging>pom</packaging>
<properties>
<jbpm.version>5.4.0-SNAPSHOT</jbpm.version>
<drools.version>5.5.0-SNAPSHOT</drools.version>
<hibernate.version>3.4.0.GA</hibernate.version>
<hibernate.core.version>3.3.2.GA</hibernate.core.version>

</properties>
<modules>
<module>chapter_02</module>
<module>chapter_03</module>
<module>chapter_05</module>
<module>chapter_06</module>
<module>chapter_07</module>
<module>chapter_08</module>
<module>chapter_09</module>
</modules>

<repositories>

<repository>
<id>jboss-repo</id>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
<repository>
<url>http://repo1.maven.org/maven2/</url>
<id>central</id>
<layout>default</layout>

</repository>
</repositories>
</project>