JBoss JBPM SVN: r4534 - in jbpm4/trunk/modules: examples/src/test/java/org/jbpm/examples/eventlistener and 5 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-04-10 05:57:59 -0400 (Fri, 10 Apr 2009)
New Revision: 4534
Added:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/eventlistener/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/eventlistener/EventListenerTest.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/eventlistener/LogListener.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/eventlistener/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/eventlistener/process.jpdl.xml
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.eventlistener.png
Modified:
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml
Log:
JBPM-2027 adding example and docs for event listeners
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/eventlistener/EventListenerTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/eventlistener/EventListenerTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/eventlistener/EventListenerTest.java 2009-04-10 09:57:59 UTC (rev 4534)
@@ -0,0 +1,29 @@
+package org.jbpm.examples.eventlistener;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.Execution;
+import org.jbpm.test.JbpmTestCase;
+
+
+public class EventListenerTest extends JbpmTestCase {
+
+ public void testEventListener() {
+ deployJpdlResource("org/jbpm/examples/eventlistener/process.jpdl.xml");
+
+ LogListener.logs = new ArrayList<String>();
+
+ Execution execution = executionService.startProcessInstanceByKey("EventListener");
+ executionService.signalExecutionById(execution.getId());
+
+ List<String> expectedLogs = new ArrayList<String>();
+ expectedLogs.add("event(start) on process(EventListener)");
+ expectedLogs.add("event(start) on activity(wait)");
+ expectedLogs.add("event(end) on activity(wait)");
+ expectedLogs.add("event(take) on (wait)-->(end)");
+ expectedLogs.add("event(end) on process(EventListener)");
+
+ assertEquals(expectedLogs, LogListener.logs);
+ }
+}
Property changes on: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/eventlistener/EventListenerTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/eventlistener/LogListener.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/eventlistener/LogListener.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/eventlistener/LogListener.java 2009-04-10 09:57:59 UTC (rev 4534)
@@ -0,0 +1,18 @@
+package org.jbpm.examples.eventlistener;
+
+import java.util.List;
+
+import org.jbpm.listener.EventListener;
+import org.jbpm.listener.EventListenerExecution;
+
+
+public class LogListener implements EventListener {
+
+ private static final long serialVersionUID = 1L;
+
+ public static List<String> logs; // initialization done in test method
+
+ public void notify(EventListenerExecution execution) {
+ logs.add(execution.getEvent()+" on "+execution.getEventSource());
+ }
+}
Property changes on: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/eventlistener/LogListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/eventlistener/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/eventlistener/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/eventlistener/process.jpdl.xml 2009-04-10 09:57:59 UTC (rev 4534)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="EventListener" xmlns="http://jbpm.org/4/jpdl">
+
+ <on event="start">
+ <event-listener class="org.jbpm.examples.eventlistener.LogListener"/>
+ </on>
+
+ <on event="end">
+ <event-listener class="org.jbpm.examples.eventlistener.LogListener"/>
+ </on>
+
+
+ <start g="17,19,48,48">
+ <transition to="wait"/>
+ </start>
+
+ <state g="96,16,104,52" name="wait">
+ <on event="start">
+ <event-listener class="org.jbpm.examples.eventlistener.LogListener"/>
+ </on>
+ <on event="end">
+ <event-listener class="org.jbpm.examples.eventlistener.LogListener"/>
+ </on>
+
+ <transition to="end">
+ <event-listener class="org.jbpm.examples.eventlistener.LogListener"/>
+ </transition>
+
+ </state>
+
+ <end g="231,19,80,52" name="end"/>
+
+</process>
Property changes on: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/eventlistener/process.jpdl.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java 2009-04-10 00:07:30 UTC (rev 4533)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/JbpmTestCase.java 2009-04-10 09:57:59 UTC (rev 4534)
@@ -124,57 +124,49 @@
super.tearDown();
}
- protected void deploy(String archive)
- {
- if(isIntegrationTest())
+ @Deprecated
+ protected void deploy(String archive) {
+ if (isIntegrationTest())
remoteDeploy(archive);
else
localDeploy(archive);
}
- private void remoteDeploy(String archive)
- {
- try
- {
+ @Deprecated
+ private void remoteDeploy(String archive) {
+ try {
getTestHelper().deploy(archive);
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
throw new RuntimeException("Failed to deploy " + archive, e);
}
}
- protected void undeploy(String archive)
- {
- if(isIntegrationTest())
+ @Deprecated
+ protected void undeploy(String archive) {
+ if (isIntegrationTest())
remoteUndeploy(archive);
// TODO: localUndeploy() happens in tearDown()
}
- private void localUndeploy(String archive)
- {
+ @Deprecated
+ private void localUndeploy(String archive) {
// TODO: Match archive with dbId, but for now undeploy any
- for (Long deploymentDbid : registeredDeployments)
- {
+ for (Long deploymentDbid : registeredDeployments) {
repositoryService.deleteDeploymentCascade(deploymentDbid);
}
}
- private void remoteUndeploy(String archive)
- {
- try
- {
+ @Deprecated
+ private void remoteUndeploy(String archive) {
+ try {
getTestHelper().undeploy(archive);
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
throw new RuntimeException("Failed to undeploy " + archive, e);
}
}
- protected IntegrationTestHelper getTestHelper()
- {
+ protected IntegrationTestHelper getTestHelper() {
if(!isIntegrationTest())
throw new IllegalArgumentException("'jboss.bind.address' system property is missing");
@@ -184,12 +176,11 @@
return testHelper;
}
- public static boolean isIntegrationTest()
- {
+ @Deprecated
+ public static boolean isIntegrationTest() {
return System.getProperty("jboss.bind.address")!=null;
}
- @Deprecated
public long deployJpdlXmlString(String jpdlXmlString) {
long deploymentDbid =
repositoryService.createDeployment()
@@ -201,7 +192,6 @@
return deploymentDbid;
}
- /*@Deprecated
public void deployJpdlResource(String resource) {
long deploymentDbid =
repositoryService.createDeployment()
@@ -209,8 +199,9 @@
.deploy();
registerDeployment(deploymentDbid);
- }*/
+ }
+ @Deprecated
public void localDeploy(String archive) {
URL archiveUrl = IntegrationTestHelper.getTestArchiveURL(archive);
Added: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.eventlistener.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.eventlistener.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml 2009-04-10 00:07:30 UTC (rev 4533)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml 2009-04-10 09:57:59 UTC (rev 4534)
@@ -108,11 +108,12 @@
</table>
</section>
- <section id="activities">
- <title>Activities</title>
- <para>(BPMN note: when we mention activities here, we are not only refering to BPMN
- activities, but also to BPMN events and BPMN gateways.)
- </para>
+ <!-- ##################################################################### -->
+ <!-- ### CONTROL FLOW ACTIVITIES ### -->
+ <!-- ##################################################################### -->
+
+ <section id="controlflowactivities">
+ <title>Control flow activities</title>
<section id="start">
<title><literal>start</literal></title>
@@ -691,132 +692,6 @@
</section>
</section>
- <!-- ### JAVA ########################################################## -->
-
- <section id="java">
- <title><literal>java</literal></title>
- <para>The Java task. A process execution will execute the method of the class that is configured
- in this activity.</para>
- <table><title><literal>java</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>class</literal></entry>
- <entry>classname</entry>
- <entry></entry>
- <entry><emphasis role="bold">required</emphasis></entry>
- <entry>The fully qualified classname.</entry>
- </row>
- <row>
- <entry><literal>method</literal></entry>
- <entry>methodname</entry>
- <entry></entry>
- <entry><emphasis role="bold">required</emphasis></entry>
- <entry>The name of the method to invoke</entry>
- </row>
- <row>
- <entry><literal>var</literal></entry>
- <entry>variablename</entry>
- <entry></entry>
- <entry>optional</entry>
- <entry>The name of the variable in which the return value
- should be stored.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table><title><literal>java</literal> 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 inject in a memberfield before
- the method is invoked.</entry>
- </row>
- <row>
- <entry><literal>arg</literal></entry>
- <entry>0..*</entry>
- <entry>method parameters</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <para>Consider the following example.</para>
- <figure id="process.java">
- <title>A java task</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/process.java.png"/></imageobject></mediaobject>
- </figure>
- <programlisting><process name="Java" xmlns="http://jbpm.org/4/jpdl">
-
- <start>
- <transition to="invoke java method" />
- </start>
-
- <java name="invoke java method"
- class="org.jbpm.examples.java.JohnDoe"
- method="hello"
- var="answer">
-
- <field name="state"><string value="fine"/></field>
- <field name="session"><env type="org.hibernate.Session"/></field>
-
- <arg><string value="Hi, how are you?"/></arg>
-
- <transition to="wait" />
- </java>
-
- <state name="wait">
-
-</process>
- </programlisting>
- <para>The java task specifies that during its execution an instance of the class <literal>org.jbpm.examples.java.JohnDoe</literal>
- will be instantiated and the method <literal>hello</literal> of this class will be invoked on the resulting object. The variable named
- <literal>answer</literal> will contain the result of the invocation. Let's look at the class <literal>JohnDoe</literal> below.
- </para>
- <programlisting>package org.jbpm.examples.java;
-
-import org.hibernate.Session;
-
-public class JohnDoe {
-
- String state;
- Session session;
-
- public String hello(String msg) {
- if ( (msg.indexOf("how are you?")!=-1)
- && (session.isOpen())
- ) {
- return "I'm "+state+", thank you.";
- }
- return null;
- }
-}</programlisting>
- <para>The class above reveals that it contains two fields named <literal>state</literal> and <literal>session</literal>
- and that the method <literal>hello</literal> accepts one argument. During the execution the values specified in the
- <literal>field</literal> and <literal>arg</literal> configuration elements will be used. The expected result of creating
- a process instance is that the process variable <literal>answer</literal> contains the string
- <literal>I'm fine, thank you.</literal>.
- </para>
- </section>
-
<!-- ### TASK ########################################################## -->
<section id="task">
@@ -1250,7 +1125,141 @@
taskService.setVariables(taskDbid, variables);</programlisting>
</section>
</section>
+ </section>
+
+ <!-- ##################################################################### -->
+ <!-- ### AUTOMATIC ACTIVITIES ### -->
+ <!-- ##################################################################### -->
+
+ <section id="automaticactivities">
+ <title>Automatic activities</title>
+ <!-- ### JAVA ########################################################## -->
+
+ <section id="java">
+ <title><literal>java</literal></title>
+ <para>The Java task. A process execution will execute the method of the class that is configured
+ in this activity.</para>
+ <table><title><literal>java</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>class</literal></entry>
+ <entry>classname</entry>
+ <entry></entry>
+ <entry><emphasis role="bold">required</emphasis></entry>
+ <entry>The fully qualified classname.</entry>
+ </row>
+ <row>
+ <entry><literal>method</literal></entry>
+ <entry>methodname</entry>
+ <entry></entry>
+ <entry><emphasis role="bold">required</emphasis></entry>
+ <entry>The name of the method to invoke</entry>
+ </row>
+ <row>
+ <entry><literal>var</literal></entry>
+ <entry>variablename</entry>
+ <entry></entry>
+ <entry>optional</entry>
+ <entry>The name of the variable in which the return value
+ should be stored.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table><title><literal>java</literal> 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 inject in a memberfield before
+ the method is invoked.</entry>
+ </row>
+ <row>
+ <entry><literal>arg</literal></entry>
+ <entry>0..*</entry>
+ <entry>method parameters</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>Consider the following example.</para>
+ <figure id="process.java">
+ <title>A java task</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.java.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting><process name="Java" xmlns="http://jbpm.org/4/jpdl">
+
+ <start>
+ <transition to="invoke java method" />
+ </start>
+
+ <java name="invoke java method"
+ class="org.jbpm.examples.java.JohnDoe"
+ method="hello"
+ var="answer">
+
+ <field name="state"><string value="fine"/></field>
+ <field name="session"><env type="org.hibernate.Session"/></field>
+
+ <arg><string value="Hi, how are you?"/></arg>
+
+ <transition to="wait" />
+ </java>
+
+ <state name="wait">
+
+</process>
+ </programlisting>
+ <para>The java task specifies that during its execution an instance of the class <literal>org.jbpm.examples.java.JohnDoe</literal>
+ will be instantiated and the method <literal>hello</literal> of this class will be invoked on the resulting object. The variable named
+ <literal>answer</literal> will contain the result of the invocation. Let's look at the class <literal>JohnDoe</literal> below.
+ </para>
+ <programlisting>package org.jbpm.examples.java;
+
+import org.hibernate.Session;
+
+public class JohnDoe {
+
+ String state;
+ Session session;
+
+ public String hello(String msg) {
+ if ( (msg.indexOf("how are you?")!=-1)
+ && (session.isOpen())
+ ) {
+ return "I'm "+state+", thank you.";
+ }
+ return null;
+ }
+}</programlisting>
+ <para>The class above reveals that it contains two fields named <literal>state</literal> and <literal>session</literal>
+ and that the method <literal>hello</literal> accepts one argument. During the execution the values specified in the
+ <literal>field</literal> and <literal>arg</literal> configuration elements will be used. The expected result of creating
+ a process instance is that the process variable <literal>answer</literal> contains the string
+ <literal>I'm fine, thank you.</literal>.
+ </para>
+ </section>
+
<!-- ### SCRIPT ######################################################## -->
<section id="script">
@@ -1642,55 +1651,193 @@
<literal>session.createSQLQuery(...)</literal> is used.
</para>
</section>
+ </section>
- <section id="commonactivitycontents">
- <title>Common activity contents</title>
- <para>Unless specified otherwise above, all activities also include this
- content model:
- </para>
- <table><title>Common activity 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>any text</entry>
- <entry></entry>
- <entry><emphasis role="bold">required</emphasis></entry>
- <entry>name of the activity</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table><title>Common activity 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>transition</literal></entry>
- <entry>0..*</entry>
- <entry>the outgoing transitions</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
+ <!-- ##################################################################### -->
+ <!-- ### COMMON ACTIVITY CONTENTS ### -->
+ <!-- ##################################################################### -->
+
+ <section id="commonactivitycontents">
+ <title>Common activity contents</title>
+ <para>Unless specified otherwise above, all activities also include this
+ content model:
+ </para>
+ <table><title>Common activity 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>any text</entry>
+ <entry></entry>
+ <entry><emphasis role="bold">required</emphasis></entry>
+ <entry>name of the activity</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table><title>Common activity 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>transition</literal></entry>
+ <entry>0..*</entry>
+ <entry>the outgoing transitions</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
</section>
+ <!-- ##################################################################### -->
+ <!-- ### EVENTS ### -->
+ <!-- ##################################################################### -->
+
+ <section id="events">
+ <title>Events</title>
+ <para>Events specify points in a process on which a list of event listeners can be registered.
+ When an execution passes that point in the process, the event listeners are notified.
+ The events and listeners are not shown in the graphical view of the process. An event
+ is fired by an element in the process definition like e.g. the process definition,
+ an activity or a transition.
+ </para>
+ <para>The EventListener interface looks like this:
+ </para>
+ <programlisting>public interface <emphasis role="bold">EventListener</emphasis> extends Serializable {
+
+ void notify(EventListenerExecution execution) throws Exception;
+
+}</programlisting>
+ <para>All <link linkend="automaticactivities">automatic activities</link> can be used as
+ event listeners as well.</para>
+ <para>To associate a list of event listeners with a process or an activity, use
+ the <literal>on</literal> element to group the event listeners and specifiy the
+ event. <literal>on</literal> can be nested as a subelement of <literal>process</literal>
+ or any activity.
+ </para>
+ <para>To associate a list of event listeners with a transition <literal>take</literal>
+ event, just include the event listeners directly in the <literal>transition</literal>
+ element.
+ </para>
+ <table><title><literal>on</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>event</literal></entry>
+ <entry>{start | end}</entry>
+ <entry></entry>
+ <entry><emphasis role="bold">required</emphasis></entry>
+ <entry>name name of the event</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table><title><literal>on</literal> 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>event-listener</literal></entry>
+ <entry>0..*</entry>
+ <entry>An event listener implementation object.</entry>
+ </row>
+ <row>
+ <entry>any automatic activity</entry>
+ <entry>0..*</entry>
+ <entry></entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>Let's look at an example process with event listeners:</para>
+ <figure id="process.eventlistener">
+ <title>The event listener example process</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.eventlistener.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting><process name="EventListener" xmlns="http://jbpm.org/4/jpdl">
+
+ <emphasis role="bold"><on event="start">
+ <event-listener class="org.jbpm.examples.eventlistener.LogListener"/>
+ </on>
+
+ <on event="end">
+ <event-listener class="org.jbpm.examples.eventlistener.LogListener"/>
+ </on></emphasis>
+
+
+ <start>
+ <transition to="wait" name=""/>
+ </start>
+
+ <state name="wait">
+ <emphasis role="bold"><on event="start">
+ <event-listener class="org.jbpm.examples.eventlistener.LogListener"/>
+ </on>
+ <on event="end">
+ <event-listener class="org.jbpm.examples.eventlistener.LogListener"/>
+ </on></emphasis>
+
+ <transition to="end" name="">
+ <event-listener class="org.jbpm.examples.eventlistener.LogListener"/>
+ </transition>
+ </state>
+
+ <end name="end"/>
+
+</process></programlisting>
+ <para><literal>LogListener</literal> will maintain a list of logs in a static member
+ field:</para>
+ <programlisting>public class <emphasis role="bold">LogListener</emphasis> implements EventListener {
+
+ public static List<String> logs; // initialization done in test method
+
+ public void notify(EventListenerExecution execution) {
+ logs.add(execution.getEvent()+" on "+execution.getEventSource());
+ }
+}</programlisting>
+ <para>Next, we start a new process instance.</para>
+ <programlisting>Execution execution = executionService.startProcessInstanceByKey("EventListener");</programlisting>
+ <para>Then the process instance executes up to the wait activity. So we provide a signal
+ and that will cause it to execute till the end.</para>
+ <programlisting>executionService.signalExecutionById(execution.getId());</programlisting>
+ <para>The list of log messages will now look like this:</para>
+ <programlisting>[event(start) on process(EventListener),
+ event(start) on activity(wait),
+ event(end) on activity(wait),
+ event(take) on (wait)-->(end),
+ event(end) on process(EventListener)]</programlisting>
+ </section>
+
<section id="usercode">
<title>User code</title>
<para>Various elements in the jPDL process language refer to a an
17 years
JBoss JBPM SVN: r4533 - jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules.
by do-not-reply@jboss.org
Author: bradsdavis
Date: 2009-04-09 20:07:30 -0400 (Thu, 09 Apr 2009)
New Revision: 4533
Modified:
jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules/ch09-Emails.xml
Log:
Updated with templating starts.
Modified: jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules/ch09-Emails.xml
===================================================================
--- jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules/ch09-Emails.xml 2009-04-09 22:45:20 UTC (rev 4532)
+++ jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules/ch09-Emails.xml 2009-04-10 00:07:30 UTC (rev 4533)
@@ -10,26 +10,107 @@
</section>
<section id="scriptableemails">
<title>Producers</title>
+ <para>Producers are responsible for creating emails within jBPM. All mail producers implement the <literal>MailProducer</literal> interface.
+ Several out-of-the-box implementations have been created to address simple email needs.</para>
+ <para>For complex emails or custom generation of attachments, see: <link linkend="customemails">Extension Points: Custom Emails</link>.</para>
<section id="standardemailformat">
<title>Standard</title>
+ <para>Used to send non-scripted text emails.</para>
+ <table><title>Standard Email</title>
+ <tgroup cols="2" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Property</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>subject</literal></entry>
+ <entry>Email subject.</entry>
+ </row>
+ <row>
+ <entry><literal>text</literal></entry>
+ <entry>The textual body of the email.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
</section>
<section id="scriptedemailformat">
<title>Scriptable Standard</title>
+ <para>Used to send scripted text emails for the subject and/or text.</para>
+ <table><title>Scriptable Email</title>
+ <tgroup cols="2" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Property</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>language</literal></entry>
+ <entry>The scripting language used to resolve properties within the subject and textual body.</entry>
+ </row>
+ <row>
+ <entry><literal>subject</literal></entry>
+ <entry>Email subject.</entry>
+ </row>
+ <row>
+ <entry><literal>text</literal></entry>
+ <entry>The textual body of the email.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
</section>
<section id="htmlemailformat">
<title>Scriptable HTML</title>
+ <para>Used to send scripted HTML formatted emails for the subject, text, and html.</para>
</section>
+ <table><title>Scriptable HTML Email</title>
+ <tgroup cols="2" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Property</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>language</literal></entry>
+ <entry>The scripting language used to resolve properties within the subject, textual body, and HTML body.</entry>
+ </row>
+ <row>
+ <entry><literal>subject</literal></entry>
+ <entry>Email subject.</entry>
+ </row>
+ <row>
+ <entry><literal>text</literal></entry>
+ <entry>The textual body of the email.</entry>
+ </row>
+ <row>
+ <entry><literal>html</literal></entry>
+ <entry>The HTML formatted body of the email.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
</section>
<section id="emailtemplates">
<title>Templates</title>
+ <para>Templates are available to externalize commonly used messages from jPDL definitions. In jBPM 4, templates can produce either standard or HTML message; also, templates
+ can support any scripting language supported by the jBPM Script Manager. As you will see, any <literal>MailProducer</literal> implementation available to jPDL is also available to be templated.
+ </para>
</section>
- <section id="serverconfiguration">
+ <section id="emailserverconfiguration">
<title>Server Configuration</title>
- <para>Mail Server configuration is provided within jbpm.cfg.xml The <emphasis role="bold">mail-server</emphasis> tag describes an SMTP mail server capable of sending email messages.
- Because jBPM uses JavaMail to send mail, all properties supported by JavaMail are also exposed to jBPM. Within the <emphasis role="bold">session-properties</emphasis>
- subtag of <emphasis role="bold">mail-server</emphasis>, the SMTP properties must be provided as described in the example below.</para>
+ <para>Mail Server configuration is provided within jbpm.cfg.xml The <literal>mail-server</literal> tag describes an SMTP mail server capable of sending email messages.
+ Because jBPM uses JavaMail to send mail, all properties supported by JavaMail are also exposed to jBPM. Within the <literal>session-properties</literal>
+ subtag of <literal>mail-server</literal>, the SMTP properties must be provided as described in the example below.</para>
<para>
- See the Sun JavaMail API for more information on supported properties. <ulink url="http://java.sun.com/products/javamail/javadocs/com/sun/mail/smtp/package-...">Sun SMTP Properties</ulink>
+ See the Sun JavaMail API for more information on supported properties: <ulink url="http://java.sun.com/products/javamail/javadocs/com/sun/mail/smtp/package-...">Sun SMTP Properties</ulink>.
</para>
<programlisting><objects>
<mail-session>
@@ -48,10 +129,10 @@
<para>
To setup multiple SMTP mail servers, provide multiple mail servers within the jBPM configuration, as described below.
- Note that the tag <emphasis role="bold">address-filter</emphasis> has been added to filter which domains are serviced by each mail server.
+ Note that the tag <literal>address-filter</literal> has been added to filter which domains are serviced by each mail server.
The mail filter accepts regular expressions to determine if an address is to be sent by a given server.
</para>
- <para>See the Sun Pattern API for more information on supported RegEx expressions. <ulink url="http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html">Sun Pattern JavaDoc</ulink>
+ <para>See the Sun Pattern API for more information on supported RegEx expressions: <ulink url="http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html">Sun Regex Patterns</ulink>.
</para>
<programlisting><objects>
<mail-session>
@@ -123,6 +204,13 @@
</section>
<section id="customemails">
<title>Custom Emails</title>
+ <para>jBPM 4 allows the creation of your own Email Producers to address an organization's specific email needs.
+ To do so, users must implement the <literal>MailProducer</literal> interface. The method produce will return one or more Email objects, which jBPM will then send using the jBPM MailSession.
+ <para>Apache Commons Email was choosen to simplify the email interface for jBPM. All emails returned by the MailProducer implementation must extend the base <literal>org.apache.commons.mail.Email</literal>.</para>
+ <para>See the Apache Commons for more information on supported <literal>Email</literal> types:
+ <ulink url="http://commons.apache.org/email/">Apache Commons Email</ulink>.</para>
+ </para>
+
<section id="generatedemailattachments">
<title>Attachments</title>
</section>
17 years
JBoss JBPM SVN: r4532 - jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules.
by do-not-reply@jboss.org
Author: bradsdavis
Date: 2009-04-09 18:45:20 -0400 (Thu, 09 Apr 2009)
New Revision: 4532
Modified:
jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules/ch09-Emails.xml
Log:
Added different types of producers to talk about.
Modified: jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules/ch09-Emails.xml
===================================================================
--- jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules/ch09-Emails.xml 2009-04-09 22:34:59 UTC (rev 4531)
+++ jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules/ch09-Emails.xml 2009-04-09 22:45:20 UTC (rev 4532)
@@ -10,6 +10,15 @@
</section>
<section id="scriptableemails">
<title>Producers</title>
+ <section id="standardemailformat">
+ <title>Standard</title>
+ </section>
+ <section id="scriptedemailformat">
+ <title>Scriptable Standard</title>
+ </section>
+ <section id="htmlemailformat">
+ <title>Scriptable HTML</title>
+ </section>
</section>
<section id="emailtemplates">
<title>Templates</title>
@@ -22,17 +31,16 @@
<para>
See the Sun JavaMail API for more information on supported properties. <ulink url="http://java.sun.com/products/javamail/javadocs/com/sun/mail/smtp/package-...">Sun SMTP Properties</ulink>
</para>
- <programlisting><![CDATA[
-<objects>
- <mail-session>
- <mail-server>
- <session-properties>
- <property name='mail.host' value='localhost' />
+ <programlisting><objects>
+ <mail-session>
+ <mail-server><emphasis role="bold">
+ <session-properties>
+ <property name='mail.host' value='localhost' />
...
- </session-properties>
- </mail-server>
- </mail-session>
-</objects>]]></programlisting>
+ </session-properties></emphasis>
+ </mail-server>
+ </mail-session>
+</objects></programlisting>
<section id="serverconfigurationmultipl">
<title>Multiple Mail Servers</title>
<para>Multiple SMTP server support has been added to jBPM 4 to support many organizational server structures.
@@ -68,7 +76,7 @@
</mail-session>
</objects></programlisting>
<para>
- The include/excude logic includes an address if it is explicitly included and not explicitly excluded.
+ The include/excude logic includes an address if it is <emphasis role="bold">included and not explicitly excluded.</emphasis>
The include/exclude logic within the address filter is described below.
@@ -110,6 +118,16 @@
</section>
<section id="extensibility">
<title>Extension Points</title>
+ <section id="addressresolvers">
+ <title>Address Resolvers</title>
+ </section>
+ <section id="customemails">
+ <title>Custom Emails</title>
+ <section id="generatedemailattachments">
+ <title>Attachments</title>
+ </section>
+ </section>
+
</section>
</chapter>
\ No newline at end of file
17 years
JBoss JBPM SVN: r4531 - jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules.
by do-not-reply@jboss.org
Author: bradsdavis
Date: 2009-04-09 18:34:59 -0400 (Thu, 09 Apr 2009)
New Revision: 4531
Modified:
jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules/ch09-Emails.xml
Log:
Modified: jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules/ch09-Emails.xml
===================================================================
--- jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules/ch09-Emails.xml 2009-04-09 22:31:24 UTC (rev 4530)
+++ jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules/ch09-Emails.xml 2009-04-09 22:34:59 UTC (rev 4531)
@@ -17,7 +17,8 @@
<section id="serverconfiguration">
<title>Server Configuration</title>
<para>Mail Server configuration is provided within jbpm.cfg.xml The <emphasis role="bold">mail-server</emphasis> tag describes an SMTP mail server capable of sending email messages.
- Because jBPM uses JavaMail to send mail, all properties supported by JavaMail are also exposed to jBPM. Within the subtag of <emphasis role="bold">mail-server</emphasis>, the SMTP properties must be provided as described in the example below.</para>
+ Because jBPM uses JavaMail to send mail, all properties supported by JavaMail are also exposed to jBPM. Within the <emphasis role="bold">session-properties</emphasis>
+ subtag of <emphasis role="bold">mail-server</emphasis>, the SMTP properties must be provided as described in the example below.</para>
<para>
See the Sun JavaMail API for more information on supported properties. <ulink url="http://java.sun.com/products/javamail/javadocs/com/sun/mail/smtp/package-...">Sun SMTP Properties</ulink>
</para>
@@ -88,7 +89,7 @@
</row>
<row>
<entry><literal>include</literal></entry>
- <entry>1..X</entry>
+ <entry>1..Many</entry>
<entry>If one or more includes are present, the address filter will include only email addresses matching the include patterns provided.</entry>
</row>
<row>
@@ -98,7 +99,7 @@
</row>
<row>
<entry><literal>exclude</literal></entry>
- <entry>1..X</entry>
+ <entry>1..Many</entry>
<entry>If one or more excludes are present, the address filter will explicitly exclude only email addresses matching the exclude patterns provided.</entry>
</row>
</tbody>
17 years
JBoss JBPM SVN: r4530 - jbpm4/branches/email/modules/userguide/src/main/docbook/en.
by do-not-reply@jboss.org
Author: bradsdavis
Date: 2009-04-09 18:31:24 -0400 (Thu, 09 Apr 2009)
New Revision: 4530
Modified:
jbpm4/branches/email/modules/userguide/src/main/docbook/en/master.xml
Log:
Added email documentation.
Modified: jbpm4/branches/email/modules/userguide/src/main/docbook/en/master.xml
===================================================================
--- jbpm4/branches/email/modules/userguide/src/main/docbook/en/master.xml 2009-04-09 22:31:14 UTC (rev 4529)
+++ jbpm4/branches/email/modules/userguide/src/main/docbook/en/master.xml 2009-04-09 22:31:24 UTC (rev 4530)
@@ -8,7 +8,8 @@
<!ENTITY ch05-Jpdl SYSTEM "modules/ch05-Jpdl.xml">
<!ENTITY ch06-Variables SYSTEM "modules/ch06-Variables.xml">
<!ENTITY ch07-Scripting SYSTEM "modules/ch07-Scripting.xml">
- <!ENTITY ch08-Identity SYSTEM "modules/ch08-Identity.xml">
+ <!ENTITY ch08-Identity SYSTEM "modules/ch08-Identity.xml">
+ <!ENTITY ch09-Emails SYSTEM "modules/ch09-Emails.xml">
]>
<book lang="en">
@@ -27,5 +28,5 @@
&ch06-Variables;
&ch07-Scripting;
&ch08-Identity;
-
+ &ch09-Emails;
</book>
\ No newline at end of file
17 years
JBoss JBPM SVN: r4529 - jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules.
by do-not-reply@jboss.org
Author: bradsdavis
Date: 2009-04-09 18:31:14 -0400 (Thu, 09 Apr 2009)
New Revision: 4529
Added:
jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules/ch09-Emails.xml
Log:
Beginnings of the email documentation.
Added: jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules/ch09-Emails.xml
===================================================================
--- jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules/ch09-Emails.xml (rev 0)
+++ jbpm4/branches/email/modules/userguide/src/main/docbook/en/modules/ch09-Emails.xml 2009-04-09 22:31:14 UTC (rev 4529)
@@ -0,0 +1,114 @@
+<chapter id="emails">
+ <title>Email Support</title>
+ <para>
+ This chapter explains Email Support provided within jBPM 4.
+ </para>
+
+
+ <section id="mailinjpdl">
+ <title>Mail in jPDL</title>
+ </section>
+ <section id="scriptableemails">
+ <title>Producers</title>
+ </section>
+ <section id="emailtemplates">
+ <title>Templates</title>
+ </section>
+ <section id="serverconfiguration">
+ <title>Server Configuration</title>
+ <para>Mail Server configuration is provided within jbpm.cfg.xml The <emphasis role="bold">mail-server</emphasis> tag describes an SMTP mail server capable of sending email messages.
+ Because jBPM uses JavaMail to send mail, all properties supported by JavaMail are also exposed to jBPM. Within the subtag of <emphasis role="bold">mail-server</emphasis>, the SMTP properties must be provided as described in the example below.</para>
+ <para>
+ See the Sun JavaMail API for more information on supported properties. <ulink url="http://java.sun.com/products/javamail/javadocs/com/sun/mail/smtp/package-...">Sun SMTP Properties</ulink>
+ </para>
+ <programlisting><![CDATA[
+<objects>
+ <mail-session>
+ <mail-server>
+ <session-properties>
+ <property name='mail.host' value='localhost' />
+ ...
+ </session-properties>
+ </mail-server>
+ </mail-session>
+</objects>]]></programlisting>
+ <section id="serverconfigurationmultipl">
+ <title>Multiple Mail Servers</title>
+ <para>Multiple SMTP server support has been added to jBPM 4 to support many organizational server structures.
+ This is useful for organizations who have both internal and external SMTP servers, for example.</para>
+ <para>
+ To setup multiple SMTP mail servers, provide multiple mail servers within the jBPM configuration, as described below.
+
+ Note that the tag <emphasis role="bold">address-filter</emphasis> has been added to filter which domains are serviced by each mail server.
+ The mail filter accepts regular expressions to determine if an address is to be sent by a given server.
+ </para>
+ <para>See the Sun Pattern API for more information on supported RegEx expressions. <ulink url="http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html">Sun Pattern JavaDoc</ulink>
+ </para>
+ <programlisting><objects>
+ <mail-session>
+ <mail-server><emphasis role="bold">
+ <address-filter>
+ <include>.+(a)jbpm.org</include>
+ </address-filter></emphasis>
+ <session-properties>
+ <property name='mail.host' value='internal.host.url' />
+ ...
+ </session-properties>
+ </mail-server>
+ <mail-server><emphasis role="bold">
+ <address-filter>
+ <exclude>.+(a)jbpm.org</exclude>
+ </address-filter></emphasis>
+ <session-properties>
+ <property name='mail.host' value='external.host.url' />
+ ...
+ </session-properties>
+ </mail-server>
+ </mail-session>
+</objects></programlisting>
+ <para>
+ The include/excude logic includes an address if it is explicitly included and not explicitly excluded.
+
+ The include/exclude logic within the address filter is described below.
+
+ <table><title>Address Filter</title>
+ <tgroup cols="3" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Property</entry>
+ <entry>Multiple</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>include</literal></entry>
+ <entry>0</entry>
+ <entry>If no includes are present, the address filter will include all email addresses.</entry>
+ </row>
+ <row>
+ <entry><literal>include</literal></entry>
+ <entry>1..X</entry>
+ <entry>If one or more includes are present, the address filter will include only email addresses matching the include patterns provided.</entry>
+ </row>
+ <row>
+ <entry><literal>exclude</literal></entry>
+ <entry>0</entry>
+ <entry>If no excludes are present, no addresses are explicitly excluded.</entry>
+ </row>
+ <row>
+ <entry><literal>exclude</literal></entry>
+ <entry>1..X</entry>
+ <entry>If one or more excludes are present, the address filter will explicitly exclude only email addresses matching the exclude patterns provided.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </para>
+ </section>
+ </section>
+ <section id="extensibility">
+ <title>Extension Points</title>
+ </section>
+
+</chapter>
\ No newline at end of file
17 years
JBoss JBPM SVN: r4528 - jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl.
by do-not-reply@jboss.org
Author: bradsdavis
Date: 2009-04-09 16:08:20 -0400 (Thu, 09 Apr 2009)
New Revision: 4528
Modified:
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/ScriptMailProducer.java
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java
Log:
Refactored method names.
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java 2009-04-09 20:07:18 UTC (rev 4527)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java 2009-04-09 20:08:20 UTC (rev 4528)
@@ -47,13 +47,13 @@
this.text = (String)scriptManager.evaluateScript(this.text, exe, language);
this.subject = (String)scriptManager.evaluateScript(this.subject, exe, language);
this.html = (String)scriptManager.evaluate(this.html, exe, language);
- this.resolveAttachments(scriptManager, exe);
+ this.resolveUrlAttachments(scriptManager, exe);
//Create an HTML message.
HtmlEmail email = new HtmlEmail();
//Populate recipients.
this.populateAddresses(mailContext, email);
- this.populateAttachments((MultiPartEmail)email);
+ this.populateUrlAttachments((MultiPartEmail)email);
//Set the regular body [non-html] and subject.
email.setTextMsg(this.text);
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/ScriptMailProducer.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/ScriptMailProducer.java 2009-04-09 20:07:18 UTC (rev 4527)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/ScriptMailProducer.java 2009-04-09 20:08:20 UTC (rev 4528)
@@ -29,7 +29,7 @@
//as evaluated by the JBPM script manager.
this.text = (String)scriptManager.evaluateScript(this.text, exe, language);
this.subject = (String)scriptManager.evaluateScript(this.subject, exe, language);
- this.resolveAttachments(scriptManager,exe);
+ this.resolveUrlAttachments(scriptManager,exe);
//Populate and produce email based on SimpleMailProducer logic now that fields
@@ -41,7 +41,7 @@
this.language = language;
}
- protected void resolveAttachments(final ScriptManager scriptManager, final Execution exe) {
+ protected void resolveUrlAttachments(final ScriptManager scriptManager, final Execution exe) {
//Resolve attachments from script to URL.
if(urlAttachments!=null&&!urlAttachments.isEmpty())
{
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java 2009-04-09 20:07:18 UTC (rev 4527)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java 2009-04-09 20:08:20 UTC (rev 4528)
@@ -55,7 +55,7 @@
//If there are attachments, add them to the email.
if(urlAttachments!=null&&!urlAttachments.isEmpty())
{
- populateAttachments((MultiPartEmail)email);
+ populateUrlAttachments((MultiPartEmail)email);
}
//Set subject and message.
@@ -140,7 +140,7 @@
return name;
}
- protected void populateAttachments(MultiPartEmail email) throws Exception
+ protected void populateUrlAttachments(MultiPartEmail email) throws Exception
{
if(urlAttachments!=null&&!urlAttachments.isEmpty())
{
17 years
JBoss JBPM SVN: r4527 - jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl.
by do-not-reply@jboss.org
Author: bradsdavis
Date: 2009-04-09 16:07:18 -0400 (Thu, 09 Apr 2009)
New Revision: 4527
Modified:
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/ScriptMailProducer.java
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java
Log:
Extracted logic for resolving and populating attachments.
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java 2009-04-09 19:44:10 UTC (rev 4526)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java 2009-04-09 20:07:18 UTC (rev 4527)
@@ -47,41 +47,18 @@
this.text = (String)scriptManager.evaluateScript(this.text, exe, language);
this.subject = (String)scriptManager.evaluateScript(this.subject, exe, language);
this.html = (String)scriptManager.evaluate(this.html, exe, language);
-
- //Resolve attachements from script to URL.
- if(urlAttachments!=null)
- {
- for(String urlKey : urlAttachments.keySet())
- {
- String url = urlAttachments.get(urlKey);
- url = (String)scriptManager.evaluateScript(url, exe, language);
- urlAttachments.put(urlKey, url);
- }
- }
+ this.resolveAttachments(scriptManager, exe);
//Create an HTML message.
HtmlEmail email = new HtmlEmail();
//Populate recipients.
this.populateAddresses(mailContext, email);
+ this.populateAttachments((MultiPartEmail)email);
+
//Set the regular body [non-html] and subject.
email.setTextMsg(this.text);
email.setSubject(this.subject);
- if(urlAttachments!=null)
- {
- for(String urlKey : urlAttachments.keySet())
- {
- try {
- URL url = new URL(urlAttachments.get(urlKey));
- ((MultiPartEmail)email).attach(url,urlKey,urlKey);
- }
- catch(EmailException urlException)
- {
- log.error("Exception getting the URL.",urlException);
- }
- }
- }
-
//Keep track of the CIDs that have replaced SRCs to reduce
//calls to replace. Should improve efficiency.
Set<String> cidSet = new HashSet<String>();
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/ScriptMailProducer.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/ScriptMailProducer.java 2009-04-09 19:44:10 UTC (rev 4526)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/ScriptMailProducer.java 2009-04-09 20:07:18 UTC (rev 4527)
@@ -29,9 +29,21 @@
//as evaluated by the JBPM script manager.
this.text = (String)scriptManager.evaluateScript(this.text, exe, language);
this.subject = (String)scriptManager.evaluateScript(this.subject, exe, language);
+ this.resolveAttachments(scriptManager,exe);
- //Resolve attachements from script to URL.
- if(urlAttachments!=null)
+
+ //Populate and produce email based on SimpleMailProducer logic now that fields
+ //have been resolved using the JBPM script manager.
+ return super.produce(exe, mailContext);
+ }
+
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ protected void resolveAttachments(final ScriptManager scriptManager, final Execution exe) {
+ //Resolve attachments from script to URL.
+ if(urlAttachments!=null&&!urlAttachments.isEmpty())
{
for(String urlKey : urlAttachments.keySet())
{
@@ -40,14 +52,6 @@
urlAttachments.put(urlKey, url);
}
}
-
- //Populate and produce email based on SimpleMailProducer logic now that fields
- //have been resolved using the JBPM script manager.
- return super.produce(exe, mailContext);
}
- public void setLanguage(String language) {
- this.language = language;
- }
-
}
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java 2009-04-09 19:44:10 UTC (rev 4526)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java 2009-04-09 20:07:18 UTC (rev 4527)
@@ -51,26 +51,17 @@
//Resolve and populate to, cc, bcc addresses.
populateAddresses(mailContext, email);
-
+
+ //If there are attachments, add them to the email.
+ if(urlAttachments!=null&&!urlAttachments.isEmpty())
+ {
+ populateAttachments((MultiPartEmail)email);
+ }
+
//Set subject and message.
email.setSubject(subject);
email.setMsg(text);
- if(urlAttachments!=null)
- {
- for(String urlKey : urlAttachments.keySet())
- {
- try {
- URL url = new URL(urlAttachments.get(urlKey));
- ((MultiPartEmail)email).attach(url,urlKey,urlKey);
- }
- catch(EmailException urlException)
- {
- log.error("Exception getting the URL.",urlException);
- }
- }
- }
-
Collection<Email> emails = new HashSet<Email>();
emails.add(email);
@@ -148,6 +139,18 @@
return name;
}
+
+ protected void populateAttachments(MultiPartEmail email) throws Exception
+ {
+ if(urlAttachments!=null&&!urlAttachments.isEmpty())
+ {
+ for(String urlKey : urlAttachments.keySet())
+ {
+ URL url = new URL(urlAttachments.get(urlKey));
+ ((MultiPartEmail)email).attach(url,urlKey,urlKey);
+ }
+ }
+ }
public void setText(String text) {
17 years
JBoss JBPM SVN: r4526 - jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl.
by do-not-reply@jboss.org
Author: bradsdavis
Date: 2009-04-09 15:44:10 -0400 (Thu, 09 Apr 2009)
New Revision: 4526
Modified:
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java
Log:
Added simple URL attachment support.
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java 2009-04-09 19:43:02 UTC (rev 4525)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java 2009-04-09 19:44:10 UTC (rev 4526)
@@ -1,5 +1,6 @@
package org.jbpm.pvm.internal.email.producer.impl;
+import java.net.URL;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
@@ -11,7 +12,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.mail.Email;
+import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
+import org.apache.commons.mail.MultiPartEmail;
import org.jbpm.Execution;
import org.jbpm.env.Environment;
import org.jbpm.pvm.internal.email.producer.MailContext;
@@ -45,6 +48,17 @@
this.subject = (String)scriptManager.evaluateScript(this.subject, exe, language);
this.html = (String)scriptManager.evaluate(this.html, exe, language);
+ //Resolve attachements from script to URL.
+ if(urlAttachments!=null)
+ {
+ for(String urlKey : urlAttachments.keySet())
+ {
+ String url = urlAttachments.get(urlKey);
+ url = (String)scriptManager.evaluateScript(url, exe, language);
+ urlAttachments.put(urlKey, url);
+ }
+ }
+
//Create an HTML message.
HtmlEmail email = new HtmlEmail();
//Populate recipients.
@@ -53,6 +67,21 @@
email.setTextMsg(this.text);
email.setSubject(this.subject);
+ if(urlAttachments!=null)
+ {
+ for(String urlKey : urlAttachments.keySet())
+ {
+ try {
+ URL url = new URL(urlAttachments.get(urlKey));
+ ((MultiPartEmail)email).attach(url,urlKey,urlKey);
+ }
+ catch(EmailException urlException)
+ {
+ log.error("Exception getting the URL.",urlException);
+ }
+ }
+ }
+
//Keep track of the CIDs that have replaced SRCs to reduce
//calls to replace. Should improve efficiency.
Set<String> cidSet = new HashSet<String>();
17 years
JBoss JBPM SVN: r4525 - jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl.
by do-not-reply@jboss.org
Author: bradsdavis
Date: 2009-04-09 15:43:02 -0400 (Thu, 09 Apr 2009)
New Revision: 4525
Modified:
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java
Log:
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java 2009-04-09 19:42:34 UTC (rev 4524)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/SimpleMailProducer.java 2009-04-09 19:43:02 UTC (rev 4525)
@@ -38,12 +38,14 @@
//Create a simple email with the body set.
Email email;
+ //If there are attachments, must be multipart message.
if(urlAttachments!=null&&!urlAttachments.isEmpty())
{
email = new MultiPartEmail();
}
else
{
+ //Otherwise, it is simple.
email = new SimpleEmail();
}
17 years