[jbpm-commits] JBoss JBPM SVN: r6028 - in jbpm4/trunk/modules/devguide/src/main/docbook/en: modules and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Dec 22 22:53:55 EST 2009


Author: koen.aers at jboss.com
Date: 2009-12-22 22:53:55 -0500 (Tue, 22 Dec 2009)
New Revision: 6028

Added:
   jbpm4/trunk/modules/devguide/src/main/docbook/en/images/process.java.ejb.png
Modified:
   jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml
Log:
add ejb invocation documentation

Added: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/process.java.ejb.png
===================================================================
(Binary files differ)


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

Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml	2009-12-22 22:06:05 UTC (rev 6027)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml	2009-12-23 03:53:55 UTC (rev 6028)
@@ -631,6 +631,81 @@
     </para>
   </section>
 
+  <!-- ### JAVA ####################################################### -->
+  <section id="java">
+    <title><literal>java</literal> activity</title>
+    <para>
+      The purpose of the <literal>java</literal> activity in general is to invoke
+      a Java method as explained in the User Guide. This section in the Developer 
+      Guide is specifically about how to use the <literal>java</literal> activity
+      to invoke a method of an ejb session bean. 
+    </para>
+    <para>
+      Exactly for this purpose it is possible to use the <literal>ejb-jndi-name</literal>
+      attribute. As its name indicates the attribute specifies the jndi name of the 
+      ejb of which the method needs to be invoked. Consider the following ejb:
+    </para>
+    <programlisting>package org.jbpm.test.enterprise.stateless.bean;
+
+import javax.ejb.Stateless;
+
+ at Stateless
+public class CalculatorBean implements CalculatorRemote, CalculatorLocal
+{
+   public Integer add(Integer x, Integer y)
+   {
+      return x + y;
+   }
+
+   public Integer subtract(Integer x, Integer y)
+   {
+      return x - y;
+   }
+}</programlisting>
+    <para>and the following process definition:</para>
+    <figure id="process.java.ejb">
+      <title>The ejb method invocation example process</title>
+      <mediaobject><imageobject><imagedata align="center" fileref="images/process.java.ejb.png"/></imageobject></mediaobject>
+    </figure>
+    <programlisting>&lt;process name=&quot;EJB&quot;&gt;
+
+  &lt;start&gt;
+    &lt;transition to=&quot;calculate&quot; /&gt;
+  &lt;/start&gt;
+
+  <emphasis role="bold">&lt;java name=&quot;calculate&quot; 
+        ejb-jndi-name=&quot;CalculatorBean/local&quot;
+        method=&quot;add&quot;
+        var=&quot;answer&quot;&gt;
+        
+    &lt;arg&gt;&lt;int value=&quot;25&quot;/&gt;&lt;/arg&gt;
+    &lt;arg&gt;&lt;int value=&quot;38&quot;/&gt;&lt;/arg&gt;
+    
+    &lt;transition to=&quot;wait&quot; /&gt;
+  &lt;/java&gt;</emphasis>
+  
+  &lt;state name=&quot;wait&quot; /&gt;
+
+&lt;/process&gt;</programlisting>
+
+    <para>
+      As you can expect, the execution of this node will invoke the <literal>add</literal> method of the ejb
+      that is known under the jndi name <literal>CalculatorBean/local</literal>. The result will be stored in 
+      the variable <literal>answer</literal>. This is illustrated in the following test snippet.
+    </para>
+    
+    <programlisting>public void testEjbInvocation() throws Exception {
+  String executionId = executionService
+      .startProcessInstanceByKey(&quot;EJB&quot;)
+      .getProcessInstance()
+      .getId();
+  assertEquals(63, executionService.getVariable(executionId, &quot;answer&quot;));
+}</programlisting>
+
+
+ 
+  </section>
+
   <!-- ### RULES DECISION ####################################################### -->
   <section id="rulesdecision">
     <title><literal>rules-decision</literal> activity</title>



More information about the jbpm-commits mailing list