[jbpm-commits] JBoss JBPM SVN: r2275 - in jbpm4/pvm/trunk: hudson and 18 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Sep 17 11:47:24 EDT 2008
Author: tom.baeyens at jboss.com
Date: 2008-09-17 11:47:24 -0400 (Wed, 17 Sep 2008)
New Revision: 2275
Added:
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example01/
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example01/AutomaticActivity.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example01/ObjectExecutionModeTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example01/WaitState.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example02/
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example02/PersistentExecutionModeTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/EmbeddedExecutionModeTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/EmbeddedTests.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/Loan.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/examples/
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/examples/ExamplesTests.java
jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/example03/
jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/example03/Loan.hbm.xml
jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/example03/hibernate.cfg.xml
jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/images/interceptors.png
jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/ch04-BasicProcessExecutionConcepts.xml
jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/chxx-SoftwareLogging.xml
Removed:
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/embedded/
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/EmbeddedPersistenceTest.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/Loan.java
jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/api/db/embedded/
jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/example03/Order.hbm.xml
jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/example03/hibernate.cfg.xml
jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/ch04-SoftwareLogging.xml
jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/chxx-BasicGraphExecution.xml
jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/chxx-Services.xml
Modified:
jbpm4/pvm/trunk/.classpath
jbpm4/pvm/trunk/assembly.xml
jbpm4/pvm/trunk/hudson/build.xml
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/activity/ActivityExecution.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/listener/EventListenerExecution.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/test/base/EnvironmentFactoryTestCase.java
jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/test/base/EnvironmentFactoryTestSetup.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/DbTests.java
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/example03/AutomaticActivity.java
jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/WaitState.java
jbpm4/pvm/trunk/modules/manual/pom.xml
jbpm4/pvm/trunk/modules/manual/src/main/diagrams/images.ppt
jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/master.xml
jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/ch02-ExecutionModes.xml
jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/ch03-Architecture.xml
jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/chxx-AdvancedGraphExecution.xml
Log:
docs and packaging
Modified: jbpm4/pvm/trunk/.classpath
===================================================================
--- jbpm4/pvm/trunk/.classpath 2008-09-17 14:10:01 UTC (rev 2274)
+++ jbpm4/pvm/trunk/.classpath 2008-09-17 15:47:24 UTC (rev 2275)
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" output="modules/core/target/classes" path="modules/core/src/main/java"/>
- <classpathentry kind="src" output="modules/core/target/classes" path="modules/core/src/main/resources"/>
- <classpathentry kind="src" output="modules/core/target/test-classes" path="modules/core/src/test/java"/>
- <classpathentry kind="src" output="modules/core/target/test-classes" path="modules/core/src/test/resources"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER/modules"/>
- <classpathentry kind="output" path="target/classes"/>
+ <classpathentry kind="src" output="modules/core/target/classes" path="modules/core/src/main/java"/>
+ <classpathentry kind="src" output="modules/core/target/classes" path="modules/core/src/main/resources"/>
+ <classpathentry kind="src" output="modules/core/target/test-classes" path="modules/core/src/test/java"/>
+ <classpathentry kind="src" output="modules/core/target/test-classes" path="modules/core/src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER/modules"/>
+ <classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: jbpm4/pvm/trunk/assembly.xml
===================================================================
--- jbpm4/pvm/trunk/assembly.xml 2008-09-17 14:10:01 UTC (rev 2274)
+++ jbpm4/pvm/trunk/assembly.xml 2008-09-17 15:47:24 UTC (rev 2275)
@@ -9,7 +9,7 @@
<moduleSets>
<moduleSet>
<includes>
- <include>org.jbpm:pvm</include>
+ <include>org.jbpm.jbpm4:pvm-core</include>
</includes>
<binaries>
<outputDirectory></outputDirectory>
@@ -27,7 +27,7 @@
<fileSets>
<fileSet>
<directory>modules/core/target/apidocs</directory>
- <outputDirectory>doc/api-javadocs</outputDirectory>
+ <outputDirectory>doc/api</outputDirectory>
</fileSet>
<fileSet>
<directory>modules/core/src/main/java</directory>
@@ -38,8 +38,8 @@
<outputDirectory>src</outputDirectory>
</fileSet>
<fileSet>
- <directory>modules/core/target/doc-reference</directory>
- <outputDirectory>doc/reference</outputDirectory>
+ <directory>modules/manual/target/docbook/publish/en</directory>
+ <outputDirectory>doc/manual</outputDirectory>
<excludes>
<exclude>**/*.fo</exclude>
</excludes>
Modified: jbpm4/pvm/trunk/hudson/build.xml
===================================================================
--- jbpm4/pvm/trunk/hudson/build.xml 2008-09-17 14:10:01 UTC (rev 2274)
+++ jbpm4/pvm/trunk/hudson/build.xml 2008-09-17 15:47:24 UTC (rev 2275)
@@ -12,7 +12,8 @@
<!-- $Id$ -->
<project>
-
+
+
<property name="hudson.dir" value="${basedir}"/>
<property name="hudson.target.dir" value="${hudson.dir}/target"/>
@@ -23,10 +24,10 @@
<target name="init">
<!-- Check if ant.properties is available -->
- <available property="ant.properties.available" file="${basedir}/ant.properties"/>
- <fail message="Cannot find ant.properties. Did you copy/edit ant.properties.example?" unless="ant.properties.available"/>
+ <available property="hudson.properties.available" file="${user.home}/.jbpm4/hudson.properties"/>
+ <fail message="Cannot find ${user.home}/.jbpm4/hudson.properties. Did you copy/edit ant.properties.example?" unless="hudson.properties.available"/>
- <property file="${basedir}/ant.properties"/>
+ <property file="${user.home}/.jbpm4/hudson.properties"/>
<xmlproperty file="${basedir}/../pom.xml"/>
<property name="version.id" value="${project.version}"/>
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/activity/ActivityExecution.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/activity/ActivityExecution.java 2008-09-17 14:10:01 UTC (rev 2274)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/activity/ActivityExecution.java 2008-09-17 15:47:24 UTC (rev 2275)
@@ -29,7 +29,6 @@
import org.jbpm.pvm.model.Node;
import org.jbpm.pvm.model.ObservableElement;
import org.jbpm.pvm.model.OpenExecution;
-import org.jbpm.pvm.model.OpenProcessDefinition;
import org.jbpm.pvm.model.Transition;
import org.jbpm.pvm.processlog.ProcessLog;
import org.jbpm.pvm.session.PvmDbSession;
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/listener/EventListenerExecution.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/listener/EventListenerExecution.java 2008-09-17 14:10:01 UTC (rev 2274)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/listener/EventListenerExecution.java 2008-09-17 15:47:24 UTC (rev 2275)
@@ -37,6 +37,19 @@
*/
public interface EventListenerExecution extends OpenExecution {
+
+ /** the original object that fired the event, part of the current position in the
+ * process graph. Can be null in case no event is being fired. This is mostly the
+ * object that is listened to with an {@link Activity}, but the eventSource can also
+ * be a child of the object to which is listened in case of event propagation. */
+ ObservableElement getEventSource();
+
+ /** the event that is being fired, part of the current position in the process
+ * graph. Can be null in case no event is being fired. */
+ Event getEvent();
+
+ // candidates to be moved to OpenExecution:
+
// logs /////////////////////////////////////////////////////////////////////
/** adds a <a href="package-summary.html#logs">log</a> to this execution. */
@@ -56,17 +69,7 @@
/** the exception in case an exception handler is handling an exception. */
Exception getException();
-
- /** the original object that fired the event, part of the current position in the
- * process graph. Can be null in case no event is being fired. This is mostly the
- * object that is listened to with an {@link Activity}, but the eventSource can also
- * be a child of the object to which is listened in case of event propagation. */
- ObservableElement getEventSource();
- /** the event that is being fired, part of the current position in the process
- * graph. Can be null in case no event is being fired. */
- Event getEvent();
-
// extensions //////////////////////////////////////////////////////////////
/** way to access process language extensions in the execution without
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/test/base/EnvironmentFactoryTestCase.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/test/base/EnvironmentFactoryTestCase.java 2008-09-17 14:10:01 UTC (rev 2274)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/test/base/EnvironmentFactoryTestCase.java 2008-09-17 15:47:24 UTC (rev 2275)
@@ -79,24 +79,4 @@
environmentFactory.close();
}
}
-
- /*
- static String getConfigResource(Package p) {
- return p.getName().replace('.','/')+"/environment.cfg.xml";
- }
-
- static void setUpPackage(Package testPackage) {
- String packageName = testPackage.getName();
- createEnvironmentFactory(testPackage);
- }
-
- static void tearDownPackage(Package testPackage) {
- String packageName = testPackage.getName();
- EnvironmentFactory environmentFactory = environmentFactories.remove(packageName);
- if (environmentFactory!=null) {
- log.debug("closing environment factory for package ["+packageName+"]");
- environmentFactory.close();
- }
- }
- */
}
Modified: jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/test/base/EnvironmentFactoryTestSetup.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/test/base/EnvironmentFactoryTestSetup.java 2008-09-17 14:10:01 UTC (rev 2274)
+++ jbpm4/pvm/trunk/modules/core/src/main/java/org/jbpm/pvm/test/base/EnvironmentFactoryTestSetup.java 2008-09-17 15:47:24 UTC (rev 2275)
@@ -14,10 +14,6 @@
package org.jbpm.pvm.test.base;
-import org.jbpm.pvm.PvmException;
-import org.jbpm.pvm.env.EnvironmentFactory;
-import org.jbpm.pvm.env.PvmEnvironmentFactory;
-
import junit.extensions.TestSetup;
import junit.framework.Test;
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/DbTests.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/DbTests.java 2008-09-17 14:10:01 UTC (rev 2274)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/DbTests.java 2008-09-17 15:47:24 UTC (rev 2275)
@@ -25,10 +25,10 @@
import junit.framework.TestSuite;
import org.jbpm.pvm.api.db.continuation.ContinuationTests;
-import org.jbpm.pvm.api.db.embedded.EmbeddedTests;
import org.jbpm.pvm.api.db.svc.DbSvcTests;
import org.jbpm.pvm.api.spring.SpringTests;
import org.jbpm.pvm.api.tx.TxTests;
+import org.jbpm.pvm.example03.EmbeddedTests;
import org.jbpm.pvm.internal.db.langext.DbLangExtTests;
import org.jbpm.pvm.internal.db.model.DbModelTests;
import org.jbpm.pvm.internal.db.type.VariableCustomTypeTest;
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-17 14:10:01 UTC (rev 2274)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/basicfeatures/BasicExecutionFlowTest.java 2008-09-17 15:47:24 UTC (rev 2275)
@@ -28,11 +28,11 @@
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;
+import org.jbpm.pvm.example03.AutomaticActivity;
+import org.jbpm.pvm.example03.WaitState;
import org.jbpm.pvm.model.ProcessFactory;
import org.jbpm.pvm.test.base.JbpmTestCase;
Added: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example01/AutomaticActivity.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example01/AutomaticActivity.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example01/AutomaticActivity.java 2008-09-17 15:47:24 UTC (rev 2275)
@@ -0,0 +1,37 @@
+/*
+ * 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.pvm.example01;
+
+import org.jbpm.pvm.activity.Activity;
+import org.jbpm.pvm.activity.ActivityExecution;
+
+/**
+ * @author Tom Baeyens
+ */
+public class AutomaticActivity implements Activity {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ActivityExecution execution) throws Exception {
+ }
+
+}
Added: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example01/ObjectExecutionModeTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example01/ObjectExecutionModeTest.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example01/ObjectExecutionModeTest.java 2008-09-17 15:47:24 UTC (rev 2275)
@@ -0,0 +1,36 @@
+package org.jbpm.pvm.example01;
+
+import junit.framework.TestCase;
+
+import org.jbpm.pvm.client.ClientExecution;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.model.ProcessFactory;
+
+
+public class ObjectExecutionModeTest extends TestCase {
+
+
+ public void testObjectExecutionMode(){
+ ClientProcessDefinition processDefinition = ProcessFactory.build("loan")
+ .node("submit loan request").initial().behaviour(AutomaticActivity.class)
+ .transition().to("evaluate")
+ .node("evaluate").behaviour(WaitState.class)
+ .transition("approve").to("wire money")
+ .transition("reject").to("end")
+ .node("wire money").behaviour(AutomaticActivity.class)
+ .transition().to("archive")
+ .node("archive").behaviour(WaitState.class)
+ .transition().to("end")
+ .node("end").behaviour(WaitState.class)
+ .done();
+
+ ClientExecution execution = processDefinition.startProcessInstance();
+
+ assertEquals("evaluate", execution.getNodeName());
+
+ execution.signal("approve");
+
+ execution.signal();
+ assertEquals("end", execution.getNodeName());
+ }
+}
Added: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example01/WaitState.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example01/WaitState.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example01/WaitState.java 2008-09-17 15:47:24 UTC (rev 2275)
@@ -0,0 +1,44 @@
+/*
+ * 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.pvm.example01;
+
+import java.util.Map;
+
+import org.jbpm.pvm.activity.ActivityExecution;
+import org.jbpm.pvm.activity.ExternalActivity;
+
+/**
+ * @author Tom Baeyens
+ */
+public class WaitState implements ExternalActivity {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ActivityExecution execution) {
+ execution.waitForSignal();
+ }
+
+ public void signal(ActivityExecution execution,
+ String signalName,
+ Map<String, Object> parameters) {
+ }
+}
Added: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example02/PersistentExecutionModeTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example02/PersistentExecutionModeTest.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example02/PersistentExecutionModeTest.java 2008-09-17 15:47:24 UTC (rev 2275)
@@ -0,0 +1,51 @@
+package org.jbpm.pvm.example02;
+
+import org.jbpm.pvm.Deployment;
+import org.jbpm.pvm.Execution;
+import org.jbpm.pvm.ExecutionService;
+import org.jbpm.pvm.ManagementService;
+import org.jbpm.pvm.ProcessService;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.env.EnvironmentFactory;
+import org.jbpm.pvm.example01.AutomaticActivity;
+import org.jbpm.pvm.example01.WaitState;
+import org.jbpm.pvm.model.ProcessFactory;
+import org.jbpm.pvm.test.base.EnvironmentFactoryTestCase;
+
+
+public class PersistentExecutionModeTest extends EnvironmentFactoryTestCase {
+
+ public void testPersistentExecutionMode() {
+ // the default constructor of EnvironmentFactoryTestCase will use
+ // resource environment.cfg.xml
+ EnvironmentFactory environmentFactory = getEnvironmentFactory();
+
+ ProcessService processService = environmentFactory.get(ProcessService.class);
+ ExecutionService executionService = environmentFactory.get(ExecutionService.class);
+ ManagementService managementService = environmentFactory.get(ManagementService.class);
+
+ ClientProcessDefinition processDefinition = ProcessFactory.build("loan")
+ .node("submit loan request").initial().behaviour(AutomaticActivity.class)
+ .transition().to("evaluate")
+ .node("evaluate").behaviour(WaitState.class)
+ .transition("approve").to("wire money")
+ .transition("reject").to("end")
+ .node("wire money").behaviour(AutomaticActivity.class)
+ .transition().to("archive")
+ .node("archive").behaviour(WaitState.class)
+ .transition().to("end")
+ .node("end").behaviour(WaitState.class)
+ .done();
+
+ Deployment deployment = new Deployment(processDefinition);
+ processService.deploy(deployment);
+
+ Execution execution = executionService.startExecution("loan:1", "request7836");
+
+ assertEquals("evaluate", execution.getNodeName());
+
+ assertEquals("loan:1/request7836", execution.getId());
+
+ executionService.signalExecution("loan:1/request7836", "approve");
+ }
+}
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03 (from rev 2248, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/embedded)
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/AutomaticActivity.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/embedded/AutomaticActivity.java 2008-09-15 12:10:13 UTC (rev 2248)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/AutomaticActivity.java 2008-09-17 15:47:24 UTC (rev 2275)
@@ -19,7 +19,7 @@
* 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.pvm.api.db.embedded;
+package org.jbpm.pvm.example03;
import org.jbpm.pvm.activity.Activity;
import org.jbpm.pvm.activity.ActivityExecution;
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/EmbeddedExecutionModeTest.java (from rev 2248, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/embedded/EmbeddedPersistenceTest.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/EmbeddedExecutionModeTest.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/EmbeddedExecutionModeTest.java 2008-09-17 15:47:24 UTC (rev 2275)
@@ -0,0 +1,106 @@
+/*
+ * 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.pvm.example03;
+
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.Transaction;
+import org.hibernate.cfg.Configuration;
+import org.jbpm.pvm.test.base.JbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class EmbeddedExecutionModeTest extends JbpmTestCase {
+
+ SessionFactory sessionFactory;
+ Session session;
+ Transaction transaction;
+
+ public void testLoanApprove() {
+ Configuration configuration = new Configuration();
+ configuration.configure("org/jbpm/pvm/example03/hibernate.cfg.xml");
+ sessionFactory = configuration.buildSessionFactory();
+
+ startTransaction();
+
+ Loan loan = new Loan("john doe", 234.0);
+ session.save(loan);
+ assertEquals("evaluate", loan.getState());
+
+ newTransaction();
+
+ loan = (Loan) session.get(Loan.class, loan.getDbid());
+ assertEquals("evaluate", loan.getState());
+ loan.approve();
+ assertEquals("archive", loan.getState());
+
+ newTransaction();
+
+ loan = (Loan) session.get(Loan.class, loan.getDbid());
+ assertEquals("archive", loan.getState());
+ loan.archiveComplete();
+ assertEquals("end", loan.getState());
+
+ commitTransaction();
+ }
+
+ public void testLoanReject() {
+ Configuration configuration = new Configuration();
+ configuration.configure("org/jbpm/pvm/example03/hibernate.cfg.xml");
+ sessionFactory = configuration.buildSessionFactory();
+
+ startTransaction();
+
+ Loan loan = new Loan("john doe", 234.0);
+ session.save(loan);
+ assertEquals("evaluate", loan.getState());
+
+ newTransaction();
+
+ loan = (Loan) session.get(Loan.class, loan.getDbid());
+ assertEquals("evaluate", loan.getState());
+ loan.reject();
+ assertEquals("end", loan.getState());
+
+ newTransaction();
+
+ loan = (Loan) session.get(Loan.class, loan.getDbid());
+ assertEquals("end", loan.getState());
+ }
+
+
+ void newTransaction() {
+ commitTransaction();
+ startTransaction();
+ }
+
+ void startTransaction() {
+ session = sessionFactory.openSession();
+ transaction = session.beginTransaction();
+ }
+
+ void commitTransaction() {
+ transaction.commit();
+ session.close();
+ }
+}
Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/EmbeddedPersistenceTest.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/embedded/EmbeddedPersistenceTest.java 2008-09-15 12:10:13 UTC (rev 2248)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/EmbeddedPersistenceTest.java 2008-09-17 15:47:24 UTC (rev 2275)
@@ -1,104 +0,0 @@
-/*
- * 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.pvm.api.db.embedded;
-
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.jbpm.pvm.test.base.JbpmTestCase;
-
-/**
- * @author Tom Baeyens
- */
-public class EmbeddedPersistenceTest extends JbpmTestCase {
-
- SessionFactory sessionFactory;
- Session session;
- Transaction transaction;
-
- public void testLoanApprove() {
- Configuration configuration = new Configuration();
- configuration.configure("org/jbpm/pvm/api/db/embedded/hibernate.cfg.xml");
- sessionFactory = configuration.buildSessionFactory();
-
- startTransaction();
-
- Loan loan = new Loan("john doe", 234.0);
- session.save(loan);
- assertEquals("evaluate", loan.getState());
-
- newTransaction();
-
- loan = (Loan) session.get(Loan.class, loan.getDbid());
- assertEquals("evaluate", loan.getState());
- loan.approve();
- assertEquals("end", loan.getState());
-
- newTransaction();
-
- loan = (Loan) session.get(Loan.class, loan.getDbid());
- assertEquals("validate", loan.getState());
-
- commitTransaction();
- }
-
- public void testLoanReject() {
- Configuration configuration = new Configuration();
- configuration.configure("org/jbpm/pvm/api/db/embedded/hibernate.cfg.xml");
- sessionFactory = configuration.buildSessionFactory();
-
- startTransaction();
-
- Loan loan = new Loan("john doe", 234.0);
- session.save(loan);
- assertEquals("evaluate", loan.getState());
-
- newTransaction();
-
- loan = (Loan) session.get(Loan.class, loan.getDbid());
- assertEquals("evaluate", loan.getState());
- loan.approve();
- assertEquals("end", loan.getState());
-
- newTransaction();
-
- loan = (Loan) session.get(Loan.class, loan.getDbid());
- assertEquals("validate", loan.getState());
- }
-
-
- void newTransaction() {
- commitTransaction();
- startTransaction();
- }
-
- void startTransaction() {
- session = sessionFactory.openSession();
- transaction = session.beginTransaction();
- }
-
- void commitTransaction() {
- transaction.commit();
- session.close();
- }
-}
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/EmbeddedTests.java (from rev 2263, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/embedded/EmbeddedTests.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/EmbeddedTests.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/EmbeddedTests.java 2008-09-17 15:47:24 UTC (rev 2275)
@@ -0,0 +1,17 @@
+package org.jbpm.pvm.example03;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+
+public class EmbeddedTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("org.jbpm.pvm.api.db.embedded");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(EmbeddedExecutionModeTest.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
Deleted: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/Loan.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/embedded/Loan.java 2008-09-15 12:10:13 UTC (rev 2248)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/Loan.java 2008-09-17 15:47:24 UTC (rev 2275)
@@ -1,96 +0,0 @@
-/*
- * 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.pvm.api.db.embedded;
-
-
-import org.jbpm.pvm.client.ClientExecution;
-import org.jbpm.pvm.client.ClientProcessDefinition;
-import org.jbpm.pvm.model.ProcessFactory;
-
-/**
- * @author Tom Baeyens
- */
-public class Loan {
-
- // the loan process definition as a static resource
- private static final ClientProcessDefinition processDefinition = createLoanProcess();
-
- private static ClientProcessDefinition createLoanProcess() {
- ClientProcessDefinition processDefinition = ProcessFactory.build("loan")
- .node("submit loan request").initial().behaviour(AutomaticActivity.class)
- .transition().to("evaluate")
- .node("evaluate").behaviour(WaitState.class)
- .transition("approve").to("wire money")
- .transition("reject").to("end")
- .node("wire money").behaviour(AutomaticActivity.class)
- .transition().to("archive")
- .node("archive").behaviour(WaitState.class)
- .transition().to("end")
- .node("end").behaviour(WaitState.class)
- .done();
-
- return processDefinition;
- }
-
- long dbid;
- String customer;
- double amount;
- ClientExecution execution;
-
- // constructor for persistence
- protected Loan() {
- }
-
- public Loan(String customer, double amount) {
- this.customer = customer;
- this.amount = amount;
- this.execution = processDefinition.startProcessInstance();
- }
-
- public void approve() {
- execution.signal("approve");
- }
-
- public void reject() {
- execution.signal("reject");
- }
-
- public void archiveComplete() {
- execution.signal();
- }
-
- public String getState() {
- return execution.getNode().getName();
- }
-
- // getters //////////////////////////////////////////////////////////////////
-
- public long getDbid() {
- return dbid;
- }
- public String getCustomer() {
- return customer;
- }
- public double getAmount() {
- return amount;
- }
-}
Copied: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/Loan.java (from rev 2263, jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/embedded/Loan.java)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/Loan.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/Loan.java 2008-09-17 15:47:24 UTC (rev 2275)
@@ -0,0 +1,101 @@
+/*
+ * 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.pvm.example03;
+
+
+import org.jbpm.pvm.client.ClientExecution;
+import org.jbpm.pvm.client.ClientProcessDefinition;
+import org.jbpm.pvm.model.ProcessFactory;
+
+/**
+ * @author Tom Baeyens
+ */
+public class Loan {
+
+ /** the loan process definition as a static resource */
+ private static final ClientProcessDefinition processDefinition = createLoanProcess();
+
+ private static ClientProcessDefinition createLoanProcess() {
+ ClientProcessDefinition processDefinition = ProcessFactory.build("loan")
+ .node("submit loan request").initial().behaviour(AutomaticActivity.class)
+ .transition().to("evaluate")
+ .node("evaluate").behaviour(WaitState.class)
+ .transition("approve").to("wire money")
+ .transition("reject").to("end")
+ .node("wire money").behaviour(AutomaticActivity.class)
+ .transition().to("archive")
+ .node("archive").behaviour(WaitState.class)
+ .transition().to("end")
+ .node("end").behaviour(WaitState.class)
+ .done();
+
+ return processDefinition;
+ }
+
+ /** exposes the process definition to the execution hibernate type */
+ private static ClientProcessDefinition getProcessDefinition() {
+ return processDefinition;
+ }
+
+ long dbid;
+ String customer;
+ double amount;
+ ClientExecution execution;
+
+ /** constructor for persistence */
+ protected Loan() {
+ }
+
+ public Loan(String customer, double amount) {
+ this.customer = customer;
+ this.amount = amount;
+ this.execution = processDefinition.startProcessInstance();
+ }
+
+ public void approve() {
+ execution.signal("approve");
+ }
+
+ public void reject() {
+ execution.signal("reject");
+ }
+
+ public void archiveComplete() {
+ execution.signal();
+ }
+
+ public String getState() {
+ return execution.getNodeName();
+ }
+
+ // getters //////////////////////////////////////////////////////////////////
+
+ public long getDbid() {
+ return dbid;
+ }
+ public String getCustomer() {
+ return customer;
+ }
+ public double getAmount() {
+ return amount;
+ }
+}
Modified: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/WaitState.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/api/db/embedded/WaitState.java 2008-09-15 12:10:13 UTC (rev 2248)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/example03/WaitState.java 2008-09-17 15:47:24 UTC (rev 2275)
@@ -19,7 +19,7 @@
* 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.pvm.api.db.embedded;
+package org.jbpm.pvm.example03;
import java.util.Map;
Added: jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/examples/ExamplesTests.java
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/examples/ExamplesTests.java (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/java/org/jbpm/pvm/examples/ExamplesTests.java 2008-09-17 15:47:24 UTC (rev 2275)
@@ -0,0 +1,27 @@
+package org.jbpm.pvm.examples;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jbpm.pvm.example01.ObjectExecutionModeTest;
+import org.jbpm.pvm.example02.PersistentExecutionModeTest;
+import org.jbpm.pvm.example03.EmbeddedExecutionModeTest;
+import org.jbpm.pvm.test.base.EnvironmentFactoryTestSetup;
+
+public class ExamplesTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("org.jbpm.pvm.examples");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(ObjectExecutionModeTest.class);
+ suite.addTestSuite(EmbeddedExecutionModeTest.class);
+
+ TestSuite defaultConfigTests = new TestSuite("default config tests");
+ defaultConfigTests.addTestSuite(PersistentExecutionModeTest.class);
+ suite.addTest(new EnvironmentFactoryTestSetup(defaultConfigTests, "environment.cfg.xml"));
+
+ //$JUnit-END$
+ return suite;
+ }
+
+}
Copied: jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/example03 (from rev 2248, jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/api/db/embedded)
Copied: jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/example03/Loan.hbm.xml (from rev 2263, jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/api/db/embedded/Loan.hbm.xml)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/example03/Loan.hbm.xml (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/example03/Loan.hbm.xml 2008-09-17 15:47:24 UTC (rev 2275)
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.jbpm.pvm.example03" default-access="field">
+
+ <typedef name="execution" class="org.jbpm.pvm.internal.hibernate.ExecutionType" />
+
+ <class name="Loan" table="LOAN">
+
+ <id name="dbid">
+ <generator class="sequence"/>
+ </id>
+
+ <property name="execution" type="execution" />
+ <property name="customer" />
+ <property name="amount" />
+
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Deleted: jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/example03/Order.hbm.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/api/db/embedded/Order.hbm.xml 2008-09-15 12:10:13 UTC (rev 2248)
+++ jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/example03/Order.hbm.xml 2008-09-17 15:47:24 UTC (rev 2275)
@@ -1,18 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping package="org.jbpm.pvm.api.db.embedded" default-access="field">
-
- <typedef name="execution" class="org.jbpm.pvm.internal.hibernate.ExecutionType" />
-
- <class name="Order" table="ORDERS">
-
- <id name="dbid">
- <generator class="sequence"/>
- </id>
-
- <property name="processInstance" type="execution" />
-
- </class>
-
-</hibernate-mapping>
\ No newline at end of file
Deleted: jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/example03/hibernate.cfg.xml
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/api/db/embedded/hibernate.cfg.xml 2008-09-15 12:10:13 UTC (rev 2248)
+++ jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/example03/hibernate.cfg.xml 2008-09-17 15:47:24 UTC (rev 2275)
@@ -1,23 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-
-<!DOCTYPE hibernate-configuration PUBLIC
- "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
-
-<hibernate-configuration>
- <session-factory>
-
- <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
- <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
- <property name="hibernate.connection.url">jdbc:hsqldb:mem:.</property>
- <property name="hibernate.connection.username">sa</property>
- <property name="hibernate.connection.password"></property>
- <property name="hibernate.hbm2ddl.auto">create</property>
- <property name="hibernate.show_sql">true"</property>
- <property name="hibernate.format_sql">true"</property>
- <property name="hibernate.use_sql_comments">true"</property>
-
- <mapping resource="org/jbpm/pvm/api/db/embedded/Order.hbm.xml"/>
-
- </session-factory>
-</hibernate-configuration>
Copied: jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/example03/hibernate.cfg.xml (from rev 2263, jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/api/db/embedded/hibernate.cfg.xml)
===================================================================
--- jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/example03/hibernate.cfg.xml (rev 0)
+++ jbpm4/pvm/trunk/modules/core/src/test/resources/org/jbpm/pvm/example03/hibernate.cfg.xml 2008-09-17 15:47:24 UTC (rev 2275)
@@ -0,0 +1,23 @@
+<?xml version='1.0' encoding='utf-8'?>
+
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory>
+
+ <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+ <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
+ <property name="hibernate.connection.url">jdbc:hsqldb:mem:.</property>
+ <property name="hibernate.connection.username">sa</property>
+ <property name="hibernate.connection.password"></property>
+ <property name="hibernate.hbm2ddl.auto">create</property>
+ <property name="hibernate.show_sql">true"</property>
+ <property name="hibernate.format_sql">true"</property>
+ <property name="hibernate.use_sql_comments">true"</property>
+
+ <mapping resource="org/jbpm/pvm/example03/Loan.hbm.xml"/>
+
+ </session-factory>
+</hibernate-configuration>
Modified: jbpm4/pvm/trunk/modules/manual/pom.xml
===================================================================
--- jbpm4/pvm/trunk/modules/manual/pom.xml 2008-09-17 14:10:01 UTC (rev 2274)
+++ jbpm4/pvm/trunk/modules/manual/pom.xml 2008-09-17 15:47:24 UTC (rev 2275)
@@ -29,89 +29,36 @@
<relativePath>../../pom.xml</relativePath>
</parent>
+ <dependencies>
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>pvm-core</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
<build>
+ <!-- ### PLUGINS ###################################################### -->
<plugins>
-<!--
<plugin>
- <groupId>com.agilejava.docbkx</groupId>
- <artifactId>docbkx-maven-plugin</artifactId>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ <version>2.1.2</version>
+ <extensions>true</extensions>
+
<executions>
<execution>
- <id>manual</id>
- <goals>
- <goal>generate-html</goal>
- </goals>
<phase>package</phase>
- <configuration>
- <sourceDirectory>${basedir}/src/main/docbook/en</sourceDirectory>
- <targetDirectory>${basedir}/target/manual/html_single</targetDirectory>
- <postProcess>
- <copy todir="${basedir}/target/manual/html_single/images">
- <fileset dir="${basedir}/src/main/docbook/en/images">
- <include name="**/*.png" />
- <include name="**/*.gif" />
- <include name="**/*.jpg" />
- </fileset>
- </copy>
- </postProcess>
- </configuration>
- </execution>
-
- <execution>
- <id>doc-reference chunk html</id>
<goals>
- <goal>generate-html</goal>
+ <goal>resources</goal>
+ <goal>generate</goal>
</goals>
- <phase>package</phase>
- <configuration>
- <sourceDirectory>${basedir}/src/docbook/doc-reference/en</sourceDirectory>
- <targetDirectory>${basedir}/target/manual/html/reference</targetDirectory>
- <chunkedOutput>true</chunkedOutput>
- <postProcess>
- <copy todir="${basedir}/target/manual/html/reference/images">
- <fileset
- dir="${basedir}/src/docbook/doc-reference/en/images">
- <include name="**/*.png" />
- <include name="**/*.gif" />
- <include name="**/*.jpg" />
- </fileset>
- </copy>
- </postProcess>
- </configuration>
</execution>
- <execution>
- <id>doc-reference pdf</id>
- <goals>
- <goal>generate-pdf</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <sourceDirectory>${basedir}/src/docbook/doc-reference/en</sourceDirectory>
- <targetDirectory>${basedir}/target/manual/pdf/reference</targetDirectory>
- <imgSrcPath>${basedir}/src/docbook/doc-reference/en/</imgSrcPath>
- </configuration>
- </execution>
+ </executions>
- </executions>
<dependencies>
<dependency>
- <groupId>org.docbook</groupId>
- <artifactId>docbook-xml</artifactId>
- <version>4.4</version>
- <scope>runtime</scope>
- </dependency>
- </dependencies>
- </plugin>
--->
-
- <plugin>
- <groupId>org.jboss.maven.plugins</groupId>
- <artifactId>maven-jdocbook-plugin</artifactId>
- <extensions>true</extensions>
-
- <dependencies>
- <dependency>
<groupId>org.jboss</groupId>
<artifactId>jbossorg-docbook-xslt</artifactId>
<version>1.1.0</version>
@@ -128,7 +75,7 @@
<sourceDocumentName>master.xml</sourceDocumentName>
<masterTranslation>en</masterTranslation>
<imageResource>
- <directory>src/main/docbook/en</directory>
+ <directory>${basedir}/src/main/docbook/en</directory>
<includes>
<include>images/*.png</include>
</includes>
@@ -141,6 +88,7 @@
</format>
</formats>
</configuration>
+
</plugin>
</plugins>
Modified: jbpm4/pvm/trunk/modules/manual/src/main/diagrams/images.ppt
===================================================================
(Binary files differ)
Added: jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/images/interceptors.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/images/interceptors.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
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-17 14:10:01 UTC (rev 2274)
+++ jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/master.xml 2008-09-17 15:47:24 UTC (rev 2275)
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book [
- <!ENTITY ch01-Introduction SYSTEM "modules/ch01-Introduction.xml">
- <!ENTITY ch02-ExecutionModes SYSTEM "modules/ch02-ExecutionModes.xml">
- <!ENTITY ch03-Architecture SYSTEM "modules/ch03-Architecture.xml">
- <!ENTITY ch04-SoftwareLogging SYSTEM "modules/ch04-SoftwareLogging.xml">
+ <!ENTITY ch01-Introduction SYSTEM "modules/ch01-Introduction.xml">
+ <!ENTITY ch02-ExecutionModes SYSTEM "modules/ch02-ExecutionModes.xml">
+ <!ENTITY ch03-Architecture SYSTEM "modules/ch03-Architecture.xml">
+ <!ENTITY ch04-BasicProcessExecutionConcepts SYSTEM "modules/ch04-BasicProcessExecutionConcepts.xml">
]>
<book lang="en">
@@ -21,6 +21,6 @@
&ch01-Introduction;
&ch02-ExecutionModes;
&ch03-Architecture;
- &ch04-SoftwareLogging;
+ &ch04-BasicProcessExecutionConcepts;
</book>
\ No newline at end of file
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-17 14:10:01 UTC (rev 2274)
+++ jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/ch02-ExecutionModes.xml 2008-09-17 15:47:24 UTC (rev 2275)
@@ -64,7 +64,7 @@
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>
+ <programlisting>assertEquals("evaluate", execution.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:
@@ -75,12 +75,12 @@
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>
+ <programlisting>assertEquals("archive", execution.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>
+assertEquals("end", execution.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>
@@ -165,9 +165,9 @@
</para>
<programlisting>EnvironmentFactory environmentFactory = new PvmEnvironmentFactory("environment.cfg.xml");
-processService = environmentFactory.get(ProcessService.class);
-executionService = environmentFactory.get(ExecutionService.class);
-managementService = environmentFactory.get(ManagementService.class);</programlisting>
+ProcessService processService = environmentFactory.get(ProcessService.class);
+ExecutionService executionService = environmentFactory.get(ExecutionService.class);
+ManagementService managementService = environmentFactory.get(ManagementService.class);</programlisting>
<para>The responsibility of the <literal>ProcessService</literal> is to manage
the repository of process definitions. Before we can start a process execution,
the process definition needs to be deployed into the process repository.
@@ -225,6 +225,11 @@
process execution like this:
</para>
<programlisting>executionService.signalExecution("loan:1/request7836", "approve");</programlisting>
+ <para>More information about service interfaces to run in persistent
+ mode can be found in package
+ <ulink url="../../api/org/jbpm/pvm/package-summary.html"><literal>org.jbpm.pvm</literal> of the
+ api docs</ulink>.
+ </para>
</section>
<section id="embeddedexecutionmode">
Modified: jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/ch03-Architecture.xml
===================================================================
--- jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/ch03-Architecture.xml 2008-09-17 14:10:01 UTC (rev 2274)
+++ jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/ch03-Architecture.xml 2008-09-17 15:47:24 UTC (rev 2275)
@@ -110,7 +110,8 @@
environment.close();
}</programlisting>
<para>The PVM itself will fetch all it's transactional resources and configurations
- from the environment.
+ from the environment. It's recommended that <literal>Activity</literal> implementations
+ do the same.
</para>
</section>
@@ -129,16 +130,121 @@
<section>
<title>Services</title>
- <para>Services are session facades that expose methods for persistent usage of
- the PVM.
+ <para>There are three services: <literal>ProcessService</literal>,
+ <literal>ExecutionService</literal> and <literal>ManagementService</literal>.
+ In general, services are session facades that expose methods for persistent
+ usage of the PVM. The next fragments show the essential methods as example
+ to illustrate those services.
</para>
- </section>
+ <para>The <literal>ProcessService</literal> manages the repository of
+ process definitions.
+ </para>
+ <programlisting>public interface ProcessService {
- <section>
- <title>Configuration</title>
- <para>
+ ProcessDefinition deploy(Deployment deployment);
+
+ ProcessDefinition findLatestProcessDefinition(String processDefinitionName);
+
+ ...
+
+}</programlisting>
+ <para>The <literal>ExecutionService</literal> manages the runtime
+ executions.</para>
+ <programlisting>public interface ExecutionService {
+
+ Execution startExecution(String processDefinitionId, String executionKey);
+
+ Execution signalExecution(String executionId, String signalName);
+
+ ...
+
+}</programlisting>
+ <para>The <literal>ManagementService</literal> groups all management operations
+ that are needed to keep the system up and running.
</para>
+ <programlisting>public interface ManagementService {
+
+ List<Job> getJobsWithException(int firstResult, int maxResults);
+
+ void executeJob(String jobId);
+
+ ...
+
+}</programlisting>
+ <para>The implementation of all these methods is encapsulated in
+ <literal>Command</literal>s. And the three services all delegate the
+ execution of the commands to a <literal>CommandService</literal>:
+ </para>
+ <programlisting>public interface CommandService {
+
+ <T> T execute(Command<T> command);
+
+}</programlisting>
+ <para>The <literal>CommandService</literal> is configured in the
+ environment. A chain of CommandServices can act as interceptors
+ around a command. This is the core mechanism on how persistence and
+ transactional support can be offered in a variety of environments.
+ </para>
+ <para>From the default configuration which is included in full above,
+ here is the section that configures the services
+ </para>
+ <programlisting><contexts xmlns="http://jbpm.org/pvm/1.0/wire">
+
+ <environment-factory>
+
+ <process-service />
+ <execution-service />
+ <management-service />
+
+ <command-service>
+ <retry-interceptor />
+ <environment-interceptor />
+ <standard-transaction-interceptor />
+ </command-service>
+
+ ...
+ </programlisting>
+ <para>The three services <literal>process-service</literal>, <literal>execution-service</literal>
+ and <literal>management-service</literal> will look up the configured
+ <literal>command-service</literal> by type. The <literal>command-service</literal>
+ tag corresponds to the default command service that essentially does nothing else
+ then just execute the command providing it the current environment.
+ </para>
+ <para>The configured <literal>command-service</literal> results into the following
+ a chain of three interceptors followed by the default command executor.
+ </para>
+ <figure id="interceptors">
+ <title>The CommandService interceptors</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/interceptors.png"/></imageobject></mediaobject>
+ </figure>
+ <para>The retry interceptor is the first in the chain and that one that will be exposed as the
+ <literal>CommandService.class</literal> from the environment. So the retry interceptor
+ will be given to the respective services <literal>process-service</literal>, <literal>execution-service</literal>
+ and <literal>management-service</literal>.
+ </para>
+ <para>The <literal>retry-interceptor</literal> will catch hibernate StaleObjectExceptions
+ (indicating optimistic locking failures) and retry to execute the command.
+ </para>
+ <para>The <literal>environment-interceptor</literal> will put an environment block
+ around the execution of the command.
+ </para>
+ <para>The <literal>standard-transaction-interceptor</literal> will initialize a
+ <literal>StandardTransaction</literal>. The hibernate session/transaction will be
+ enlisted as a resource with this standard transaction.
+ </para>
+ <para>Different configurations of this interceptor stack will also enable to
+ </para>
+ <itemizedlist>
+ <listitem>delegate execution to a local ejb command service so that an container
+ managed transaction is started.
+ </listitem>
+ <listitem>delegate to a remote ejb command service so that the command actually
+ gets executed on a different JVM.
+ </listitem>
+ <listitem>package the command as an asynchronous message so that the command gets
+ executed asynchronously in a different transaction.
+ </listitem>
+ </itemizedlist>
</section>
-
</chapter>
\ No newline at end of file
Copied: jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/ch04-BasicProcessExecutionConcepts.xml (from rev 2248, jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/chxx-BasicGraphExecution.xml)
===================================================================
--- jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/ch04-BasicProcessExecutionConcepts.xml (rev 0)
+++ jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/ch04-BasicProcessExecutionConcepts.xml 2008-09-17 15:47:24 UTC (rev 2275)
@@ -0,0 +1,544 @@
+<chapter id="basicprocessexecutionconcepts">
+ <title>Basic process execution concepts</title>
+
+ <para>This chapter explains the basics of process definitions, the features offered by
+ the Process Virtual Machine and how activity implementations can be build. At the same
+ time the client API is shown to execute processes with those activity implementations.
+ </para>
+
+ <!-- ### Activity ####################################################### -->
+ <section id="activity">
+ <title>Activity</title>
+ <para>The PVM library doesn't have a fixed set of process constructs.
+ Instead, runtime behaviour of a node is delegated to an <literal>Activity</literal>.
+ In other words, <literal>Activity</literal> is an interface to implement the runtime
+ behaviour of process constructs in plain Java.
+ </para>
+ <programlisting>public <emphasis role="bold">interface Activity</emphasis> extends Serializable {
+
+ void <emphasis role="bold">execute</emphasis>(ActivityExecution execution) throws Exception;
+
+}</programlisting>
+ <para>When an activity is used as the node behaviour, it is in full control of the further
+ propagation of the execution. In other words, a node behaviour can decide what the execution
+ should do next. For example, it can take a transition with
+ <literal>execution.take(Transition)</literal> or go into a wait state with
+ <literal>execution.waitForSignal()</literal>. In case the node behaviour does not invoke
+ any of the above execution propagation methods, the execution will
+ <link linkend="defaultproceedbehaviour">proceed in a default way</link>.
+ </para>
+ </section>
+
+ <!-- ### Activity example ############################################### -->
+ <section id="activityexample">
+ <title>Activity example</title>
+ <para>We'll start with a very original hello world example. A Display
+ activity will print a message to the console:
+ </para>
+ <programlisting>public <emphasis role="bold">class Display</emphasis> implements <emphasis role="bold">Activity</emphasis> {
+
+ String message;
+
+ public Display(String message) {
+ this.message = message;
+ }
+
+ public void execute(ActivityExecution execution) {
+ <emphasis role="bold">System.out.println(message);</emphasis>
+ }
+}</programlisting>
+ <para>Let' build our first process definition with this activity:</para>
+ <figure id="activity.example">
+ <title>Activity example process</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting>ProcessDefinition processDefinition = ProcessFactory.build()
+ .<emphasis role="bold">node("a").initial()</emphasis>.behaviour(<emphasis role="bold">new Display("hello")</emphasis>)
+ .transition().to("b")
+ .<emphasis role="bold">node("b")</emphasis>.behaviour(<emphasis role="bold">new Display("world")</emphasis>)
+.done();</programlisting>
+ <para>Now we can execute this process as follows:</para>
+ <programlisting>Execution execution = processDefinition.startExecution();</programlisting>
+ <para>The invocation of <literal>startExecution</literal> will print hello world to the console:</para>
+ <programlisting>hello
+world</programlisting>
+ <para>One thing already worth noticing is that activities can be configured
+ with properties. In the Display example, you can see that the message property
+ is configured differently in the two usages. With configuration properties
+ it becomes possible to write reusable activities. They can then be configured
+ differently each time they are used in a process. That is an essential part of
+ how process languages can be build on top of the Process Virtual Machine.
+ </para>
+ </section>
+
+ <!-- ### ExternalActivity ############################################### -->
+ <section id="externalactivity">
+ <title>ExternalActivity</title>
+ <para>External activities are activities for which the responsibility for proceeding
+ the execution is transferred externally, meaning outside the process system. This
+ means that for the system that is executing the process, it's a wait state. The
+ execution will wait until an external trigger is given.
+ </para>
+ <para>For dealing with external triggers, <literal>ExternalActivity</literal>
+ adds two methods to the <literal>Activity</literal>:</para>
+ <programlisting>public <emphasis role="bold">interface ExternalActivity</emphasis> extends <emphasis role="bold">Activity</emphasis> {
+
+ void <emphasis role="bold">signal</emphasis>(Execution execution,
+ String signal,
+ Map<String, Object> parameters) throws Exception;
+
+}</programlisting>
+ <para>Just like with plain activities, when an execution arrives in a node, the
+ <literal>execute</literal>-method of the node behaviour is invoked.
+ In external activities, the execute method typically does something to
+ transfer the responsibility to another system and then enters a wait
+ state by invoking <literal>execution.waitForSignal()</literal>. For
+ example in the execute method, responsibility could be transferred to a
+ person by creating a task entry in a task management system and then
+ wait until the person completes the task.
+ </para>
+ <para>In case a node behaves as a wait state, then the execution will
+ wait in that node until the execution's <literal>signal</literal> method
+ is invoked. The execution will delegate that signal to the behaviour Activity
+ of the current node.
+ </para>
+ <para>So the Activity's <literal>signal</literal>-method is invoked
+ when the execution receives an external trigger during the wait state. With the
+ signal method, responsibility is transferred back to the process execution. For
+ example, when a person completes a task, the task management system calls the
+ signal method on the execution.
+ </para>
+ <para>A signal can optionally have a signal name and a map of parameters. Most
+ common way on how node behaviours interprete the signal and parameters is that
+ the signal relates to the outgoing transition that needs to be taken and that the
+ parameters are set as variables on the execution. But those are just examples, it
+ is up to the activity to use the signal and the parameters as it pleases.
+ </para>
+ </section>
+
+ <!-- ### ExternalActivity example ####################################### -->
+ <section id="externalactivityexample">
+ <title>ExternalActivity example</title>
+ <para>Here's a first example of a simple wait state implementation:
+ </para>
+ <programlisting>public <emphasis role="bold">class WaitState</emphasis> implements ExternalActivity {
+
+ public void <emphasis role="bold">execute</emphasis>(Execution execution) {
+ execution.waitForSignal();
+ }
+
+ public void <emphasis role="bold">signal</emphasis>(Execution execution,
+ String signal,
+ Map<String, Object> parameters) {
+ execution.take(signal);
+ }
+}</programlisting>
+ <para>The <literal>execute</literal>-method calls
+ <literal>execution.waitForSignal()</literal>. This call is
+ necessary to prevent automatic propagation of the execution. By calling
+ <literal>execution.waitForSignal()</literal>, the node will
+ behave as a wait state.
+ </para>
+ <para><literal>signal</literal>-method takes the transition with
+ the signal parameter as the transition name. So when an execution receives an
+ external trigger, the signal name is interpreted as the name of an outgoing
+ transition and the execution will be propagated over that transition.
+ </para>
+ <para>Here's the same simple process that has a transition from a to b. This
+ time, the behaviour of the two nodes will be WaitState's.
+ </para>
+ <figure id="process.diagram">
+ <title>Process diagram</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting>ProcessDefinition processDefinition = ProcessFactory.build()
+ .<emphasis role="bold">node("a").initial()</emphasis>.behaviour(<emphasis role="bold">new WaitState()</emphasis>)
+ .transition().to("b")
+ .<emphasis role="bold">node("b")</emphasis>.behaviour(<emphasis role="bold">new WaitState()</emphasis>)
+.done();</programlisting>
+
+<programlisting>Execution execution = processDefinition.startExecution();</programlisting>
+<programlisting>execution.signal();</programlisting>
+ </section>
+
+ <!-- ### BASIC PROCESS EXECUTION ######################################## -->
+ <section id="basicprocessexecution">
+ <title>Basic process execution</title>
+ <para>In this next example, we'll combine automatic activities and wait states.
+ This example is a simplified version of a loan approval process. Graphically,
+ it looks like this:
+ </para>
+ <figure id="the.first.graph.process">
+ <title>The first graph process</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/first.graph.process.png"/></imageobject></mediaobject>
+ </figure>
+ <para>Building process graphs in Java code can be tedious because you have to keep track of all the
+ references in local variables. To resolve that, the Process Virtual Machine comes with a
+ ProcessFactory. The ProcessFactory is a kind of domain specific language (DSL) that is embedded
+ in Java and eases the construction of process graphs. This pattern is also known as
+ a <ulink url="http://martinfowler.com/bliki/FluentInterface.html">fluent
+ interface</ulink>.
+ </para>
+ <programlisting>ProcessDefinition processDefinition = ProcessFactory.build()
+ .<emphasis role="bold">node("accept loan request").initial()</emphasis>.behaviour(new WaitState())
+ .transition().to("loan evaluation")
+ .<emphasis role="bold">node("loan evaluation")</emphasis>.behaviour(new WaitState())
+ .transition("approve").to("wire the money")
+ .transition("reject").to("end")
+ .<emphasis role="bold">node("wire the money")</emphasis>.behaviour(new Display("automatic payment"))
+ .transition().to("end")
+ .<emphasis role="bold">node("end")</emphasis>.behaviour(new WaitState())
+.done();</programlisting>
+ <para>For more details about the ProcessFactory, see the javadocs. An alternative for
+ the ProcessFactory would be to create an XML language and an XML parser for expressing
+ processes. The XML parser can then instantiate the classes of package
+ <literal>org.jbpm.pvm.internal.model</literal> directly. That approach is typically taken by
+ process languages.
+ </para>
+ <para>The node <literal>wire the money</literal> is an automatic node. The
+ <literal>Display</literal> implementation uses the Java API's to just print a
+ message to the console. But the witty reader can imagine an alternative
+ <literal>Activity</literal> implementation that uses the Java API of a payment
+ processing library to make a real automatic payment. All the other nodes are
+ wait states.
+ </para>
+ <para>A new execution for the process above can be started like this
+ </para>
+ <programlisting>Execution execution = processDefinition.startExecution();</programlisting>
+ <para>Starting a new execution implies that the initial node is executed. Since in
+ this case it's a wait state, the new execution will be positioned in the
+ node 'accept loan request' when the <literal>startExecution</literal>-method returns.
+ </para>
+ <figure id="first.execution.state.accept">
+ <title>Execution positioned in 'accept loan request'</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/execution.state.accept.png"/></imageobject></mediaobject>
+ </figure>
+ <para>Now we can give this execution an external trigger with the <literal>signal</literal>-
+ method on the execution. Invoking the signal method will take the execution to the next
+ wait state.
+ </para>
+ <programlisting>execution.signal();</programlisting>
+ <figure id="execution.state.evaluation">
+ <title>Execution positioned in 'loan evaluation'</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/execution.state.evaluation.png"/></imageobject></mediaobject>
+ </figure>
+ <para>Now, the execution is at an interesting point. There are two transitions out of
+ the state 'loan evaluation'. One transition is called 'approve' and one transition
+ is called 'reject'. As we explained above in the WaitState implementation, the transition
+ taken corresponds to the signal that is given. Let's feed in the 'approve' signal like this:
+ </para>
+ <programlisting>execution.signal("approve");</programlisting>
+ <para>The 'approve' signal will cause the execution to take the 'approve' transition and
+ it will arrive in the node 'wire the money'.
+ </para>
+ <para>In <literal>wire the money</literal>, the message will be printed to the console.
+ Since, the <literal>Display</literal> activity didn't invoke the
+ <literal>execution.waitForSignal()</literal>, nor any of the other execution propagation
+ methods, the default behaviour will be to just proceed.
+ </para>
+ <para><link linkend="defaultproceedbehaviour">Proceeding</link> in this case means that
+ the default outgoing transition is taken and the execution will arrive in the <literal>end</literal>
+ node, which is a wait state.</para>
+ <para>So only when the <literal>end</literal> wait state is reached, the <literal>signal("approve")</literal>
+ returns. That is because all of the things that needed to be done between the original
+ state and this new state could be executed by the process system. Executing till the
+ next wait state is the default behaviour and that behaviour can be changed with
+ </para>
+ <para><emphasis role="bold">TODO: add link to async continuations</emphasis></para>
+ <para>asynchronous continuations in case
+ transactions should not include all calculations till the next wait state. For
+ more about this, see <xref linkend="executionandthreads" />.
+ </para>
+ <para>Another signal invocation will bring it eventually in the end state.</para>
+ <figure id="execution.state.end">
+ <title>Execution positioned in 'end'</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/execution.state.end.png"/></imageobject></mediaobject>
+ </figure>
+ </section>
+
+ <!-- ### MOTIVATION ##################################################### -->
+ <section id="motivation">
+ <title>Motivation</title>
+ <para>There are basically two forms of process languages: graph based and composite
+ process languages. First of all, this design supports both. Even graph based execution
+ and node composition can be used in combination to implement something like UML super states.
+ </para>
+ <para>In this design, control flow activity implementations will have to be
+ aware of whether they are dependent on transitions (graph based) or whether they are
+ using the composite node structure. The goal of this design is that all non-control
+ flow activities can be implemented in the same way so that you can use them in graph
+ based process languages as well as in composite process languages.
+ </para>
+ </section>
+
+ <!-- ### EVENTS ######################################################### -->
+ <section id="events">
+ <title>Events</title>
+ <para>Events are points in the process definition to which a list of
+ activities can be subscribed as listeners. The motivation for events is to allow for
+ developers to add programming logic to a process without changing the process diagram.
+ This is a very valuable instrument in
+ facilitating the collaboration between business analysts and developers. Business analysts
+ are responsible for expressing the requirements. When they use a process graph to document
+ those requirements, developers can take this diagram and make it executable. Events can
+ be a very handy to insert technical details into a process (like e.g. some database insert)
+ in which the business analyst is not interested.
+ </para>
+ <para>Most common events are fired by the execution automatically:
+ </para>
+ <itemizedlist>
+ <listitem><literal>Transition.EVENT_TRANSITION_TAKE = "transition-take"</literal> :
+ fired on transitions when transitions are taken.
+ </listitem>
+ <listitem><literal>Node.EVENT_NODE_ENTER = "node-enter"</literal> : fired on the node
+ when execution enters that node. This happens when execution takes a transition
+ to that node, when a child node is being executed with <literal>execution.execute(Node)</literal>
+ or when a transition is taken from a node outside that node to a contained node.
+ The latter refers to super states in state machines.
+ </listitem>
+ <listitem><literal>Node.EVENT_NODE_LEAVE = "node-leave"</literal> : fired on the node
+ when a transition is taken out of that node or when a child node execution is
+ finished and the execution is propagated to the parent node.
+ </listitem>
+ <listitem><literal>ProcessDefinition.EVENT_PROCESS_START = "process-start"</literal> : fired on a process
+ when a new process is started.
+ </listitem>
+ <listitem><literal>ProcessDefinition.EVENT_PROCESS_END = "process-end"</literal> : fired on a process
+ when a new process is ended. This might include a executions that are ended
+ with a cancelled or error state.
+ </listitem>
+ </itemizedlist>
+ <para>Events are identified by the combination of a process element
+ and an event name. Users and process languages can also fire events
+ programmatically with the fire method on the Execution:
+ </para>
+ <programlisting>public interface Execution extends Serializable {
+ ...
+ void fire(String eventName, ProcessElement eventSource);
+ ...
+}</programlisting>
+
+ <para>A list of <link linkend="activity"><literal>Activity</literal>s</link> can be associated to an
+ event. But activities on events can not influence the control flow of the execution since
+ they are merely listeners to an execution wich is already in progress. This is different from
+ activities that serve as the behaviour for nodes. Node behaviour activities are responsible
+ for propagating the execution. So if an activity in an event invokes any of the
+ following methods, then it will result in an exception.
+ </para>
+
+ <itemizedlist>
+ <listitem><literal>waitForSignal()</literal></listitem>
+ <listitem><literal>take(Transition)</literal></listitem>
+ <listitem><literal>end(*)</literal></listitem>
+ <listitem><literal>execute(Node)</literal></listitem>
+ </itemizedlist>
+
+ <para>We'll reuse the <literal><link linkend="activity">Display</link></literal>
+ activity from above in a simple process: two nodes connected by a
+ transition. The Display listener will be subscribed to the transition event.</para>
+ <figure id="action.process">
+ <title>The process to which a listener activity will be associated</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting>ProcessDefinition processDefinition = ProcessFactory.build()
+ .node("a").initial().behaviour(new WaitState())
+ <emphasis role="bold">.event("node-leave")
+ .listener(new Display("leaving a"))
+ .listener(new Display("second message while leaving a"))</emphasis>
+ .transition().to("b")
+ <emphasis role="bold">.listener(new Display("taking transition"))</emphasis>
+ .node("b").behaviour(new WaitState())
+ <emphasis role="bold">.event("node-enter")
+ .listener(new Display("entering b"))</emphasis>
+.done();</programlisting>
+ <para>The first event shows how to register multiple listeners to the same
+ event. They will be notified in the order as they are specified.
+ </para>
+ <para>Then, on the transition, there is only one type of event. So in that case,
+ the event type must not be specified and the listeners can be added directly on
+ the transition.
+ </para>
+ <para>A listeners will be called each time an execution fires the event to
+ which the listener is subscribed. The execution will be provided in the activity
+ interface as a parameter and can be used by listeners except for the methods that
+ control the propagation of execution.
+ </para>
+ </section>
+
+ <!-- ### EVENT PROPAGATION ############################################## -->
+ <section>
+ <title>Event propagation</title>
+ <para>Events are by default propagated to enclosing process elements. The motivation
+ is to allow for listeners on process definitions or composite nodes that get executed
+ for all events that occur within that process element. For example this feature
+ allows to register a listener on a process definition or a composite node on
+ <literal>node-leave</literal> events. Such action will be executed if that node is
+ left. And if that listener is registered on a composite node, it will also be executed
+ for all nodes that are left within that composite node.
+ </para>
+ <para>To show this clearly, we'll create a <literal>DisplaySource</literal> activity
+ that will print the message <literal>leaving</literal> and the source of the event
+ to the console.
+ </para>
+ <programlisting>public class <emphasis role="bold">DisplaySource</emphasis> implements Activity {
+
+ public void execute(Execution execution) {
+ <emphasis role="bold">System.out.println("leaving "+execution.getEventSource());</emphasis>
+ }
+}</programlisting>
+ <para>Note that the purpose of event listeners is not to be visible, that's why the activity
+ itself should not be displayed in the diagram. A <literal>DisplaySource</literal> activity
+ will be added as a listener to the event <literal>node-leave</literal> on the composite node.
+ </para>
+ <para>The next process shows how the <literal>DisplaySource</literal> activity is registered
+ as a listener to to the 'node-leave' event on the <literal>composite</literal> node:</para>
+ <figure id="propagation.process">
+ <title>A process with an invisible activity on a node-leave event on a composite node.</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/propagation.process.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting>ProcessDefinition processDefinition = ProcessFactory.build("propagate")
+ .compositeNode("composite")
+ <emphasis role="bold">.event(Node.EVENT_NODE_LEAVE)
+ .listener(new DisplaySource())</emphasis>
+ .node("a").initial().behaviour(new WaitState())
+ .transition().to("b")
+ .node("b").behaviour(new WaitState())
+ .transition().to("c")
+ .compositeEnd()
+ .node("c").behaviour(new WaitState())
+.done();</programlisting>
+ <para>Next we'll start an execution.</para>
+ <programlisting>Execution execution = processDefinition.startExecution();</programlisting>
+ <para>After starting a new execution, the execution will be in node <literal>a</literal> as
+ that is the initial node. No nodes have been left so no message is logged. Next a signal
+ will be given to the execution, causing it to take the transition from <literal>a</literal>
+ to <literal>b</literal>.
+ </para>
+ <programlisting>execution.signal();</programlisting>
+ <para>When the signal method returns, the execution will have taken the transition and
+ the node-leave event will be fired on node a. That event will be propagated to the
+ composite node and to the process definition. Since our propagation logger is placed
+ on node composite it will receive the event and print the following message:
+ </para>
+ <programlisting>leaving node(a)</programlisting>
+ <para>Another</para>
+ <programlisting>execution.signal();</programlisting>
+ <para>will take the transition from b to c. That will fire two node-leave events. One on
+ node b and one on node composite. So the following lines will be appended to the console
+ output:</para>
+ <programlisting>leaving node(b)
+leaving node(composite)</programlisting>
+ <para>Event propagation is build on the hierarchical composition structure of the process
+ definition. The top level element is always the process definition. The process
+ definition contains a list of nodes. Each node can be a leaf node or it can be a
+ composite node, which means that it contains a list of nested nodes. Nested nodes
+ can be used for e.g. super states or composite activities in nested process languages like BPEL.
+ </para>
+ <para>So the even model also works similarly for composite nodes as it did for the process
+ definition above. Suppose that 'Phase one' models
+ a super state as in state machines. Then event propagation allows to subscribe to all events
+ within that super state. The idea is that the hierarchical composition corresponds to
+ diagram representation. If an element 'e' is drawn inside another element 'p', then p
+ is the parent of e. A process definition has a set of top level nodes. Every node can have
+ a set of nested nodes. The parent of a transition is considered as the first common
+ parent for it's source and destination.
+ </para>
+ <para>If an event listener is not interested in propagated events, propagation can be disabled
+ with <literal>propagationDisabled()</literal>. The next process is the same process
+ as above except that propagated events will be disabled on the event listener. The graph diagram
+ remains the same.
+ </para>
+ <figure id="propagation.disabled.process">
+ <title>A process with a listener to 'node-leave' events with propagation disabled.</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/propagation.process.png"/></imageobject></mediaobject>
+ </figure>
+ <para>Building the process with the process factory:
+ </para>
+ <programlisting>ProcessDefinition processDefinition = ProcessFactory.build("propagate")
+ .compositeNode("composite")
+ <emphasis role="bold">.event(Node.EVENT_NODE_LEAVE)
+ .listener(new DisplaySource())
+ .propagationDisabled()</emphasis>
+ .node("a").initial().behaviour(new WaitState())
+ .transition().to("b")
+ .node("b").behaviour(new WaitState())
+ .transition().to("c")
+ .nodesEnd()
+ .node("c").behaviour(new WaitState())
+.done();</programlisting>
+ <para>So when the first signal is given for this process, again the node-leave event will be
+ fired on node a, but now the listener on the composite node will not be executed cause
+ propagated events have been disabled. Disabling propagation is a property on the listener
+ and doesn't influence the other listeners. The event will always be fired and propagated
+ over the whole parent hierarchy.
+ </para>
+ <programlisting>Execution execution = processDefinition.startExecution();
+execution.signal();
+</programlisting>
+ <para>Next, the second signal will take the transition from b to c.
+ </para>
+ <programlisting>execution.signal()</programlisting>
+ <para>Again two node-leave
+ events are fired just like above on nodes b and composite respectively. The first event
+ is the node-leave event on node b. That will be propagated to the composite node. So the
+ listener will not be executed for this event cause it has propagation disabled. But the
+ listener will be executed for the node-leave event on the composite node. That is not
+ propagated, but fired directly on the composite node. So the listener will now be executed
+ only once for the composite node as shown in the following console output:
+ </para>
+ <programlisting>leaving node(composite)</programlisting>
+ </section>
+
+ <!-- ### PROCESS STRUCTURE ############################################## -->
+ <section>
+ <title>Process structure</title>
+ <para>Above we already touched briefly on the two main process constructs:
+ Nodes, transitions and node composition. This section will elaborate
+ on all the basic combination possibilities.
+ </para>
+ <figure id="process.structure">
+ <title>UML class diagram of the basic process structure</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.structure.classes.png"/></imageobject></mediaobject>
+ </figure>
+ <para>Next is a series of example diagram structures that can be formed
+ with the PVM process model.
+ </para>
+ <figure id="transition">
+ <title>Any two nodes can be connected with a transition.</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/transition.png"/></imageobject></mediaobject>
+ </figure>
+ <figure id="self.transition">
+ <title>A self transition.</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/self.transition.png"/></imageobject></mediaobject>
+ </figure>
+ <figure id="composite.node">
+ <title>Composite node is a list of nested nodes.</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/composite.node.png"/></imageobject></mediaobject>
+ </figure>
+ <figure id="transition.into.composite">
+ <title>Transition to a node inside a composite.</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/transition.into.composite.png"/></imageobject></mediaobject>
+ </figure>
+ <figure id="transition.out.of.composite">
+ <title>Transition from a node inside a composite to a node outside the composite.</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/transition.out.of.composite.png"/></imageobject></mediaobject>
+ </figure>
+ <figure id="transition.inheritence">
+ <title>Transition of composite nodes are inherited. The node inside can take the transition of the composite node.</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/transition.inheritence.png"/></imageobject></mediaobject>
+ </figure>
+ <figure id="transition.to.outer">
+ <title>Transition from a node to an outer composite.</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/transition.to.outer.png"/></imageobject></mediaobject>
+ </figure>
+ <figure id="transition.to.inner">
+ <title>Transition from a composite node to an inner composed node.</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/transition.to.inner.png"/></imageobject></mediaobject>
+ </figure>
+ <figure id="initial.in.composite">
+ <title>An initial node inside a composite node.</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/initial.in.composite.png"/></imageobject></mediaobject>
+ </figure>
+ </section>
+
+</chapter>
Deleted: jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/ch04-SoftwareLogging.xml
===================================================================
--- jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/ch04-SoftwareLogging.xml 2008-09-17 14:10:01 UTC (rev 2274)
+++ jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/ch04-SoftwareLogging.xml 2008-09-17 15:47:24 UTC (rev 2275)
@@ -1,99 +0,0 @@
-<chapter id="softwarelogging">
- <title>Software logging</title>
-
- <section>
- <title>Configuration</title>
- <para>PVM can use JDK logging (java.util.logging) or log4j. When the first message is
- logged, PVM logging will make the selection with following procedure:
- <orderedlist>
- <listitem>If a <literal>logging.properties</literal> resource is found
- on the classpath (using the context classloader), then JDK logging will
- be used and that file will be used to initialize the JDK logging.
- </listitem>
- <listitem>If log4j is found on the classpath, then log4j will be used.
- The check for log4j will be done by checking availability of class
- <literal>org.apache.log4j.LogManager</literal> with the context classloader.
- </listitem>
- <listitem>If none of the above, JDK logging will be used.</listitem>
- </orderedlist>
- </para>
- </section>
-
- <section>
- <title>Categories</title>
- <para>The PVM classes use their class name as the category for the logger.
- </para>
- <para>To have a basic understanding of what the PVM classes are doing,
- turning on the <literal>debug</literal> level is great. Level
- <literal>trace</literal> might be spitting out too much for that
- purpose.
- </para>
- </section>
-
- <section>
- <title>JDK logging</title>
- <para>In JDK logging, <literal>debug</literal>maps to <literal>fine</literal>
- and <literal>trace</literal> maps to <literal>finest</literal>.
- Level <literal>finer</literal> is not used.
- </para>
- <para><literal>org.jbpm.pvm.internal.log.LogFormatter</literal> is part of
- the pvm library and it can create a nice one-line output for log messages.
- It also has a neat feature that creates a unique indentation per thread.
- To configure it, this is a typical <literal>logging.properties</literal>
- </para>
- <programlisting>handlers = java.util.logging.ConsoleHandler
-java.util.logging.ConsoleHandler.level = FINEST
-java.util.logging.ConsoleHandler.formatter = org.jbpm.pvm.internal.log.LogFormatter
-
-# For example, set the com.xyz.foo logger to only log SEVERE messages:
-# com.xyz.foo.level = SEVERE
-
-.level = SEVERE
-org.jbpm.level=FINE
-org.jbpm.tx.level=FINE
-org.jbpm.pvm.internal.wire.level=FINE</programlisting>
-
-<!--
- <para>For production usage, jBPM also includes an error triggered log handler. This is
- a log handler that will only keep the most recent log messages in
- memory and these will only be flushed to a file in case an error occurs.
- </para>
- <para>to configure it, add <literal>org.jbpm.util.ErrorTriggeredFileHandler</literal>
- to the handlers in the logging properties like this:
- </para>
- <programlisting>handlers = java.util.logging.ConsoleHandler org.jbpm.util.ErrorTriggeredFileHandler</programlisting>
- <para>Next snippet shows how in the same logging.properties, the error
- triggered file handler can be configured. The given values are the default
- values.
- </para>
- <programlisting>org.jbpm.util.ErrorTriggeredFileHandler.size = 500
-org.jbpm.util.ErrorTriggeredFileHandler.push = SEVERE
-org.jbpm.util.ErrorTriggeredFileHandler.pattern = %h/jbpm%u.log</programlisting>
- <para>Alternatively to using the org.jbpm.util.ErrorTriggeredFileHandler, the
- JDK handlers FileHandler and MemoryHandler can used in combination to get
- similar results with a bit more configuration.
- </para>
-
--->
- </section>
-
- <section>
- <title>Debugging persistence</title>
- <para>When testing the persistence, following logging configurations can be
- valuable. Category <literal>org.hibernate.SQL</literal> shows the SQL statement that is executed
- and category <literal>org.hibernate.type</literal> shows the values of the parameters that are
- set in the queries.
- </para>
- <programlisting>org.hibernate.SQL.level=FINEST
-org.hibernate.type.level=FINEST</programlisting>
- <para>And in case you get a failed batch as a cause in a hibernate exception,
- you might want to set the batch size to 0 like this in the hibernate properties:
- </para>
- <programlisting>hibernate.jdbc.batch_size = 0</programlisting>
- <para>Also in the hibernate properties, the following properties allow for
- detailed logs of the SQL that hibernate spits out:</para>
- <programlisting>hibernate.show_sql = true
-hibernate.format_sql = true
-hibernate.use_sql_comments = true</programlisting>
- </section>
-</chapter>
\ No newline at end of file
Modified: jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/chxx-AdvancedGraphExecution.xml
===================================================================
--- jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/chxx-AdvancedGraphExecution.xml 2008-09-17 14:10:01 UTC (rev 2274)
+++ jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/chxx-AdvancedGraphExecution.xml 2008-09-17 15:47:24 UTC (rev 2275)
@@ -53,6 +53,33 @@
</para>
</section>
+ <!-- ### FUNCTIONAL ACTIVITIES ################################ -->
+ <section id="functionalactivities">
+ <title>Functional activities</title>
+ <para>Activities that also can be used as event listeners are called functional
+ activities. Examples of automatic activities are sending an email, doing a database
+ update, generating a pdf, calculating an average, etc. All of these are automatic
+ activities that do not change the execution flow. Here's how such activities can
+ be implemented:
+ </para>
+ <programlisting>public class FunctionalActivity implements Activity, EventListener {
+ public void execute(ActivityExecution execution) {
+ perform(execution);
+ }
+ public void notify(EventListenerExecution execution) {
+ perform(execution);
+ }
+ void perform(OpenExecution execution) {
+ ...do functional work...
+ }
+ }</programlisting>
+ <para>None of these methods actually invoke execution propagation methods.
+ So after the perform method is completed, the execution will
+ <link linkend="defaultproceedbehaviour">proceed in the default way</link>.
+ </para>
+ </section>
+
+
<!-- ### EXECUTION AND THREADS ########################################## -->
<section id="executionandthreads">
<title>Execution and threads</title>
Deleted: jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/chxx-BasicGraphExecution.xml
===================================================================
--- jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/chxx-BasicGraphExecution.xml 2008-09-17 14:10:01 UTC (rev 2274)
+++ jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/chxx-BasicGraphExecution.xml 2008-09-17 15:47:24 UTC (rev 2275)
@@ -1,553 +0,0 @@
-<chapter id="basicgraphexecution">
- <title>Basic graph execution</title>
-
- <!-- ### Activity ####################################################### -->
- <section id="activity">
- <title>Activity</title>
- <para>The PVM library doesn't have a fixed set of process constructs.
- Instead, runtime behaviour of a node is delegated to an <literal>Activity</literal>.
- In other words, <literal>Activity</literal> is an interface to implement the runtime
- behaviour of process constructs in plain Java. Also, <literal>Activity</literal>
- implementations can be subscrribed as listeners to
- <link linkend="events">process events</link>.
- </para>
- <programlisting>public <emphasis role="bold">interface Activity</emphasis> extends Serializable {
- void <emphasis role="bold">execute</emphasis>(Execution execution) throws Exception;
-}</programlisting>
- <para><literal>Activity</literal>'s can be used as node behaviour and as listeners to process
- events. When an activity is used as the node behaviour, it is in full control of the further
- propagation of the execution. In other words, a node behaviour can decide what the execution
- should do next. For example, it can take a transition
- with <literal>execution.take(Transition)</literal>, go into a wait state with
- <literal>execution.waitForSignal()</literal>. Or the node behaviour can not invoke
- any of the above, in that case the Process Virtual Machine will just
- <link linkend="defaultproceedbehaviour">proceed the execution in a default way</link>.
- </para>
- <para>Events are only fired during process execution. Since during an event the
- execution is already 'in motion', event listeners can not control the propagation
- of execution. Therefore, <literal>Activity</literal> implementations can only
- be used as event listeners if they don't invoke any of the execution propagation
- methods.
- </para>
- <para>This way, it is very easy to implement automatic activities that can be
- used as node behaviour as well as event listeners. Examples of automatic activities
- are sending an email, doing a database update, generating a pdf, calculating an average,
- etc. All of these can be executed by the process system and they can be used both as
- node behaviour as well as event listeners. In case they are used as node behaviour
- they can rely on the default proceed behaviour.
- </para>
- </section>
-
- <!-- ### Activity example ############################################### -->
- <section id="activityexample">
- <title>Activity example</title>
- <para>We'll start with a very original hello world example. A Display
- activity will print a message to the console:
- </para>
- <programlisting>public <emphasis role="bold">class Display</emphasis> implements <emphasis role="bold">Activity</emphasis> {
-
- String message;
-
- public Display(String message) {
- this.message = message;
- }
-
- public void execute(Execution execution) {
- <emphasis role="bold">System.out.println(message);</emphasis>
- }
-}</programlisting>
- <para>Let' build our first process definition with this activity:</para>
- <figure id="activity.example">
- <title>Activty example process</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/process.png"/></imageobject></mediaobject>
- </figure>
- <programlisting>ProcessDefinition processDefinition = ProcessFactory.build()
- .<emphasis role="bold">node("a").initial()</emphasis>.behaviour(<emphasis role="bold">new Display("hello")</emphasis>)
- .transition().to("b")
- .<emphasis role="bold">node("b")</emphasis>.behaviour(<emphasis role="bold">new Display("world")</emphasis>)
-.done();</programlisting>
- <para>Now we can execute this process as follows:</para>
- <programlisting>Execution execution = processDefinition.startExecution();</programlisting>
- <para>The invocation of <literal>startExecution</literal> will print hello world to the console:</para>
- <programlisting>hello
-world</programlisting>
- <para>One thing already worth noticing is that activities can be configured
- with properties. In the Display example, you can see that the message property
- is configured differently in the two usages. With configuration properties
- it becomes possible to write reusable activities. They can then be configured
- differently each time they are used in a process. That is an essential part of
- how process languages can be build on top of the Process Virtual Machine.
- </para>
- </section>
-
- <!-- ### ExternalActivity ############################################### -->
- <section id="externalactivity">
- <title>ExternalActivity</title>
- <para>External activities are activities for which the responsibility for proceeding
- the execution is transferred externally, meaning outside the process system. This
- means that for the system that is executing the process, it's a wait state. The
- execution will wait until an external trigger is given.
- </para>
- <para>For dealing with external triggers, <literal>ExternalActivity</literal>
- adds two methods to the <literal>Activity</literal>:</para>
- <programlisting>public <emphasis role="bold">interface ExternalActivity</emphasis> extends <emphasis role="bold">Activity</emphasis> {
-
- void <emphasis role="bold">signal</emphasis>(Execution execution,
- String signal,
- Map<String, Object> parameters) throws Exception;
-
-}</programlisting>
- <para>Just like with plain activities, when an execution arrives in a node, the
- <literal>execute</literal>-method of the node behaviour is invoked.
- In external activities, the execute method typically does something to
- transfer the responsibility to another system and then enters a wait
- state by invoking <literal>execution.waitForSignal()</literal>. For
- example in the execute method, responsibility could be transferred to a
- person by creating a task entry in a task management system and then
- wait until the person completes the task.
- </para>
- <para>In case a node behaves as a wait state, then the execution will
- wait in that node until the execution's <literal>signal</literal> method
- is invoked. The execution will delegate that signal to the behaviour Activity
- of the current node.
- </para>
- <para>So the Activity's <literal>signal</literal>-method is invoked
- when the execution receives an external trigger during the wait state. With the
- signal method, responsibility is transferred back to the process execution. For
- example, when a person completes a task, the task management system calls the
- signal method on the execution.
- </para>
- <para>A signal can optionally have a signal name and a map of parameters. Most
- common way on how node behaviours interprete the signal and parameters is that
- the signal relates to the outgoing transition that needs to be taken and that the
- parameters are set as variables on the execution. But those are just examples, it
- is up to the activity to use the signal and the parameters as it pleases.
- </para>
- </section>
-
- <!-- ### ExternalActivity example ####################################### -->
- <section id="externalactivityexample">
- <title>ExternalActivity example</title>
- <para>Here's a first example of a simple wait state implementation:
- </para>
- <programlisting>public <emphasis role="bold">class WaitState</emphasis> implements ExternalActivity {
-
- public void <emphasis role="bold">execute</emphasis>(Execution execution) {
- execution.waitForSignal();
- }
-
- public void <emphasis role="bold">signal</emphasis>(Execution execution,
- String signal,
- Map<String, Object> parameters) {
- execution.take(signal);
- }
-}</programlisting>
- <para>The <literal>execute</literal>-method calls
- <literal>execution.waitForSignal()</literal>. This call is
- necessary to prevent automatic propagation of the execution. By calling
- <literal>execution.waitForSignal()</literal>, the node will
- behave as a wait state.
- </para>
- <para><literal>signal</literal>-method takes the transition with
- the signal parameter as the transition name. So when an execution receives an
- external trigger, the signal name is interpreted as the name of an outgoing
- transition and the execution will be propagated over that transition.
- </para>
- <para>Here's the same simple process that has a transition from a to b. This
- time, the behaviour of the two nodes will be WaitState's.
- </para>
- <figure id="process.diagram">
- <title>Process diagram</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/process.png"/></imageobject></mediaobject>
- </figure>
- <programlisting>ProcessDefinition processDefinition = ProcessFactory.build()
- .<emphasis role="bold">node("a").initial()</emphasis>.behaviour(<emphasis role="bold">new WaitState()</emphasis>)
- .transition().to("b")
- .<emphasis role="bold">node("b")</emphasis>.behaviour(<emphasis role="bold">new WaitState()</emphasis>)
-.done();</programlisting>
-
-<programlisting>Execution execution = processDefinition.startExecution();</programlisting>
-<programlisting>execution.signal();</programlisting>
- </section>
-
- <!-- ### BASIC PROCESS EXECUTION ######################################## -->
- <section id="basicprocessexecution">
- <title>Basic process execution</title>
- <para>In this next example, we'll combine automatic activities and wait states.
- This example is a simplified version of a loan approval process. Graphically,
- it looks like this:
- </para>
- <figure id="the.first.graph.process">
- <title>The first graph process</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/first.graph.process.png"/></imageobject></mediaobject>
- </figure>
- <para>Building process graphs in Java code can be tedious because you have to keep track of all the
- references in local variables. To resolve that, the Process Virtual Machine comes with a
- ProcessFactory. The ProcessFactory is a kind of domain specific language (DSL) that is embedded
- in Java and eases the construction of process graphs. This pattern is also known as
- a <ulink url="http://martinfowler.com/bliki/FluentInterface.html">fluent
- interface</ulink>.
- </para>
- <programlisting>ProcessDefinition processDefinition = ProcessFactory.build()
- .<emphasis role="bold">node("accept loan request").initial()</emphasis>.behaviour(new WaitState())
- .transition().to("loan evaluation")
- .<emphasis role="bold">node("loan evaluation")</emphasis>.behaviour(new WaitState())
- .transition("approve").to("wire the money")
- .transition("reject").to("end")
- .<emphasis role="bold">node("wire the money")</emphasis>.behaviour(new Display("automatic payment"))
- .transition().to("end")
- .<emphasis role="bold">node("end")</emphasis>.behaviour(new WaitState())
-.done();</programlisting>
- <para>For more details about the ProcessFactory, see the javadocs. An alternative for
- the ProcessFactory would be to create an XML language and an XML parser for expressing
- processes. The XML parser can then instantiate the classes of package
- <literal>org.jbpm.pvm.internal.model</literal> directly. That approach is typically taken by
- process languages.
- </para>
- <para>The node <literal>wire the money</literal> is an automatic node. The
- <literal>Display</literal> implementation uses the Java API's to just print a
- message to the console. But the witty reader can imagine an alternative
- <literal>Activity</literal> implementation that uses the Java API of a payment
- processing library to make a real automatic payment. All the other nodes are
- wait states.
- </para>
- <para>A new execution for the process above can be started like this
- </para>
- <programlisting>Execution execution = processDefinition.startExecution();</programlisting>
- <para>Starting a new execution implies that the initial node is executed. Since in
- this case it's a wait state, the new execution will be positioned in the
- node 'accept loan request' when the <literal>startExecution</literal>-method returns.
- </para>
- <figure id="first.execution.state.accept">
- <title>Execution positioned in 'accept loan request'</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/execution.state.accept.png"/></imageobject></mediaobject>
- </figure>
- <para>Now we can give this execution an external trigger with the <literal>signal</literal>-
- method on the execution. Invoking the signal method will take the execution to the next
- wait state.
- </para>
- <programlisting>execution.signal();</programlisting>
- <figure id="execution.state.evaluation">
- <title>Execution positioned in 'loan evaluation'</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/execution.state.evaluation.png"/></imageobject></mediaobject>
- </figure>
- <para>Now, the execution is at an interesting point. There are two transitions out of
- the state 'loan evaluation'. One transition is called 'approve' and one transition
- is called 'reject'. As we explained above in the WaitState implementation, the transition
- taken corresponds to the signal that is given. Let's feed in the 'approve' signal like this:
- </para>
- <programlisting>execution.signal("approve");</programlisting>
- <para>The 'approve' signal will cause the execution to take the 'approve' transition and
- it will arrive in the node 'wire the money'.
- </para>
- <para>In <literal>wire the money</literal>, the message will be printed to the console.
- Since, the <literal>Display</literal> activity didn't invoke the
- <literal>execution.waitForSignal()</literal>, nor any of the other execution propagation
- methods, the default behaviour will be to just proceed.
- </para>
- <para><link linkend="defaultproceedbehaviour">Proceeding</link> in this case means that
- the default outgoing transition is taken and the execution will arrive in the <literal>end</literal>
- node, which is a wait state.</para>
- <para>So only when the <literal>end</literal> wait state is reached, the <literal>signal("approve")</literal>
- returns. That is because all of the things that needed to be done between the original
- state and this new state could be executed by the process system. Executing till the
- next wait state is the default behaviour and that behaviour can be changed with
- </para>
- <para><emphasis role="bold">TODO: add link to async continuations</emphasis></para>
- <para>asynchronous continuations in case
- transactions should not include all calculations till the next wait state. For
- more about this, see <xref linkend="executionandthreads" />.
- </para>
- <para>Another signal invocation will bring it eventually in the end state.</para>
- <figure id="execution.state.end">
- <title>Execution positioned in 'end'</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/execution.state.end.png"/></imageobject></mediaobject>
- </figure>
- </section>
-
- <!-- ### MOTIVATION ##################################################### -->
- <section id="motivation">
- <title>Motivation</title>
- <para>There are basically two forms of process languages: graph based and composite
- process languages. First of all, this design supports both. Even graph based execution
- and node composition can be used in combination to implement something like UML super states.
- </para>
- <para>In this design, control flow activity implementations will have to be
- aware of whether they are dependent on transitions (graph based) or whether they are
- using the composite node structure. The goal of this design is that all non-control
- flow activities can be implemented in the same way so that you can use them in graph
- based process languages as well as in composite process languages.
- </para>
- </section>
-
- <!-- ### EVENTS ######################################################### -->
- <section id="events">
- <title>Events</title>
- <para>Events are points in the process definition to which a list of
- activities can be subscribed as listeners. The motivation for events is to allow for
- developers to add programming logic to a process without changing the process diagram.
- This is a very valuable instrument in
- facilitating the collaboration between business analysts and developers. Business analysts
- are responsible for expressing the requirements. When they use a process graph to document
- those requirements, developers can take this diagram and make it executable. Events can
- be a very handy to insert technical details into a process (like e.g. some database insert)
- in which the business analyst is not interested.
- </para>
- <para>Most common events are fired by the execution automatically:
- </para>
- <itemizedlist>
- <listitem><literal>Transition.EVENT_TRANSITION_TAKE = "transition-take"</literal> :
- fired on transitions when transitions are taken.
- </listitem>
- <listitem><literal>Node.EVENT_NODE_ENTER = "node-enter"</literal> : fired on the node
- when execution enters that node. This happens when execution takes a transition
- to that node, when a child node is being executed with <literal>execution.execute(Node)</literal>
- or when a transition is taken from a node outside that node to a contained node.
- The latter refers to super states in state machines.
- </listitem>
- <listitem><literal>Node.EVENT_NODE_LEAVE = "node-leave"</literal> : fired on the node
- when a transition is taken out of that node or when a child node execution is
- finished and the execution is propagated to the parent node.
- </listitem>
- <listitem><literal>ProcessDefinition.EVENT_PROCESS_START = "process-start"</literal> : fired on a process
- when a new process is started.
- </listitem>
- <listitem><literal>ProcessDefinition.EVENT_PROCESS_END = "process-end"</literal> : fired on a process
- when a new process is ended. This might include a executions that are ended
- with a cancelled or error state.
- </listitem>
- </itemizedlist>
- <para>Events are identified by the combination of a process element
- and an event name. Users and process languages can also fire events
- programmatically with the fire method on the Execution:
- </para>
- <programlisting>public interface Execution extends Serializable {
- ...
- void fire(String eventName, ProcessElement eventSource);
- ...
-}</programlisting>
-
- <para>A list of <link linkend="activity"><literal>Activity</literal>s</link> can be associated to an
- event. But activities on events can not influence the control flow of the execution since
- they are merely listeners to an execution wich is already in progress. This is different from
- activities that serve as the behaviour for nodes. Node behaviour activities are responsible
- for propagating the execution. So if an activity in an event invokes any of the
- following methods, then it will result in an exception.
- </para>
-
- <itemizedlist>
- <listitem><literal>waitForSignal()</literal></listitem>
- <listitem><literal>take(Transition)</literal></listitem>
- <listitem><literal>end(*)</literal></listitem>
- <listitem><literal>execute(Node)</literal></listitem>
- </itemizedlist>
-
- <para>We'll reuse the <literal><link linkend="activity">Display</link></literal>
- activity from above in a simple process: two nodes connected by a
- transition. The Display listener will be subscribed to the transition event.</para>
- <figure id="action.process">
- <title>The process to which a listener activity will be associated</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/process.png"/></imageobject></mediaobject>
- </figure>
- <programlisting>ProcessDefinition processDefinition = ProcessFactory.build()
- .node("a").initial().behaviour(new WaitState())
- <emphasis role="bold">.event("node-leave")
- .listener(new Display("leaving a"))
- .listener(new Display("second message while leaving a"))</emphasis>
- .transition().to("b")
- <emphasis role="bold">.listener(new Display("taking transition"))</emphasis>
- .node("b").behaviour(new WaitState())
- <emphasis role="bold">.event("node-enter")
- .listener(new Display("entering b"))</emphasis>
-.done();</programlisting>
- <para>The first event shows how to register multiple listeners to the same
- event. They will be notified in the order as they are specified.
- </para>
- <para>Then, on the transition, there is only one type of event. So in that case,
- the event type must not be specified and the listeners can be added directly on
- the transition.
- </para>
- <para>A listeners will be called each time an execution fires the event to
- which the listener is subscribed. The execution will be provided in the activity
- interface as a parameter and can be used by listeners except for the methods that
- control the propagation of execution.
- </para>
- </section>
-
- <!-- ### EVENT PROPAGATION ############################################## -->
- <section>
- <title>Event propagation</title>
- <para>Events are by default propagated to enclosing process elements. The motivation
- is to allow for listeners on process definitions or composite nodes that get executed
- for all events that occur within that process element. For example this feature
- allows to register a listener on a process definition or a composite node on
- <literal>node-leave</literal> events. Such action will be executed if that node is
- left. And if that listener is registered on a composite node, it will also be executed
- for all nodes that are left within that composite node.
- </para>
- <para>To show this clearly, we'll create a <literal>DisplaySource</literal> activity
- that will print the message <literal>leaving</literal> and the source of the event
- to the console.
- </para>
- <programlisting>public class <emphasis role="bold">DisplaySource</emphasis> implements Activity {
-
- public void execute(Execution execution) {
- <emphasis role="bold">System.out.println("leaving "+execution.getEventSource());</emphasis>
- }
-}</programlisting>
- <para>Note that the purpose of event listeners is not to be visible, that's why the activity
- itself should not be displayed in the diagram. A <literal>DisplaySource</literal> activity
- will be added as a listener to the event <literal>node-leave</literal> on the composite node.
- </para>
- <para>The next process shows how the <literal>DisplaySource</literal> activity is registered
- as a listener to to the 'node-leave' event on the <literal>composite</literal> node:</para>
- <figure id="propagation.process">
- <title>A process with an invisible activity on a node-leave event on a composite node.</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/propagation.process.png"/></imageobject></mediaobject>
- </figure>
- <programlisting>ProcessDefinition processDefinition = ProcessFactory.build("propagate")
- .compositeNode("composite")
- <emphasis role="bold">.event(Node.EVENT_NODE_LEAVE)
- .listener(new DisplaySource())</emphasis>
- .node("a").initial().behaviour(new WaitState())
- .transition().to("b")
- .node("b").behaviour(new WaitState())
- .transition().to("c")
- .compositeEnd()
- .node("c").behaviour(new WaitState())
-.done();</programlisting>
- <para>Next we'll start an execution.</para>
- <programlisting>Execution execution = processDefinition.startExecution();</programlisting>
- <para>After starting a new execution, the execution will be in node <literal>a</literal> as
- that is the initial node. No nodes have been left so no message is logged. Next a signal
- will be given to the execution, causing it to take the transition from <literal>a</literal>
- to <literal>b</literal>.
- </para>
- <programlisting>execution.signal();</programlisting>
- <para>When the signal method returns, the execution will have taken the transition and
- the node-leave event will be fired on node a. That event will be propagated to the
- composite node and to the process definition. Since our propagation logger is placed
- on node composite it will receive the event and print the following message:
- </para>
- <programlisting>leaving node(a)</programlisting>
- <para>Another</para>
- <programlisting>execution.signal();</programlisting>
- <para>will take the transition from b to c. That will fire two node-leave events. One on
- node b and one on node composite. So the following lines will be appended to the console
- output:</para>
- <programlisting>leaving node(b)
-leaving node(composite)</programlisting>
- <para>Event propagation is build on the hierarchical composition structure of the process
- definition. The top level element is always the process definition. The process
- definition contains a list of nodes. Each node can be a leaf node or it can be a
- composite node, which means that it contains a list of nested nodes. Nested nodes
- can be used for e.g. super states or composite activities in nested process languages like BPEL.
- </para>
- <para>So the even model also works similarly for composite nodes as it did for the process
- definition above. Suppose that 'Phase one' models
- a super state as in state machines. Then event propagation allows to subscribe to all events
- within that super state. The idea is that the hierarchical composition corresponds to
- diagram representation. If an element 'e' is drawn inside another element 'p', then p
- is the parent of e. A process definition has a set of top level nodes. Every node can have
- a set of nested nodes. The parent of a transition is considered as the first common
- parent for it's source and destination.
- </para>
- <para>If an event listener is not interested in propagated events, propagation can be disabled
- with <literal>propagationDisabled()</literal>. The next process is the same process
- as above except that propagated events will be disabled on the event listener. The graph diagram
- remains the same.
- </para>
- <figure id="propagation.disabled.process">
- <title>A process with a listener to 'node-leave' events with propagation disabled.</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/propagation.process.png"/></imageobject></mediaobject>
- </figure>
- <para>Building the process with the process factory:
- </para>
- <programlisting>ProcessDefinition processDefinition = ProcessFactory.build("propagate")
- .compositeNode("composite")
- <emphasis role="bold">.event(Node.EVENT_NODE_LEAVE)
- .listener(new DisplaySource())
- .propagationDisabled()</emphasis>
- .node("a").initial().behaviour(new WaitState())
- .transition().to("b")
- .node("b").behaviour(new WaitState())
- .transition().to("c")
- .nodesEnd()
- .node("c").behaviour(new WaitState())
-.done();</programlisting>
- <para>So when the first signal is given for this process, again the node-leave event will be
- fired on node a, but now the listener on the composite node will not be executed cause
- propagated events have been disabled. Disabling propagation is a property on the listener
- and doesn't influence the other listeners. The event will always be fired and propagated
- over the whole parent hierarchy.
- </para>
- <programlisting>Execution execution = processDefinition.startExecution();
-execution.signal();
-</programlisting>
- <para>Next, the second signal will take the transition from b to c.
- </para>
- <programlisting>execution.signal()</programlisting>
- <para>Again two node-leave
- events are fired just like above on nodes b and composite respectively. The first event
- is the node-leave event on node b. That will be propagated to the composite node. So the
- listener will not be executed for this event cause it has propagation disabled. But the
- listener will be executed for the node-leave event on the composite node. That is not
- propagated, but fired directly on the composite node. So the listener will now be executed
- only once for the composite node as shown in the following console output:
- </para>
- <programlisting>leaving node(composite)</programlisting>
- </section>
-
- <!-- ### PROCESS STRUCTURE ############################################## -->
- <section>
- <title>Process structure</title>
- <para>Above we already touched briefly on the two main process constructs:
- Nodes, transitions and node composition. This section will elaborate
- on all the basic combination possibilities.
- </para>
- <figure id="process.structure">
- <title>UML class diagram of the basic process structure</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/process.structure.classes.png"/></imageobject></mediaobject>
- </figure>
- <para>Next is a series of example diagram structures that can be formed
- with the PVM process model.
- </para>
- <figure id="transition">
- <title>Any two nodes can be connected with a transition.</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/transition.png"/></imageobject></mediaobject>
- </figure>
- <figure id="self.transition">
- <title>A self transition.</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/self.transition.png"/></imageobject></mediaobject>
- </figure>
- <figure id="composite.node">
- <title>Composite node is a list of nested nodes.</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/composite.node.png"/></imageobject></mediaobject>
- </figure>
- <figure id="transition.into.composite">
- <title>Transition to a node inside a composite.</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/transition.into.composite.png"/></imageobject></mediaobject>
- </figure>
- <figure id="transition.out.of.composite">
- <title>Transition from a node inside a composite to a node outside the composite.</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/transition.out.of.composite.png"/></imageobject></mediaobject>
- </figure>
- <figure id="transition.inheritence">
- <title>Transition of composite nodes are inherited. The node inside can take the transition of the composite node.</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/transition.inheritence.png"/></imageobject></mediaobject>
- </figure>
- <figure id="transition.to.outer">
- <title>Transition from a node to an outer composite.</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/transition.to.outer.png"/></imageobject></mediaobject>
- </figure>
- <figure id="transition.to.inner">
- <title>Transition from a composite node to an inner composed node.</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/transition.to.inner.png"/></imageobject></mediaobject>
- </figure>
- <figure id="initial.in.composite">
- <title>An initial node inside a composite node.</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/initial.in.composite.png"/></imageobject></mediaobject>
- </figure>
- </section>
-
-</chapter>
Deleted: jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/chxx-Services.xml
===================================================================
--- jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/chxx-Services.xml 2008-09-17 14:10:01 UTC (rev 2274)
+++ jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/chxx-Services.xml 2008-09-17 15:47:24 UTC (rev 2275)
@@ -1,82 +0,0 @@
-<chapter id="services">
- <title>Services</title>
-
- <para>Services can be fetched from the EnvironmentFactory, which in it's turn
- can be created from a configuration file.
- </para>
-
- <programlisting>EnvironmentFactory environmentFactory = new PvmEnvironmentFactory("pvm.cfg.xml");
-ProcessService processService = environmentFactory.get(ProcessService.class);</programlisting>
-
- <para>Services are thread safe so only 1 single service object should be maintained
- by the application and it can serve all requests for the application.
- </para>
-
-
-
- <section id="architecture">
- <title>Architecture</title>
- <para>Service methods are implemented through command classes.
- Each method creates a command object and the command is executed with
- the <literal>execute</literal> method of the <literal>CommandService</literal>.
- The <literal>CommandService</literal> is responsible for setting up the
- environment.
- </para>
- <para>There are four command services:
- </para>
- <itemizedlist>
- <listitem><literal>command-service</literal> will just
- execute the command and pass in the current environment.</listitem>
- <listitem>(UNTESTED) <literal>async-command-service</literal> will send an
- asynchronous message. So right after that in a separate transaction,
- the message is consumed and the command is executed.</listitem>
- <listitem>(TODO) <literal>cmt-command-service</literal> will delegate
- execution of the command to a local SLSB that has transaction attribute
- <literal>required</literal>.</listitem>
- <listitem>(TODO) <literal>remote-command-service</literal> will delegate
- execution of the command to a remote SLSB.</listitem>
- </itemizedlist>
- <para>Each of the command services can be configured with a list of
- interceptors that span around the command execution. Following
- interceptors are available:</para>
- <itemizedlist>
- <listitem><literal>environment-interceptor</literal>: Will execute the
- command within an <link linkend="environmentblock">environment block</link>.
- </listitem>
- <listitem>(UNTESTED) <literal>authorization-interceptor</literal>: Will perform
- an authrorization check before the command is executed. The
- authorization interceptor will look up the AuthorizationSession
- from the environment to delegate the actual authorization check to.
- </listitem>
- <listitem><literal>retry-interceptor</literal>: Will catch hibernate's
- optmistic locking exceptions (StaleStateException) and retries
- to execute the command for a configurable number of times
- </listitem>
- <listitem><literal>transaction-interceptor</literal>: Will get
- the transaction from the current context and invoke
- setRollbackOnly() on it in case an exception comes out of
- the command execution.
- </listitem>
- </itemizedlist>
- <para>Following configuration can be used in default standard persistence
- situations:
- </para>
- <programlisting><contexts>
- <environment-factory>
-
- <pvm-service />
-
- <command-service>
- <retry-interceptor />
- <environment-interceptor />
- <transaction-interceptor />
- </command-service>
-
- ...
- </environment-factory>
- ...
-
-</contexts></programlisting>
- </section>
-
-</chapter>
\ No newline at end of file
Copied: jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/chxx-SoftwareLogging.xml (from rev 2248, jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/ch04-SoftwareLogging.xml)
===================================================================
--- jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/chxx-SoftwareLogging.xml (rev 0)
+++ jbpm4/pvm/trunk/modules/manual/src/main/docbook/en/modules/chxx-SoftwareLogging.xml 2008-09-17 15:47:24 UTC (rev 2275)
@@ -0,0 +1,99 @@
+<chapter id="softwarelogging">
+ <title>Software logging</title>
+
+ <section>
+ <title>Configuration</title>
+ <para>PVM can use JDK logging (java.util.logging) or log4j. When the first message is
+ logged, PVM logging will make the selection with following procedure:
+ <orderedlist>
+ <listitem>If a <literal>logging.properties</literal> resource is found
+ on the classpath (using the context classloader), then JDK logging will
+ be used and that file will be used to initialize the JDK logging.
+ </listitem>
+ <listitem>If log4j is found on the classpath, then log4j will be used.
+ The check for log4j will be done by checking availability of class
+ <literal>org.apache.log4j.LogManager</literal> with the context classloader.
+ </listitem>
+ <listitem>If none of the above, JDK logging will be used.</listitem>
+ </orderedlist>
+ </para>
+ </section>
+
+ <section>
+ <title>Categories</title>
+ <para>The PVM classes use their class name as the category for the logger.
+ </para>
+ <para>To have a basic understanding of what the PVM classes are doing,
+ turning on the <literal>debug</literal> level is great. Level
+ <literal>trace</literal> might be spitting out too much for that
+ purpose.
+ </para>
+ </section>
+
+ <section>
+ <title>JDK logging</title>
+ <para>In JDK logging, <literal>debug</literal>maps to <literal>fine</literal>
+ and <literal>trace</literal> maps to <literal>finest</literal>.
+ Level <literal>finer</literal> is not used.
+ </para>
+ <para><literal>org.jbpm.pvm.internal.log.LogFormatter</literal> is part of
+ the pvm library and it can create a nice one-line output for log messages.
+ It also has a neat feature that creates a unique indentation per thread.
+ To configure it, this is a typical <literal>logging.properties</literal>
+ </para>
+ <programlisting>handlers = java.util.logging.ConsoleHandler
+java.util.logging.ConsoleHandler.level = FINEST
+java.util.logging.ConsoleHandler.formatter = org.jbpm.pvm.internal.log.LogFormatter
+
+# For example, set the com.xyz.foo logger to only log SEVERE messages:
+# com.xyz.foo.level = SEVERE
+
+.level = SEVERE
+org.jbpm.level=FINE
+org.jbpm.tx.level=FINE
+org.jbpm.pvm.internal.wire.level=FINE</programlisting>
+
+<!--
+ <para>For production usage, jBPM also includes an error triggered log handler. This is
+ a log handler that will only keep the most recent log messages in
+ memory and these will only be flushed to a file in case an error occurs.
+ </para>
+ <para>to configure it, add <literal>org.jbpm.util.ErrorTriggeredFileHandler</literal>
+ to the handlers in the logging properties like this:
+ </para>
+ <programlisting>handlers = java.util.logging.ConsoleHandler org.jbpm.util.ErrorTriggeredFileHandler</programlisting>
+ <para>Next snippet shows how in the same logging.properties, the error
+ triggered file handler can be configured. The given values are the default
+ values.
+ </para>
+ <programlisting>org.jbpm.util.ErrorTriggeredFileHandler.size = 500
+org.jbpm.util.ErrorTriggeredFileHandler.push = SEVERE
+org.jbpm.util.ErrorTriggeredFileHandler.pattern = %h/jbpm%u.log</programlisting>
+ <para>Alternatively to using the org.jbpm.util.ErrorTriggeredFileHandler, the
+ JDK handlers FileHandler and MemoryHandler can used in combination to get
+ similar results with a bit more configuration.
+ </para>
+
+-->
+ </section>
+
+ <section>
+ <title>Debugging persistence</title>
+ <para>When testing the persistence, following logging configurations can be
+ valuable. Category <literal>org.hibernate.SQL</literal> shows the SQL statement that is executed
+ and category <literal>org.hibernate.type</literal> shows the values of the parameters that are
+ set in the queries.
+ </para>
+ <programlisting>org.hibernate.SQL.level=FINEST
+org.hibernate.type.level=FINEST</programlisting>
+ <para>And in case you get a failed batch as a cause in a hibernate exception,
+ you might want to set the batch size to 0 like this in the hibernate properties:
+ </para>
+ <programlisting>hibernate.jdbc.batch_size = 0</programlisting>
+ <para>Also in the hibernate properties, the following properties allow for
+ detailed logs of the SQL that hibernate spits out:</para>
+ <programlisting>hibernate.show_sql = true
+hibernate.format_sql = true
+hibernate.use_sql_comments = true</programlisting>
+ </section>
+</chapter>
\ No newline at end of file
More information about the jbpm-commits
mailing list