[jbpm-commits] JBoss JBPM SVN: r4983 - in jbpm4/trunk/modules: examples/src/test/java/org/jbpm/examples/custom and 3 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Jun 3 11:49:54 EDT 2009
Author: tom.baeyens at jboss.com
Date: 2009-06-03 11:49:54 -0400 (Wed, 03 Jun 2009)
New Revision: 4983
Added:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/custom/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/custom/CustomTest.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/custom/PrintDots.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/custom/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/custom/process.jpdl.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/custom/process.png
Modified:
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml
Log:
JBPM-2216 add custom activity
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/custom/CustomTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/custom/CustomTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/custom/CustomTest.java 2009-06-03 15:49:54 UTC (rev 4983)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.custom;
+
+import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class CustomTest extends JbpmTestCase {
+
+ long deploymentDbid;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ deploymentDbid = repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/examples/custom/process.jpdl.xml")
+ .deploy();
+ }
+
+ protected void tearDown() throws Exception {
+ repositoryService.deleteDeploymentCascade(deploymentDbid);
+
+ super.tearDown();
+ }
+
+ public void testWaitStatesSequence() {
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("Custom");
+ Execution executionInPrintDots = processInstance.findActiveExecutionIn("print dots");
+ assertNotNull(executionInPrintDots);
+ String executionId = executionInPrintDots.getId();
+ executionService.signalExecutionById(executionId);
+ }
+}
Property changes on: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/custom/CustomTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/custom/PrintDots.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/custom/PrintDots.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/custom/PrintDots.java 2009-06-03 15:49:54 UTC (rev 4983)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.custom;
+
+import java.util.Map;
+
+import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.api.activity.ExternalActivityBehaviour;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class PrintDots implements ExternalActivityBehaviour {
+
+ private static final long serialVersionUID = 1L;
+ private static final String NEWLINE = System.getProperty("line.separator");
+
+ public void execute(ActivityExecution execution) {
+ String executionId = execution.getId();
+
+ String dots =
+ " "+".::::. " + NEWLINE +
+ " " +" " +" .:::::" +":::. " +
+ NEWLINE + " ::::::::::: " + NEWLINE +
+ " " + " ':::::::::::.. "
+ + NEWLINE +" ::::" +":::::::::::' " + NEWLINE +" ':::::::::::. " + NEWLINE +
+ " .::::::::" +"::::::' " + NEWLINE +" " +".:::::::::::... " + NEWLINE +
+ " ::::::::::::::''" +
+ " " + NEWLINE +" .:::. '::::::::'':::: " + NEWLINE +
+ " .::::::::. " +
+ " ':::::' ':::: " + NEWLINE +" "
+ +".::::':::::::. " +" ::::: '::::. " + NEWLINE +" .:::::' '::::"
+ +":::::. ::::: ':::. " + NEWLINE +" .:::::' ':::::::::.::::: " +" '::. " +
+ NEWLINE +" .::::'' ':::::::::::::: '::. " + NEWLINE +" .::'' ':::::"
+ +"::::::: :::... " + NEWLINE +" ..:::: ':::::::::' " +
+ " .:' '''' " + NEWLINE +" ..''''':' ':::::.' " + NEWLINE;
+
+ System.out.println(dots);
+
+ execution.waitForSignal();
+ }
+
+ public void signal(ActivityExecution execution,
+ String signalName,
+ Map<String, ?> parameters) {
+ execution.take(signalName);
+ }
+}
Property changes on: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/custom/PrintDots.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/custom/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/custom/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/custom/process.jpdl.xml 2009-06-03 15:49:54 UTC (rev 4983)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="Custom" xmlns="http://jbpm.org/4.0/jpdl">
+
+ <start g="20,20,48,48">
+ <transition to="print dots" />
+ </start>
+
+ <custom name="print dots"
+ class="org.jbpm.examples.custom.PrintDots"
+ g="96,16,127,52">
+
+ <transition to="end" />
+ </custom>
+
+ <end name="end" g="205,22,80,40"/>
+
+</process>
Property changes on: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/custom/process.jpdl.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/custom/process.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/custom/process.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml 2009-06-03 14:32:39 UTC (rev 4982)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml 2009-06-03 15:49:54 UTC (rev 4983)
@@ -1675,7 +1675,63 @@
<para>The example test case also shows the other scenarios.
</para>
</section>
+ </section>
+
+ <!-- ### CUSTOM ####################################################### -->
+ <section id="custom">
+ <title><literal>custom</literal></title>
+
+ <para>Invokes user code that implements custom behaviour of an activity.
+ </para>
+
+ <para>A custom activity refers to user code. See <xref linkend="usercode" />
+ for more details on the specific attributes and elements. Let's look at
+ the example:
+ </para>
+
+ <programlisting><process name="Custom" xmlns="http://jbpm.org/4.0/jpdl">
+
+ <start >
+ <transition to="print dots" />
+ </start>
+
+ <custom name="print dots"
+ class="org.jbpm.examples.custom.PrintDots">
+
+ <transition to="end" />
+ </custom>
+
+ <end name="end" />
+
+</process></programlisting>
+ <para>The custom activity behaviour class <literal>PrintDots</literal>
+ shows that it's possible to control the flow when implementing
+ custom activity behaviours. In this case the <literal>PrintDots</literal>
+ acitivity implementation will after printing dots wait in the activity until
+ a signal is given.
+ </para>
+ <programlisting>public class PrintDots implements ExternalActivityBehaviour {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ActivityExecution execution) {
+ String executionId = execution.getId();
+
+ String dots = ...;
+
+ System.out.println(dots);
+
+ execution.waitForSignal();
+ }
+
+ public void signal(ActivityExecution execution,
+ String signalName,
+ Map<String, ?> parameters) {
+ execution.take(signalName);
+ }
+}</programlisting>
+
</section>
</section>
@@ -2961,93 +3017,87 @@
<xref linkend="taskassignmenthandler" />. This section describes the
attributes and sub elements of those type of user code objects.
</para>
- <table><title>attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>class</literal></entry>
- <entry>classname</entry>
- <entry></entry>
- <entry><emphasis role="bold">required</emphasis></entry>
- <entry>The fully qualified classname.</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table><title>sub elements:</title>
- <tgroup cols="3" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Element</entry>
- <entry>Multiplicity</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>field</literal></entry>
- <entry>0..*</entry>
- <entry>describes a configuration value to be injected directly in
- a memberfield before this user class is used.</entry>
- </row>
- <row>
- <entry><literal>property</literal></entry>
- <entry>0..*</entry>
- <entry>describes a configuration value to injected through a setter
- method before this user object is used.</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table><title><literal>field</literal> attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>name</literal></entry>
- <entry>string</entry>
- <entry></entry>
- <entry><emphasis role="bold">required</emphasis></entry>
- <entry>the name of the field</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table><title><literal>field</literal> sub elements:</title>
- <tgroup cols="3" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Element</entry>
- <entry>Multiplicity</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>string</literal></entry>
- <entry>0..1</entry>
- <entry>represents a string value</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
+ <table><title>attributes:</title>
+ <tgroup cols="5" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Attribute</entry>
+ <entry>Type</entry>
+ <entry>Default</entry>
+ <entry>Required?</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>class</literal></entry>
+ <entry>classname</entry>
+ <entry></entry>
+ <entry>one of {class|expr} is required</entry>
+ <entry>The fully qualified classname.</entry>
+ </row>
+ <row>
+ <entry><literal>expr</literal></entry>
+ <entry>expression</entry>
+ <entry></entry>
+ <entry>one of {class|expr} is required</entry>
+ <entry>The fully qualified classname.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table><title>sub elements:</title>
+ <tgroup cols="3" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Element</entry>
+ <entry>Multiplicity</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>field</literal></entry>
+ <entry>0..*</entry>
+ <entry>describes a configuration value to be injected directly in
+ a memberfield before this user class is used.</entry>
+ </row>
+ <row>
+ <entry><literal>property</literal></entry>
+ <entry>0..*</entry>
+ <entry>describes a configuration value to injected through a setter
+ method before this user object is used.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table><title><literal>field</literal> attributes:</title>
+ <tgroup cols="5" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Attribute</entry>
+ <entry>Type</entry>
+ <entry>Default</entry>
+ <entry>Required?</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>name</literal></entry>
+ <entry>string</entry>
+ <entry></entry>
+ <entry><emphasis role="bold">required</emphasis></entry>
+ <entry>the name of the field</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>Inside <literal>field</literal> or <literal>property</literal> injections,
+ a lot of different value types can be specified, like <literal>string</literal>,
+ <literal>object</literal>, <literal>map</literal>, <literal>list</literal>
+ <literal>ref</literal> and so on. See jpdl schema docs for more options
+ </para>
</section>
</chapter>
More information about the jbpm-commits
mailing list