JBoss JBPM SVN: r4875 - in jbpm4/trunk/modules: examples/src/test/java/org/jbpm/examples/async and 17 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-05-23 06:38:45 -0400 (Sat, 23 May 2009)
New Revision: 4875
Added:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/eventlistener/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/eventlistener/AsyncEventListenerTest.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/eventlistener/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/eventlistener/process.jpdl.xml
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListenerMessage.java
Modified:
jbpm4/trunk/modules/api/src/main/resources/jpdl-4.0.xsd
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/activity/Application.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/Application.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/AsyncForkTest.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/hql/HqlTest.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/mail/inline/InlineMailTest.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/mail/template/TemplateMailTest.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/inline/process.jpdl.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/template/process.jpdl.xml
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/MailActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.eventlisteners.xml
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ActivityImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListener.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml
Log:
JBPM-2256 async event listeners
Modified: jbpm4/trunk/modules/api/src/main/resources/jpdl-4.0.xsd
===================================================================
--- jbpm4/trunk/modules/api/src/main/resources/jpdl-4.0.xsd 2009-05-22 14:06:47 UTC (rev 4874)
+++ jbpm4/trunk/modules/api/src/main/resources/jpdl-4.0.xsd 2009-05-23 10:38:45 UTC (rev 4875)
@@ -239,6 +239,18 @@
<element ref="tns:transition" minOccurs="0" maxOccurs="unbounded" />
</sequence>
<attributeGroup ref="tns:activityAttributes" />
+ <attribute name="multiplicity" type="int" />
+ <attribute name="lockmode" default="upgrade">
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="none"/>
+ <enumeration value="read"/>
+ <enumeration value="upgrade"/>
+ <enumeration value="upgrade_nowait"/>
+ <enumeration value="write"/>
+ </restriction>
+ </simpleType>
+ </attribute>
</complexType>
</element>
Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/activity/Application.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/activity/Application.java 2009-05-22 14:06:47 UTC (rev 4874)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/activity/Application.java 2009-05-23 10:38:45 UTC (rev 4875)
@@ -28,8 +28,10 @@
public class Application {
public void generatePdf() {
+ // assume long automatic calculations here
}
public void calculatePrimes() {
+ // assume long automatic calculations here
}
}
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/eventlistener/AsyncEventListenerTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/eventlistener/AsyncEventListenerTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/eventlistener/AsyncEventListenerTest.java 2009-05-23 10:38:45 UTC (rev 4875)
@@ -0,0 +1,76 @@
+/*
+ * 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.async.eventlistener;
+
+import java.io.IOException;
+
+import javax.mail.MessagingException;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.job.Job;
+import org.jbpm.test.JbpmTestCase;
+import org.subethamail.wiser.Wiser;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AsyncEventListenerTest extends JbpmTestCase {
+
+ long deploymentDbid;
+ Wiser wiser = null;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ deploymentDbid = repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/examples/async/eventlistener/process.jpdl.xml")
+ .deploy();
+
+ // start mail server
+ wiser = new Wiser();
+ wiser.setPort(2525);
+ wiser.start();
+ }
+
+ protected void tearDown() throws Exception {
+ wiser.stop();
+
+ repositoryService.deleteDeploymentCascade(deploymentDbid);
+
+ super.tearDown();
+ }
+
+ public void testAsyncEventListener() throws Exception{
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncEventListener");
+ String processInstanceId = processInstance.getId();
+
+ assertEquals(0, wiser.getMessages().size());
+
+ Job job = managementService.createJobQuery()
+ .processInstanceId(processInstanceId)
+ .uniqueResult();
+ managementService.executeJob(job.getDbid());
+
+ assertEquals(1, wiser.getMessages().size());
+ }
+}
Property changes on: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/eventlistener/AsyncEventListenerTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/Application.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/Application.java 2009-05-22 14:06:47 UTC (rev 4874)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/Application.java 2009-05-23 10:38:45 UTC (rev 4875)
@@ -28,8 +28,10 @@
public class Application {
public void shipGoods() {
+ // assume automatic calculations here
}
public void sendBill() {
+ // assume automatic calculations here
}
}
Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/AsyncForkTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/AsyncForkTest.java 2009-05-22 14:06:47 UTC (rev 4874)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/AsyncForkTest.java 2009-05-23 10:38:45 UTC (rev 4875)
@@ -21,6 +21,7 @@
*/
package org.jbpm.examples.async.fork;
+import java.util.Date;
import java.util.List;
import org.jbpm.api.ProcessInstance;
@@ -57,8 +58,6 @@
.processInstanceId(processInstanceId)
.list();
- System.out.println(jobs);
-
assertEquals(2, jobs.size());
Job job = jobs.get(0);
@@ -68,5 +67,13 @@
job = jobs.get(1);
managementService.executeJob(job.getDbid());
+
+ Date endTime = historyService
+ .createHistoryProcessInstanceQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult()
+ .getEndTime();
+
+ assertNotNull(endTime);
}
}
Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/hql/HqlTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/hql/HqlTest.java 2009-05-22 14:06:47 UTC (rev 4874)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/hql/HqlTest.java 2009-05-23 10:38:45 UTC (rev 4875)
@@ -25,7 +25,7 @@
import java.util.HashSet;
import java.util.Set;
-import org.jbpm.api.Execution;
+import org.jbpm.api.ProcessInstance;
import org.jbpm.api.task.Task;
import org.jbpm.test.JbpmTestCase;
@@ -75,17 +75,17 @@
}
public void testHql() {
- Execution execution = executionService.startProcessInstanceByKey("Hql");
- String executionId = execution.getId();
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("Hql");
+ String processInstanceId = processInstance.getId();
Set<String> expectedTaskNames = new HashSet<String>();
expectedTaskNames.add("dishes");
expectedTaskNames.add("iron");
- Collection<String> taskNames = (Collection<String>) executionService.getVariable(executionId, "tasknames with i");
+ Collection<String> taskNames = (Collection<String>) executionService.getVariable(processInstanceId, "tasknames with i");
taskNames = new HashSet<String>(taskNames);
assertEquals(expectedTaskNames, taskNames);
- Object activities = executionService.getVariable(executionId, "tasks");
+ Object activities = executionService.getVariable(processInstanceId, "tasks");
assertEquals("3", activities.toString());
}
}
Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/mail/inline/InlineMailTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/mail/inline/InlineMailTest.java 2009-05-22 14:06:47 UTC (rev 4874)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/mail/inline/InlineMailTest.java 2009-05-23 10:38:45 UTC (rev 4875)
@@ -44,6 +44,8 @@
*/
public class InlineMailTest extends JbpmTestCase {
+ Wiser wiser = null;
+
protected void setUp() throws Exception {
super.setUp();
@@ -62,9 +64,16 @@
identityService.createMembership("obrien", "innerparty");
identityService.createMembership("charr", "thinkpol");
identityService.createMembership("obrien", "thinkpol");
+
+ // start mail server
+ wiser = new Wiser();
+ wiser.setPort(2525);
+ wiser.start();
}
protected void tearDown() throws Exception {
+ wiser.stop();
+
// delete actors
identityService.deleteGroup("thinkpol");
identityService.deleteGroup("innerparty");
@@ -76,54 +85,46 @@
}
public void testInlineMail() throws MessagingException, IOException {
- Wiser wiser = new Wiser();
- wiser.setPort(2525);
- wiser.start();
- try {
- // prepare dynamic values
- String newspaper = "times";
- Calendar calendar = Calendar.getInstance();
- calendar.clear();
- calendar.set(1983, Calendar.DECEMBER, 3);
- Date date = calendar.getTime();
- // assemble variables
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("newspaper", newspaper);
- variables.put("date", date);
- // start process instance
- executionService.startProcessInstanceByKey("InlineMail", variables);
+ // prepare dynamic values
+ String newspaper = "times";
+ Calendar calendar = Calendar.getInstance();
+ calendar.clear();
+ calendar.set(1983, Calendar.DECEMBER, 3);
+ Date date = calendar.getTime();
+ // assemble variables
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("newspaper", newspaper);
+ variables.put("date", date);
+ // start process instance
+ executionService.startProcessInstanceByKey("InlineMail", variables);
- // examine produced message
- List<WiserMessage> wisMessages = wiser.getMessages();
- // winston, bb, innerparty(obrien), thinkpol(charr, obrien)
- assertEquals(5, wisMessages.size());
+ // examine produced message
+ List<WiserMessage> wisMessages = wiser.getMessages();
+ // winston, bb, innerparty(obrien), thinkpol(charr, obrien)
+ assertEquals(5, wisMessages.size());
- for (WiserMessage wisMessage : wisMessages) {
- Message message = wisMessage.getMimeMessage();
- // from
- Address[] from = message.getFrom();
- assertEquals(1, from.length);
- assertEquals("noreply(a)jbpm.org", from[0].toString());
- // to
- Address[] expectedTo = InternetAddress.parse("winston@minitrue");
- Address[] to = message.getRecipients(RecipientType.TO);
- assert Arrays.equals(expectedTo, to) : Arrays.asList(to);
- // cc
- Address[] expectedCc = InternetAddress.parse("bb@oceania, obrien@miniluv");
- System.out.println(Arrays.toString(expectedCc));
- Address[] cc = message.getRecipients(RecipientType.CC);
- System.out.println(Arrays.toString(cc));
- assert Arrays.equals(expectedCc, cc) : Arrays.asList(cc);
- // bcc - recipients undisclosed
- assertNull(message.getRecipients(RecipientType.BCC));
- // subject
- assertEquals("rectify " + newspaper, message.getSubject());
- // text
- assertTextPresent(newspaper + ' ' + date + " reporting bb dayorder", (String) message.getContent());
- }
+ for (WiserMessage wisMessage : wisMessages) {
+ Message message = wisMessage.getMimeMessage();
+ // from
+ Address[] from = message.getFrom();
+ assertEquals(1, from.length);
+ assertEquals("noreply(a)jbpm.org", from[0].toString());
+ // to
+ Address[] expectedTo = InternetAddress.parse("winston@minitrue");
+ Address[] to = message.getRecipients(RecipientType.TO);
+ assert Arrays.equals(expectedTo, to) : Arrays.asList(to);
+ // cc
+ Address[] expectedCc = InternetAddress.parse("bb@oceania, obrien@miniluv");
+ System.out.println(Arrays.toString(expectedCc));
+ Address[] cc = message.getRecipients(RecipientType.CC);
+ System.out.println(Arrays.toString(cc));
+ assert Arrays.equals(expectedCc, cc) : Arrays.asList(cc);
+ // bcc - recipients undisclosed
+ assertNull(message.getRecipients(RecipientType.BCC));
+ // subject
+ assertEquals("rectify " + newspaper, message.getSubject());
+ // text
+ assertTextPresent(newspaper + ' ' + date + " reporting bb dayorder", (String) message.getContent());
}
- finally {
- wiser.stop();
- }
}
}
Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/mail/template/TemplateMailTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/mail/template/TemplateMailTest.java 2009-05-22 14:06:47 UTC (rev 4874)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/mail/template/TemplateMailTest.java 2009-05-23 10:38:45 UTC (rev 4875)
@@ -44,6 +44,8 @@
*/
public class TemplateMailTest extends JbpmTestCase {
+ Wiser wiser = null;
+
protected void setUp() throws Exception {
super.setUp();
@@ -62,9 +64,16 @@
identityService.createMembership("obrien", "innerparty");
identityService.createMembership("charr", "thinkpol");
identityService.createMembership("obrien", "thinkpol");
+
+ // start mail server
+ wiser = new Wiser();
+ wiser.setPort(2525);
+ wiser.start();
}
protected void tearDown() throws Exception {
+ wiser.stop();
+
// delete actors
identityService.deleteGroup("thinkpol");
identityService.deleteGroup("innerparty");
@@ -76,57 +85,49 @@
}
public void testTemplateMail() throws MessagingException, IOException {
- Wiser wiser = new Wiser();
- wiser.setPort(2525);
- wiser.start();
- try {
- // prepare dynamic values
- String addressee = "winston@minitrue";
- String newspaper = "times";
- Calendar calendar = Calendar.getInstance();
- calendar.clear();
- calendar.set(1983, Calendar.DECEMBER, 3);
- Date date = calendar.getTime();
- String details = "reporting bb dayorder doubleplusungood refs unpersons rewrite "
- + "fullwise upsub antefiling";
- // assemble variables
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("addressee", addressee);
- variables.put("newspaper", newspaper);
- variables.put("date", date);
- variables.put("details", details);
- // start process instance
- executionService.startProcessInstanceByKey("TemplateMail", variables);
+ // prepare dynamic values
+ String addressee = "winston@minitrue";
+ String newspaper = "times";
+ Calendar calendar = Calendar.getInstance();
+ calendar.clear();
+ calendar.set(1983, Calendar.DECEMBER, 3);
+ Date date = calendar.getTime();
+ String details = "reporting bb dayorder doubleplusungood refs unpersons rewrite "
+ + "fullwise upsub antefiling";
+ // assemble variables
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("addressee", addressee);
+ variables.put("newspaper", newspaper);
+ variables.put("date", date);
+ variables.put("details", details);
+ // start process instance
+ executionService.startProcessInstanceByKey("TemplateMail", variables);
- // examine produced messages
- List<WiserMessage> wisMessages = wiser.getMessages();
- // winston, bb, innerparty(obrien), thinkpol(charr, obrien)
- assertEquals(5, wisMessages.size());
+ // examine produced messages
+ List<WiserMessage> wisMessages = wiser.getMessages();
+ // winston, bb, innerparty(obrien), thinkpol(charr, obrien)
+ assertEquals(5, wisMessages.size());
- for (WiserMessage wisMessage : wisMessages) {
- Message message = wisMessage.getMimeMessage();
- // from
- Address[] from = message.getFrom();
- assertEquals(1, from.length);
- assertEquals("noreply(a)jbpm.org", from[0].toString());
- // to
- Address[] expectedTo = InternetAddress.parse(addressee);
- Address[] to = message.getRecipients(RecipientType.TO);
- assert Arrays.equals(expectedTo, to) : Arrays.asList(to);
- // cc
- Address[] expectedCc = InternetAddress.parse("bb@oceania, obrien@miniluv");
- Address[] cc = message.getRecipients(RecipientType.CC);
- assert Arrays.equals(expectedCc, cc) : Arrays.asList(cc);
- // bcc - recipients undisclosed
- assertNull(message.getRecipients(RecipientType.BCC));
- // subject
- assertEquals("rectify " + newspaper, message.getSubject());
- // text
- assertEquals(newspaper + ' ' + date + ' ' + details, (String) message.getContent());
- }
+ for (WiserMessage wisMessage : wisMessages) {
+ Message message = wisMessage.getMimeMessage();
+ // from
+ Address[] from = message.getFrom();
+ assertEquals(1, from.length);
+ assertEquals("noreply(a)jbpm.org", from[0].toString());
+ // to
+ Address[] expectedTo = InternetAddress.parse(addressee);
+ Address[] to = message.getRecipients(RecipientType.TO);
+ assert Arrays.equals(expectedTo, to) : Arrays.asList(to);
+ // cc
+ Address[] expectedCc = InternetAddress.parse("bb@oceania, obrien@miniluv");
+ Address[] cc = message.getRecipients(RecipientType.CC);
+ assert Arrays.equals(expectedCc, cc) : Arrays.asList(cc);
+ // bcc - recipients undisclosed
+ assertNull(message.getRecipients(RecipientType.BCC));
+ // subject
+ assertEquals("rectify " + newspaper, message.getSubject());
+ // text
+ assertEquals(newspaper + ' ' + date + ' ' + details, (String) message.getContent());
}
- finally {
- wiser.stop();
- }
}
}
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/eventlistener/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/eventlistener/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/eventlistener/process.jpdl.xml 2009-05-23 10:38:45 UTC (rev 4875)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="AsyncEventListener" xmlns="http://jbpm.org/4.0/jpdl">
+
+ <start name="start" g="22,69,80,40">
+ <transition to="wait">
+ <mail continue="async">
+ <to addresses="you@yourcompany" />
+ <subject>hello</subject>
+ <text>hello</text>
+ </mail>
+ </transition>
+ </start>
+
+ <state name="wait"/>
+
+</process>
Property changes on: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/eventlistener/process.jpdl.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/inline/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/inline/process.jpdl.xml 2009-05-22 14:06:47 UTC (rev 4874)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/inline/process.jpdl.xml 2009-05-23 10:38:45 UTC (rev 4875)
@@ -2,11 +2,11 @@
<process name="InlineMail">
- <start>
+ <start g="20,25,80,40">
<transition to="send rectify note" />
</start>
- <mail name="send rectify note" language="juel">
+ <mail name="send rectify note" language="juel" g="99,25,115,45">
<to addresses="winston@minitrue" />
<cc users="bb" groups="innerparty" />
<bcc groups="thinkpol" />
@@ -27,6 +27,6 @@
<transition to="end" />
</mail>
- <state name="end" />
+ <state name="end" g="240,25,98,45"/>
</process>
\ No newline at end of file
Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/template/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/template/process.jpdl.xml 2009-05-22 14:06:47 UTC (rev 4874)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/template/process.jpdl.xml 2009-05-23 10:38:45 UTC (rev 4875)
@@ -1,15 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
-<process name="TemplateMail">
-
- <start>
- <transition to="send rectify note" />
- </start>
-
- <mail name="send rectify note" template="rectify-template">
- <transition to="end" />
- </mail>
-
- <state name="end" />
-
+<process name="TemplateMail" xmlns="http://jbpm.org/4.0/jpdl">
+
+ <start g="20,25,80,40">
+ <transition to="send rectify note"/>
+ </start>
+
+ <mail name="send rectify note"
+ template="rectify-template"
+ g="99,25,115,45">
+ <transition to="end"/>
+ </mail>
+
+ <state name="end" g="240,25,98,45"/>
+
</process>
\ No newline at end of file
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java 2009-05-22 14:06:47 UTC (rev 4874)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java 2009-05-23 10:38:45 UTC (rev 4875)
@@ -22,14 +22,15 @@
package org.jbpm.jpdl.internal.activity;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.List;
+import org.hibernate.LockMode;
+import org.hibernate.Session;
import org.jbpm.api.Execution;
import org.jbpm.api.JbpmException;
import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.api.env.Environment;
import org.jbpm.api.model.Activity;
-import org.jbpm.api.model.OpenExecution;
import org.jbpm.api.model.Transition;
import org.jbpm.pvm.internal.model.ExecutionImpl;
@@ -42,6 +43,7 @@
private static final long serialVersionUID = 1L;
int multiplicity = -1;
+ LockMode lockMode = LockMode.UPGRADE;
public void execute(ActivityExecution execution) {
execute((ExecutionImpl)execution);
@@ -60,6 +62,10 @@
execution.take(transition);
} else if (Execution.STATE_ACTIVE_CONCURRENT.equals(execution.getState())) {
+
+ // force version increment in the parent execution
+ Session session = Environment.getFromCurrent(Session.class);
+ session.lock(execution.getParent(), lockMode);
execution.setState(Execution.STATE_INACTIVE_JOIN);
execution.waitForSignal();
@@ -118,4 +124,11 @@
joinedExecution.end();
}
}
+
+ public void setMultiplicity(int multiplicity) {
+ this.multiplicity = multiplicity;
+ }
+ public void setLockMode(LockMode lockMode) {
+ this.lockMode = lockMode;
+ }
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinBinding.java 2009-05-22 14:06:47 UTC (rev 4874)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinBinding.java 2009-05-23 10:38:45 UTC (rev 4875)
@@ -21,6 +21,7 @@
*/
package org.jbpm.jpdl.internal.activity;
+import org.hibernate.LockMode;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
@@ -36,7 +37,29 @@
}
public Object parse(Element element, Parse parse, Parser parser) {
- return new JoinActivity();
+ JoinActivity joinActivity = new JoinActivity();
+
+ if (element.hasAttribute("multiplicicty")) {
+ String multiplicictyText = element.getAttribute("multiplicicty");
+ try {
+ int multiplicity = Integer.parseInt(multiplicictyText);
+ joinActivity.setMultiplicity(multiplicity);
+ } catch (NumberFormatException e) {
+ parse.addProblem("multiplicity "+multiplicictyText+" is not a valid integer", element);
+ }
+ }
+
+ if (element.hasAttribute("lockmode")) {
+ String lockModeText = element.getAttribute("lockmode");
+ LockMode lockMode = LockMode.parse(lockModeText.toUpperCase());
+ if (lockMode==null) {
+ parse.addProblem("lockmode "+lockModeText+" is not a valid lock mode", element);
+ } else {
+ joinActivity.setLockMode(lockMode);
+ }
+ }
+
+ return joinActivity;
}
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/MailActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/MailActivity.java 2009-05-22 14:06:47 UTC (rev 4874)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/MailActivity.java 2009-05-23 10:38:45 UTC (rev 4875)
@@ -39,7 +39,6 @@
private static final long serialVersionUID = 1L;
- @Override
void perform(OpenExecution execution) throws Exception {
Collection<Message> messages = mailProducer.produce(execution);
Environment.getFromCurrent(MailSession.class).send(messages);
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2009-05-22 14:06:47 UTC (rev 4874)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2009-05-23 10:38:45 UTC (rev 4875)
@@ -250,10 +250,12 @@
parseTransitions(nestedElement, activity, parse);
String continuationText = XmlUtil.attribute(nestedElement, "continue");
- if ("async".equals(continuationText)) {
- activity.setContinuation(Continuation.ASYNCHRONOUS);
- } else if ("exclusive".equals(continuationText)) {
- activity.setContinuation(Continuation.EXCLUSIVE);
+ if (continuationText!=null) {
+ if ("async".equals(continuationText)) {
+ activity.setContinuation(Continuation.ASYNCHRONOUS);
+ } else if ("exclusive".equals(continuationText)) {
+ activity.setContinuation(Continuation.EXCLUSIVE);
+ }
}
ActivityBehaviour activityBehaviour = (ActivityBehaviour) activityBinding.parse(nestedElement, parse, this);
@@ -338,18 +340,20 @@
}
}
- public void parseOnEvent(Element element, ObservableElementImpl scopeElement, String eventName, Parse parse) {
+ public void parseOnEvent(Element element, ObservableElementImpl observableElement, String eventName, Parse parse) {
if (eventName!=null) {
- EventImpl event = scopeElement.getEvent(eventName);
+ EventImpl event = observableElement.getEvent(eventName);
if (event==null) {
- event = scopeElement.createEvent(eventName);
+ event = observableElement.createEvent(eventName);
}
String continuationText = XmlUtil.attribute(element, "continue");
- if ("async".equals(continuationText)) {
- event.setContinuation(Continuation.ASYNCHRONOUS);
- } else if ("exclusive".equals(continuationText)) {
- event.setContinuation(Continuation.EXCLUSIVE);
+ if (continuationText!=null) {
+ if ("async".equals(continuationText)) {
+ event.setContinuation(Continuation.ASYNCHRONOUS);
+ } else if ("exclusive".equals(continuationText)) {
+ event.setContinuation(Continuation.EXCLUSIVE);
+ }
}
for (Element eventListenerElement: XmlUtil.elements(element)) {
@@ -359,15 +363,27 @@
EventListenerReference eventListenerReference = event.createEventListenerReference(eventListener);
continuationText = XmlUtil.attribute(eventListenerElement, "continue");
- if ("async".equals(continuationText)) {
- eventListenerReference.setContinuation(Continuation.ASYNCHRONOUS);
- } else if ("exclusive".equals(continuationText)) {
- eventListenerReference.setContinuation(Continuation.EXCLUSIVE);
+ if (continuationText!=null) {
+ if (observableElement instanceof ActivityImpl) {
+ if (observableElement.getName()==null) {
+ parse.addProblem("async continuation on event listener requires activity name", eventListenerElement);
+ }
+ } else if (observableElement instanceof TransitionImpl) {
+ TransitionImpl transition = (TransitionImpl) observableElement;
+ if (transition.getSource().getName()==null) {
+ parse.addProblem("async continuation on event listener requires name in the transition source activity", eventListenerElement);
+ }
+ }
+ if ("async".equals(continuationText)) {
+ eventListenerReference.setContinuation(Continuation.ASYNCHRONOUS);
+ } else if ("exclusive".equals(continuationText)) {
+ eventListenerReference.setContinuation(Continuation.EXCLUSIVE);
+ }
}
} else {
String tagName = XmlUtil.getTagLocalName(eventListenerElement);
- if ( ! ( (scopeElement instanceof TransitionImpl)
+ if ( ! ( (observableElement instanceof TransitionImpl)
&& ( "condition".equals(tagName)
|| "timer".equals(tagName)
)
Modified: jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.eventlisteners.xml
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.eventlisteners.xml 2009-05-22 14:06:47 UTC (rev 4874)
+++ jbpm4/trunk/modules/jpdl/src/main/resources/jbpm.jpdl.eventlisteners.xml 2009-05-23 10:38:45 UTC (rev 4875)
@@ -5,4 +5,5 @@
<eventlistener binding="org.jbpm.jpdl.internal.activity.HqlBinding" />
<eventlistener binding="org.jbpm.jpdl.internal.activity.SqlBinding" />
<eventlistener binding="org.jbpm.jpdl.internal.activity.ScriptBinding" />
+ <eventlistener binding="org.jbpm.jpdl.internal.activity.MailBinding" />
</eventlisteners>
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ActivityImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ActivityImpl.java 2009-05-22 14:06:47 UTC (rev 4874)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ActivityImpl.java 2009-05-23 10:38:45 UTC (rev 4875)
@@ -84,6 +84,7 @@
public TransitionImpl createOutgoingTransition() {
// create a new transition
TransitionImpl transition = new TransitionImpl();
+ transition.setProcessDefinition(processDefinition);
// wire it between the source and destination
addOutgoingTransition(transition);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListener.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListener.java 2009-05-22 14:06:47 UTC (rev 4874)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListener.java 2009-05-23 10:38:45 UTC (rev 4875)
@@ -25,7 +25,6 @@
import org.jbpm.api.model.ObservableElement;
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.job.MessageImpl;
-import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.model.EventImpl;
import org.jbpm.pvm.internal.model.EventListenerReference;
import org.jbpm.pvm.internal.model.ExecutionImpl;
@@ -82,7 +81,7 @@
}
public MessageImpl< ? > createAsyncMessage(ExecutionImpl execution) {
- return null;
+ return new ExecuteEventListenerMessage(execution, observableElement, event, eventListenerReference);
}
public String toString() {
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListenerMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListenerMessage.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListenerMessage.java 2009-05-23 10:38:45 UTC (rev 4875)
@@ -0,0 +1,99 @@
+/*
+ * 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.internal.model.op;
+
+import org.jbpm.api.env.Environment;
+import org.jbpm.api.listener.EventListener;
+import org.jbpm.api.model.ObservableElement;
+import org.jbpm.api.session.RepositorySession;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.EventImpl;
+import org.jbpm.pvm.internal.model.EventListenerReference;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ObservableElementImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.model.TransitionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExecuteEventListenerMessage extends MessageImpl<Object> {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String processDefinitionId;
+ protected String activityName;
+ protected Integer transitionIndex;
+ protected String eventName;
+ protected Integer eventListenerIndex;
+
+ public ExecuteEventListenerMessage() {
+ }
+
+ public ExecuteEventListenerMessage(ExecutionImpl execution, ObservableElement observableElement, EventImpl event, EventListenerReference eventListenerReference) {
+ super(execution);
+ if (observableElement instanceof ProcessDefinitionImpl) {
+ ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) observableElement;
+ processDefinitionId = processDefinition.getId();
+ } else if (observableElement instanceof ActivityImpl) {
+ ActivityImpl activity = (ActivityImpl) observableElement;
+ processDefinitionId = activity.getProcessDefinition().getId();
+ activityName = activity.getName();
+ } else if (observableElement instanceof TransitionImpl) {
+ TransitionImpl transition = (TransitionImpl) observableElement;
+ processDefinitionId = transition.getProcessDefinition().getId();
+ activityName = transition.getSource().getName();
+ transitionIndex = transition.getSource().getOutgoingTransitions().indexOf(transition);
+ }
+
+ eventName = event.getName();
+ eventListenerIndex = event.getListenerReferences().indexOf(eventListenerReference);
+ }
+
+ public Object execute(Environment environment) throws Exception {
+ ObservableElementImpl observableElement = null;
+
+ RepositorySession repositorySession = environment.get(RepositorySession.class);
+ ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) repositorySession.findProcessDefinitionById(processDefinitionId);
+ if (activityName!=null) {
+ ActivityImpl activity = processDefinition.findActivity(activityName);
+ if (transitionIndex!=null) {
+ TransitionImpl transition = (TransitionImpl) activity.getOutgoingTransitions().get(transitionIndex);
+ observableElement = transition;
+ } else {
+ observableElement = activity;
+ }
+ } else {
+ observableElement = processDefinition;
+ }
+
+ EventImpl event = observableElement.getEvent(eventName);
+ EventListenerReference eventListenerReference = event.getListenerReferences().get(eventListenerIndex);
+ EventListener eventListener = eventListenerReference.get();
+
+ eventListener.notify(execution);
+
+ return null;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteEventListenerMessage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml 2009-05-22 14:06:47 UTC (rev 4874)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml 2009-05-23 10:38:45 UTC (rev 4875)
@@ -231,18 +231,21 @@
index="IDX_JOB_CMDDESCR"/ -->
<subclass name="org.jbpm.pvm.internal.job.MessageImpl" discriminator-value="Msg">
- <subclass name="org.jbpm.pvm.internal.model.op.ExecuteActivityMessage" discriminator-value="ExeActivityMsg" />
- <subclass name="org.jbpm.pvm.internal.model.op.SignalMessage" discriminator-value="SignalMsg">
+ <subclass name="org.jbpm.pvm.internal.model.op.ExecuteActivityMessage" discriminator-value="ExeAct" />
+ <subclass name="org.jbpm.pvm.internal.model.op.SignalMessage" discriminator-value="Signal">
<property name="signalName" column="SIGNAL_" />
- <!-- many-to-one name="activity"
- column="NODE_"
- cascade="none"
- foreign-key="FK_JOB_NODE"/ -->
</subclass>
- <subclass name="org.jbpm.pvm.internal.model.op.TransitionEndActivityMessage" discriminator-value="TrEndActMsg" />
- <subclass name="org.jbpm.pvm.internal.model.op.TransitionTakeMessage" discriminator-value="TrTakeMsg" />
- <subclass name="org.jbpm.pvm.internal.model.op.TransitionStartActivityMessage" discriminator-value="TrStartActMsg" />
- <subclass name="org.jbpm.pvm.internal.job.CommandMessage" discriminator-value="CmdMsg" />
+ <subclass name="org.jbpm.pvm.internal.model.op.TransitionEndActivityMessage" discriminator-value="TrEndAct" />
+ <subclass name="org.jbpm.pvm.internal.model.op.TransitionTakeMessage" discriminator-value="TrTake" />
+ <subclass name="org.jbpm.pvm.internal.model.op.TransitionStartActivityMessage" discriminator-value="TrStartAct" />
+ <subclass name="org.jbpm.pvm.internal.model.op.ExecuteEventListenerMessage" discriminator-value="ExeEvtLst">
+ <property name="processDefinitionId" column="PROCDEF_" />
+ <property name="activityName" column="ACT_" />
+ <property name="transitionIndex" column="TRIDX_" />
+ <property name="eventName" column="EVENT_" />
+ <property name="eventListenerIndex" column="EVTLSTIDX_" />
+ </subclass>
+ <subclass name="org.jbpm.pvm.internal.job.CommandMessage" discriminator-value="Cmd" />
</subclass>
<subclass name="org.jbpm.pvm.internal.job.TimerImpl" discriminator-value="Timer">
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-05-22 14:06:47 UTC (rev 4874)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml 2009-05-23 10:38:45 UTC (rev 4875)
@@ -480,6 +480,41 @@
<para>With the <literal>fork</literal> and <literal>join</literal> activities,
concurrent paths of executions can be modeled.
</para>
+ <table><title><literal>join</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>multiplicity</literal></entry>
+ <entry>integer</entry>
+ <entry>nbr of incoming transitions</entry>
+ <entry>optional</entry>
+ <entry>The number of executions that should arrive in this join
+ before the join activates and push an execution out the single
+ outgoing transition of the join.
+ </entry>
+ </row>
+ <row>
+ <entry><literal>lockmode</literal></entry>
+ <entry>{none, read, upgrade, upgrade_nowait, write}</entry>
+ <entry>upgrade</entry>
+ <entry>optional</entry>
+ <entry>the hibernate lock mode applied on the parent execution to
+ prevent that 2 concurrent transactions see each other as not yet
+ arrived at the join, causing a process deadlock.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
<para>For example:</para>
<figure id="process.concurrency">
<title>The concurrency example process</title>
@@ -2213,7 +2248,7 @@
asynchronous message is committed and then processed, it will start a new transaction
and resume execution where it left off.
</para>
-- <table><title>Any activity attribute:</title>
+ <table><title>Attribute of any activity, <literal>transition</literal> or <literal>on</literal>:</title>
<tgroup cols="5" rowsep="1" colsep="1">
<thead>
<row>
@@ -2230,15 +2265,35 @@
<entry>{sync | async | exclusive}</entry>
<entry>sync</entry>
<entry>optional</entry>
- <entry>indicates if an asynchronous continuation should be performed
- before the activity is executed.
+ <entry><para>indicates if an asynchronous continuation should be performed
+ before the element is executed.</para>
</entry>
</row>
</tbody>
</tgroup>
</table>
+ <itemizedlist>
+ <listitem><emphasis role="bold">sync</emphasis> (default) keep executing
+ the element as part of the ongoing transaction.
+ </listitem>
+ <listitem><emphasis role="bold">async</emphasis> introduces an asynchronous
+ continuation (aka safe point).
+ The ongoing transaction is committed and the element is executed in a
+ new transaction. Transactional asynchronous messaging is used by the jBPM
+ implementation to achieve this.
+ </listitem>
+ <listitem><emphasis role="bold">exclusive</emphasis> introduces a asynchronous
+ continuation (aka safe point).
+ The ongoing transaction is committed and the element is executed in a
+ new transaction. Transactional asynchronous messaging is used by the jBPM
+ implementation to achieve this. Exclusive messages will not be processed
+ concurrently. The JobExecutor(s) will serialize all exclusive job
+ executions. This can be used to prevent optimistic locking failures in case
+ multiple, potentially conflicting jobs are scheduled in the same transaction.
+ </listitem>
+ </itemizedlist>
<para>Let's look at a couple of examples.</para>
-
+
<section id="asyncactivity">
<title>Async activity</title>
<figure id="process.async.activity">
@@ -2268,6 +2323,16 @@
<end name="end"/>
</process></programlisting>
+ <programlisting>public class Application {
+
+ public void generatePdf() {
+ // assume long automatic calculations here
+ }
+
+ public void calculatePrimes() {
+ // assume long automatic calculations here
+ }
+}</programlisting>
<programlisting>ProcessInstance processInstance =
executionService.startProcessInstanceByKey("AsyncActivity");
String processInstanceId = processInstance.getId();</programlisting>
@@ -2277,13 +2342,13 @@
</para>
<para>But with <literal>continue="async"</literal> the execution only
goes untill it is about to execute activity <literal>generate pdf</literal>. Then
- An asynchronous continuation message is send and the <literal>startProcessInstanceByKey</literal>
+ an asynchronous continuation message is send and the <literal>startProcessInstanceByKey</literal>
method returns.
</para>
- <para>In a normal configuration, the job executor will pick up the message and execute
- it. But for testing scenarios and for these examples we want to control
- when messages are executed so the job executor is not configured. Therefor
- we have to execute the jobs manually like this:
+ <para>In a normal configuration, the job executor will automatically pick up
+ the message and execute it. But for testing scenarios and for these examples we
+ want to control when messages are executed so the job executor is not configured.
+ Therefor we have to execute the jobs manually like this:
</para>
<programlisting>Job job = managementService.createJobQuery()
.processInstanceId(processInstanceId)
@@ -2297,6 +2362,91 @@
is executed, that transaction will run the execution till the end.
</para>
</section>
+
+ <section id="asyncfork">
+ <title>Async fork</title>
+ <figure id="process.async.fork">
+ <title>The async fork example process</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.async.fork.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting><process name="AsyncFork" xmlns="http://jbpm.org/4.0/jpdl">
+
+ <start >
+ <transition to="fork"/>
+ </start>
+
+ <fork >
+ <emphasis role="bold"><on event="end" continue="exclusive" /></emphasis>
+ <transition />
+ <transition />
+ </fork>
+
+ <java class="org.jbpm.examples.async.fork.Application" >
+ <transition />
+ </java>
+
+ <java class="org.jbpm.examples.async.fork.Application" >
+ <transition />
+ </java>
+
+ <join >
+ <transition to="end"/>
+ </join>
+
+ <end />
+
+</process></programlisting>
+ <programlisting>public class Application {
+
+ public void shipGoods() {
+ // assume automatic calculations here
+ }
+
+ public void sendBill() {
+ // assume automatic calculations here
+ }
+}</programlisting>
+ <para>By placing the asynchronous continuation on the <literal>end</literal>
+ event of the fork (<literal><on event="end" continue="exclusive" /></literal>),
+ each forked execution that takes a transition out of the
+ fork will be continued asynchronously.
+ </para>
+ <para>Value <literal>exclusive</literal> was selected to serialize the executions of
+ the 2 asynchonous continuation jobs resulting from the fork. The respective transactions
+ that will execute activities <literal>ship goods</literal>
+ and <literal>send bill</literal> will both arrive at the join. At the join, both
+ transactions will synchronize on the same execution (read: update the same execution
+ row in the DB), resulting in a potential optimistic locking failure.
+ </para>
+ <programlisting>ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncFork");
+String processInstanceId = processInstance.getId();
+
+List<Job> jobs = managementService.createJobQuery()
+ .processInstanceId(processInstanceId)
+ .list();
+
+assertEquals(2, jobs.size());
+
+Job job = jobs.get(0);
+
+// here we simulate execution of the job,
+// which is normally done by the job executor
+managementService.executeJob(job.getDbid());
+
+job = jobs.get(1);
+
+// here we simulate execution of the job,
+// which is normally done by the job executor
+managementService.executeJob(job.getDbid());
+
+Date endTime = historyService
+ .createHistoryProcessInstanceQuery()
+ .processInstanceId(processInstance.getId())
+ .uniqueResult()
+ .getEndTime();
+
+assertNotNull(endTime);</programlisting>
+ </section>
</section>
<section id="timer">
16 years, 11 months
JBoss JBPM SVN: r4874 - in jbpm4/trunk/modules: api/src/main/java/org/jbpm/api/session and 7 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-05-22 10:06:47 -0400 (Fri, 22 May 2009)
New Revision: 4874
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/OpenExecution.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/session/TimerSession.java
jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/EjbTimerSession.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TimerSessionBinding.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
Log:
JBPM-2256 removed relation ScopeInstanceImpl.timers. This was a bug that popped up in context of async fork
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/OpenExecution.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/OpenExecution.java 2009-05-22 10:03:00 UTC (rev 4873)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/OpenExecution.java 2009-05-22 14:06:47 UTC (rev 4874)
@@ -113,14 +113,6 @@
* the given type name. */
void createVariable(String key, Object value, String typeName);
- // timer access /////////////////////////////////////////////////////////////
-
- /** indicates if this execution scope has timers */
- boolean hasTimers();
-
- /** timers for this execution scope */
- Set<Timer> getTimers();
-
// priority /////////////////////////////////////////////////////////////////
/** setter for the priority. The default priority is 0, which means
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/session/TimerSession.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/session/TimerSession.java 2009-05-22 10:03:00 UTC (rev 4873)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/session/TimerSession.java 2009-05-22 14:06:47 UTC (rev 4874)
@@ -21,6 +21,9 @@
*/
package org.jbpm.api.session;
+import java.util.List;
+
+import org.jbpm.api.Execution;
import org.jbpm.api.job.Timer;
/**
@@ -28,28 +31,30 @@
*/
public interface TimerSession {
- /**
- * Schedule the execution of a timer.
- * @param timerImpl the timer to be executed.
- * @throws IllegalArgumentException if the timer is null
- * or if its activity is null or if its dueDate is null
- * or if its dueDate is negative or if its dueDate is past
- * or if its dueDate is equals to Long.MAX_VALUE
- */
- public void schedule(Timer timer);
+ /** Schedule the execution of a timer.
+ *
+ * @param timerImpl
+ * the timer to be executed.
+ * @throws IllegalArgumentException
+ * if the timer is null or if its activity is null or if its dueDate
+ * is null or if its dueDate is negative or if its dueDate is past
+ * or if its dueDate is equals to Long.MAX_VALUE
+ */
+ void schedule(Timer timer);
- /**
- * Cancels a timer.
- * <br />
- * If a transaction is in progress, the cancellation will be effective
- * at the end of the transaction.
- * If the timer has been created in the same transaction or
- * if there is no transaction, the cancellation is immediately effective.
- * <br />
- * If the timer is executing when the cancellation becomes effective,
- * the execution in progress will not be stopped.
- * @param timerImpl the timer to be cancelled.
- */
- public void cancel(Timer timer);
-
+ /** Cancels a timer. <br />
+ * If a transaction is in progress, the cancellation will be effective at the
+ * end of the transaction. If the timer has been created in the same
+ * transaction or if there is no transaction, the cancellation is immediately
+ * effective. <br />
+ * If the timer is executing when the cancellation becomes effective, the
+ * execution in progress will not be stopped.
+ *
+ * @param timerImpl
+ * the timer to be cancelled.
+ */
+ void cancel(Timer timer);
+
+ /** retrieve all the outstanding timers associated for the given execution */
+ List<Timer> findTimersByExecution(Execution execution);
}
Modified: jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/EjbTimerSession.java
===================================================================
--- jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/EjbTimerSession.java 2009-05-22 10:03:00 UTC (rev 4873)
+++ jbpm4/trunk/modules/enterprise/src/main/java/org/jbpm/enterprise/internal/ejb/EjbTimerSession.java 2009-05-22 14:06:47 UTC (rev 4874)
@@ -21,9 +21,12 @@
*/
package org.jbpm.enterprise.internal.ejb;
+import java.util.List;
+
import javax.ejb.FinderException;
import javax.ejb.RemoveException;
+import org.jbpm.api.Execution;
import org.jbpm.api.JbpmException;
import org.jbpm.api.env.Environment;
import org.jbpm.api.job.Timer;
@@ -78,4 +81,8 @@
log.error("could not remove bean for timer " + timer, e);
}
}
+
+ public List<Timer> findTimersByExecution(Execution execution) {
+ return null;
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java 2009-05-22 10:03:00 UTC (rev 4873)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/hibernate/HibernatePvmDbSession.java 2009-05-22 14:06:47 UTC (rev 4874)
@@ -30,15 +30,18 @@
import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.client.ClientExecution;
import org.jbpm.api.client.ClientProcessDefinition;
+import org.jbpm.api.env.Environment;
import org.jbpm.api.history.HistoryProcessInstance;
import org.jbpm.api.job.Job;
import org.jbpm.api.job.Message;
import org.jbpm.api.job.Timer;
import org.jbpm.api.session.PvmDbSession;
+import org.jbpm.api.session.TimerSession;
import org.jbpm.api.task.Task;
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.history.model.HistoryProcessInstanceImpl;
import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.job.TimerImpl;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.query.HistoryProcessInstanceQueryImpl;
import org.jbpm.pvm.internal.svc.DefaultCommandService;
@@ -246,15 +249,21 @@
}
}
- ExecutionImpl processInstance = (ExecutionImpl) findExecutionById(processInstanceId);
-
- // delete remaining tasks for this process instance
- List<TaskImpl> tasks = findTasks(processInstanceId);
- for (TaskImpl task: tasks) {
- session.delete(task);
- }
+ ExecutionImpl processInstance = (ExecutionImpl) findProcessInstanceById(processInstanceId);
+ if (processInstance!=null) {
+ // delete remaining tasks for this process instance
+ List<TaskImpl> tasks = findTasks(processInstanceId);
+ for (TaskImpl task: tasks) {
+ session.delete(task);
+ }
- if (processInstance!=null) {
+ // delete remaining jobs for this process instance
+ // TODO JBPM-
+ List<JobImpl> jobs = findJobs(processInstanceId);
+ for (JobImpl job: jobs) {
+ session.delete(job);
+ }
+
if (log.isDebugEnabled()) {
log.debug("deleting process instance "+processInstanceId);
}
@@ -322,7 +331,7 @@
}
}
- private List<TaskImpl> findTasks(String processInstanceId) {
+ List<TaskImpl> findTasks(String processInstanceId) {
Query query = session.createQuery(
"select task " +
"from "+TaskImpl.class.getName()+" as task " +
@@ -332,6 +341,16 @@
return query.list();
}
+ List<JobImpl> findJobs(String processInstanceId) {
+ Query query = session.createQuery(
+ "select job " +
+ "from "+JobImpl.class.getName()+" as job " +
+ "where job.execution.processInstance.id = :processInstanceId"
+ );
+ query.setString("processInstanceId", processInstanceId);
+ return query.list();
+ }
+
/** see if hibernate knows about the history class */
public boolean isHistoryEnabled() {
ClassMetadata historyHibernateMetadata = session.getSessionFactory().getClassMetadata(HistoryProcessInstanceImpl.class);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java 2009-05-22 10:03:00 UTC (rev 4873)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/job/TimerImpl.java 2009-05-22 14:06:47 UTC (rev 4874)
@@ -29,6 +29,7 @@
import org.jbpm.api.env.Transaction;
import org.jbpm.api.job.Timer;
import org.jbpm.api.model.ObservableElement;
+import org.jbpm.api.session.TimerSession;
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.cal.BusinessCalendar;
import org.jbpm.pvm.internal.cal.Duration;
@@ -62,6 +63,11 @@
public TimerImpl() {
}
+
+ public void schedule() {
+ TimerSession timerSession = Environment.getFromCurrent(TimerSession.class);
+ timerSession.schedule(this);
+ }
public void setDueDateDescription(String dueDateDescription) {
Duration duration = new Duration(dueDateDescription);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java 2009-05-22 10:03:00 UTC (rev 4873)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTimerSession.java 2009-05-22 14:06:47 UTC (rev 4874)
@@ -13,11 +13,17 @@
**/
package org.jbpm.pvm.internal.jobexecutor;
+import java.util.List;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.jbpm.api.Execution;
import org.jbpm.api.JbpmException;
import org.jbpm.api.env.Transaction;
import org.jbpm.api.job.Timer;
import org.jbpm.api.session.TimerSession;
import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.job.TimerImpl;
/**
* Timers created with this service are committed at the end of the transaction,
@@ -37,14 +43,14 @@
JobExecutor jobExecutor;
/* injected */
- JobDbSession jobDbSession;
+ Session session;
boolean jobExecutorNotificationScheduled = false;
public void schedule(Timer timer) {
log.debug("scheduling " + timer);
validate(timer);
- jobDbSession.save(timer);
+ session.save(timer);
if ( (!jobExecutorNotificationScheduled)
&& (jobExecutor!=null)
) {
@@ -70,9 +76,19 @@
public void cancel(Timer timer) {
log.debug("canceling " + timer);
if (timer != null) {
- jobDbSession.delete(timer);
+ session.delete(timer);
} else {
throw new JbpmException("timer is null");
}
}
+
+ public List<Timer> findTimersByExecution(Execution execution) {
+ Query query = session.createQuery(
+ "select timer " +
+ "from "+TimerImpl.class.getName()+" timer " +
+ "where timer.execution = :execution"
+ );
+ query.setEntity("execution", execution);
+ return query.list();
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-05-22 10:03:00 UTC (rev 4873)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-05-22 14:06:47 UTC (rev 4874)
@@ -43,6 +43,7 @@
import org.jbpm.api.cmd.CommandService;
import org.jbpm.api.env.Environment;
import org.jbpm.api.env.Transaction;
+import org.jbpm.api.job.Timer;
import org.jbpm.api.listener.EventListenerExecution;
import org.jbpm.api.model.Activity;
import org.jbpm.api.model.Comment;
@@ -52,6 +53,7 @@
import org.jbpm.api.model.Transition;
import org.jbpm.api.session.MessageSession;
import org.jbpm.api.session.RepositorySession;
+import org.jbpm.api.session.TimerSession;
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.hibernate.HibernatePvmDbSession;
import org.jbpm.pvm.internal.history.HistoryEvent;
@@ -271,6 +273,19 @@
return parent;
}
+
+ protected void destroyTimers(CompositeElementImpl scope) {
+ TimerSession timerSession = Environment.getFromCurrent(TimerSession.class, false);
+ if (timerSession!=null) {
+ log.debug("destroying timers of "+this);
+ List<Timer> timers = timerSession.findTimersByExecution(this);
+ for (Timer timer: timers) {
+ timerSession.cancel(timer);
+ }
+ }
+ }
+
+
// basic object methods /////////////////////////////////////////////////////
public String toString() {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java 2009-05-22 10:03:00 UTC (rev 4873)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java 2009-05-22 14:06:47 UTC (rev 4874)
@@ -22,9 +22,7 @@
package org.jbpm.pvm.internal.model;
import java.io.Serializable;
-import java.util.Date;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -34,8 +32,6 @@
import org.jbpm.api.Execution;
import org.jbpm.api.JbpmException;
import org.jbpm.api.env.Environment;
-import org.jbpm.api.job.Timer;
-import org.jbpm.api.session.TimerSession;
import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.job.TimerImpl;
import org.jbpm.pvm.internal.type.Converter;
@@ -59,8 +55,6 @@
protected boolean hasVariables;
protected Map<String, Variable> variables;
- protected boolean hasTimers;
- protected Set<TimerImpl> timers;
protected String state;
protected String suspendHistoryState;
@@ -267,121 +261,55 @@
// timers ///////////////////////////////////////////////////////////////////
- protected void initializeTimers(ScopeElementImpl scope) {
- // initialize the timers
- Set<TimerDefinitionImpl> timerDefinitions = scope.getTimerDefinitions();
- if (!timerDefinitions.isEmpty()) {
- timers = new HashSet<TimerImpl>();
- for (TimerDefinitionImpl timerDefinition: timerDefinitions) {
- createTimer(
- timerDefinition.getEventName(),
- timerDefinition.getSignalName(),
- timerDefinition.getDueDateDescription(),
- timerDefinition.getDueDate(),
- timerDefinition.getRepeat(),
- timerDefinition.isExclusive(),
- timerDefinition.getRetries()
- );
- }
- }
+ protected TimerImpl newTimer() {
+ return new TimerImpl();
}
-
- protected void destroyTimers(CompositeElementImpl scope) {
- log.debug("destroying timers of "+toString());
- if (hasTimers && timers!=null && !timers.isEmpty()) {
- // get the TimerSession from the environment
- Environment environment = Environment.getCurrent();
- if (environment==null) {
- throw new JbpmException("non environment for initializing timers");
- }
- TimerSession timerSession = environment.get(TimerSession.class);
- if (timerSession==null) {
- throw new JbpmException("no TimerSession in environment for initializing timers");
- }
- for (Timer timer : timers) {
- timerSession.cancel(timer);
- }
- timers.clear();
- hasTimers = false;
- }
+
+ public TimerImpl createTimer() {
+ return createTimer(null);
}
- public void createTimer(String eventName, String signalName, String dueDateDescription) {
- createTimer(eventName, signalName, dueDateDescription, null, null, null, null);
- }
-
- public void createTimer(String eventName, String signalName, String dueDateDescription, String repeat) {
- createTimer(eventName, signalName, dueDateDescription, null, repeat, null, null);
- }
-
- public void createTimer(String eventName, String signalName, String dueDateDescription, Date dueDate, String repeat, Boolean isExclusive, Integer retries) {
- if ( (eventName==null)
- && (signalName==null)
- ) {
- throw new JbpmException("no event or signal specified");
- }
+ public TimerImpl createTimer(TimerDefinitionImpl timerDefinition) {
if (log.isDebugEnabled()) {
log.debug("creating timer on "+this.toString());
}
-
- // instantiate the timer
- TimerImpl timer = instantiateTimer();
- // create the bidirectional reference
+
+ TimerImpl timer = newTimer();
timer.setExecution(getTimerExecution());
- timers.add(timer);
- hasTimers = true;
- // setInverseReference(timerImpl);
- // initialise all the timer properties
- timer.setEventName(eventName);
- timer.setSignalName(signalName);
- if (dueDate!=null) {
- timer.setDueDate(dueDate);
- } else {
- timer.setDueDateDescription(dueDateDescription);
+ if (timerDefinition!=null) {
+ timer.setEventName(timerDefinition.getEventName());
+ timer.setSignalName(timerDefinition.getSignalName());
+ timer.setDueDate(timerDefinition.getDueDate());
+ timer.setDueDateDescription(timerDefinition.getDueDateDescription());
+ Boolean isExclusive = timerDefinition.isExclusive();
+ if (isExclusive!=null) {
+ timer.setExclusive(isExclusive);
+ }
+ Integer retries = timerDefinition.getRetries();
+ if (retries!=null) {
+ timer.setRetries(retries);
+ }
+ timer.setRepeat(timerDefinition.getRepeat());
}
- // the if is added to keep the original default
- if (isExclusive!=null) {
- timer.setExclusive(isExclusive);
- }
-
- // the if is added to keep the original default
- if (retries!=null) {
- timer.setRetries(retries);
- }
+ return timer;
+ }
- // the if is added to keep the original default
- if (repeat!=null) {
- timer.setRepeat(repeat);
+ protected void initializeTimers(ScopeElementImpl scope) {
+ // initialize the timers
+ Set<TimerDefinitionImpl> timerDefinitions = scope.getTimerDefinitions();
+ if (!timerDefinitions.isEmpty()) {
+ for (TimerDefinitionImpl timerDefinition: timerDefinitions) {
+ TimerImpl timer = createTimer(timerDefinition);
+ timer.schedule();
+ }
}
-
- // get the TimerSession from the environment
- Environment environment = Environment.getCurrent();
- if (environment==null) {
- throw new JbpmException("non environment for initializing timers");
- }
- TimerSession timerSession = environment.get(TimerSession.class);
- if (timerSession==null) {
- throw new JbpmException("no TimerSession in environment for initializing timers");
- }
-
- // schedule the timer with the TimerSession
- timerSession.schedule(timer);
}
- public boolean hasTimers() {
- return hasTimers;
+ protected void destroyTimers(CompositeElementImpl scope) {
}
- public Set<Timer> getTimers() {
- return (Set) timers;
- }
-
- protected TimerImpl instantiateTimer() {
- return new TimerImpl();
- }
-
// state ////////////////////////////////////////////////////////////////////
/** @see Execution#suspend() */
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TimerSessionBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TimerSessionBinding.java 2009-05-22 10:03:00 UTC (rev 4873)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TimerSessionBinding.java 2009-05-22 14:06:47 UTC (rev 4874)
@@ -21,8 +21,8 @@
*/
package org.jbpm.pvm.internal.wire.binding;
+import org.hibernate.Session;
import org.jbpm.api.session.TimerSession;
-import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
import org.jbpm.pvm.internal.jobexecutor.JobExecutorTimerSession;
import org.jbpm.pvm.internal.util.XmlUtil;
@@ -61,7 +61,7 @@
// inject fields
objectDescriptor.addInjection("transaction", new TransactionRefDescriptor());
objectDescriptor.addInjection("jobExecutor", new EnvDescriptor(JobExecutor.class));
- objectDescriptor.addInjection("jobDbSession", new ContextTypeRefDescriptor(JobDbSession.class));
+ objectDescriptor.addInjection("session", new ContextTypeRefDescriptor(Session.class));
}
return objectDescriptor;
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml 2009-05-22 10:03:00 UTC (rev 4873)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.execution.hbm.xml 2009-05-22 14:06:47 UTC (rev 4874)
@@ -43,15 +43,6 @@
<one-to-many class="org.jbpm.pvm.internal.type.Variable" />
</map>
- <property name="hasTimers" column="HASTIMERS_" />
- <set name="timers"
- cascade="all-delete-orphan">
- <key foreign-key="FK_TMR_EXECUTION">
- <column name="EXECUTION_" />
- </key>
- <one-to-many class="org.jbpm.pvm.internal.job.TimerImpl" />
- </set>
-
<property name="name" column="NAME_" />
<property name="key" column="KEY_" />
<property name="id" column="ID_" unique="true" />
16 years, 11 months
JBoss JBPM SVN: r4873 - in jbpm4/branches/jimma/modules/migration/src: main/java/org/jbpm/jpdl/internal/convert/util and 2 other directories.
by do-not-reply@jboss.org
Author: jim.ma
Date: 2009-05-22 06:03:00 -0400 (Fri, 22 May 2009)
New Revision: 4873
Added:
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/DecisionConverter.java
jbpm4/branches/jimma/modules/migration/src/test/resources/testDecision.xml
Modified:
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TransitionConverter.java
jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java
Log:
Added DecisionConverter
Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java 2009-05-22 09:58:21 UTC (rev 4872)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java 2009-05-22 10:03:00 UTC (rev 4873)
@@ -21,6 +21,15 @@
*/
package org.jbpm.jpdl.internal.convert;
+import static org.jbpm.graph.def.Node.NodeType.StartState;
+import static org.jbpm.graph.def.Node.NodeType.State;
+import static org.jbpm.graph.def.Node.NodeType.Decision;
+import static org.jbpm.graph.def.Node.NodeType.EndState;
+import static org.jbpm.graph.def.Node.NodeType.Fork;
+import static org.jbpm.graph.def.Node.NodeType.Join;
+import static org.jbpm.graph.def.Node.NodeType.Node;
+import static org.jbpm.graph.def.Node.NodeType.Task;
+
import java.net.URL;
import java.util.Iterator;
import java.util.Map;
@@ -34,6 +43,7 @@
import org.jbpm.graph.node.StartState;
import org.jbpm.graph.node.State;
import org.jbpm.graph.node.TaskNode;
+import org.jbpm.jpdl.internal.convert.util.DecisionConverter;
import org.jbpm.jpdl.internal.convert.util.EndStateConverter;
import org.jbpm.jpdl.internal.convert.util.ForkConverter;
import org.jbpm.jpdl.internal.convert.util.JoinConverter;
@@ -82,37 +92,48 @@
}
}
for (Node node : def.getNodes()) {
- // map start state node
- if (node.getNodeType().equals(Node.NodeType.StartState)) {
- StartState jpdl3start = (StartState) node;
+ Node.NodeType nodeType = node.getNodeType();
+ switch(node.getNodeType()) {
+ case StartState :
+ org.jbpm.graph.node.StartState jpdl3start = ( org.jbpm.graph.node.StartState) node;
Process.Start start = StartStateConverter.run(jpdl3start);
process.getSwimlaneAndOnAndTimer().add(start);
- } else if (node.getNodeType().equals(Node.NodeType.State)) {
- State jpdl3state = (State) node;
+ break;
+ case State:
+ org.jbpm.graph.node.State jpdl3state = (org.jbpm.graph.node.State) node;
Process.State state = StateConverter.run(jpdl3state);
process.getSwimlaneAndOnAndTimer().add(state);
- } else if (node.getNodeType().equals(Node.NodeType.EndState)) {
- EndState jpdl3end = (EndState) node;
+ break;
+ case EndState:
+ org.jbpm.graph.node.EndState jpdl3end = (org.jbpm.graph.node.EndState) node;
Process.End end = EndStateConverter.run(jpdl3end);
process.getSwimlaneAndOnAndTimer().add(end);
- } else if (node.getNodeType().equals(Node.NodeType.Task)) {
+ break;
+ case Task:
//TaskNode
if (node instanceof TaskNode) {
- TaskNode taskNode = (TaskNode)node;
+ org.jbpm.graph.node.TaskNode taskNode = (org.jbpm.graph.node.TaskNode)node;
Set<Process.Task> tasks = TaskNodeConverter.run(taskNode);
process.getSwimlaneAndOnAndTimer().addAll(tasks);
- }
- } else if (node.getNodeType().equals(Node.NodeType.Fork)) {
- Fork fork = (Fork)node;
+ }
+ break;
+ case Fork:
+ org.jbpm.graph.node.Fork fork = (org.jbpm.graph.node.Fork)node;
process.getSwimlaneAndOnAndTimer().add(ForkConverter.run(fork));
- } else if (node.getNodeType().equals(Node.NodeType.Join)) {
- Join join = (Join)node;
+ break;
+ case Join:
+ org.jbpm.graph.node.Join join = (org.jbpm.graph.node.Join)node;
process.getSwimlaneAndOnAndTimer().add(JoinConverter.run(join));
- } else if (node.getNodeType().equals(Node.NodeType.Node)) {
- Node tmpNode = (Node)node;
+ break;
+ case Node:
+ org.jbpm.graph.def.Node tmpNode = (org.jbpm.graph.def.Node)node;
process.getSwimlaneAndOnAndTimer().add(NodeConverter.run(tmpNode));
+ break;
+ case Decision :
+ org.jbpm.graph.node.Decision decision = (org.jbpm.graph.node.Decision)node;
+ process.getSwimlaneAndOnAndTimer().add(DecisionConverter.run(decision));
}
-
+
}
return process;
}
Added: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/DecisionConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/DecisionConverter.java (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/DecisionConverter.java 2009-05-22 10:03:00 UTC (rev 4873)
@@ -0,0 +1,41 @@
+/*
+ * 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.jpdl.internal.convert.util;
+
+import org.jbpm.graph.def.Transition;
+import org.jbpm.graph.node.Decision;
+import org.jbpm.jpdl4.model.Process;
+
+public class DecisionConverter {
+ public static Process.Decision run(Decision node) {
+ Process.Decision result = new Process.Decision();
+ result.setName(node.getName());
+ //TODO: talk to Tom to find out if we should support separate DecisionCondition's
+ //node.getDecisionConditions()
+ for (Transition trans : node.getLeavingTransitions()) {
+ result.getTransition().add(TransitionConverter.run(trans, Process.Decision.Transition.class));
+ }
+
+ return result;
+ }
+
+}
Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TransitionConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TransitionConverter.java 2009-05-22 09:58:21 UTC (rev 4872)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TransitionConverter.java 2009-05-22 10:03:00 UTC (rev 4873)
@@ -30,7 +30,9 @@
import org.jbpm.graph.def.Transition;
import org.jbpm.jpdl4.model.JavaType;
import org.jbpm.jpdl4.model.ObjectFactory;
+import org.jbpm.jpdl4.model.Process;
import org.jbpm.jpdl4.model.TransitionType;
+import org.jbpm.jpdl4.model.Process.Decision.Transition.Condition;
public class TransitionConverter {
public static ObjectFactory objectFactory = new ObjectFactory();
@@ -41,6 +43,16 @@
} catch (Exception e) {
}
+
+ if (transType instanceof Process.Decision.Transition) {
+ Process.Decision.Transition decTrans = (Process.Decision.Transition)transType;
+ if (transition.getCondition() != null) {
+ Condition condition = new Condition();
+ condition.setExpr(transition.getCondition());
+ decTrans.getCondition().add(condition);
+ }
+ }
+
// get the actions
if (transition.getEvents() != null) {
Iterator ite = transition.getEvents().entrySet().iterator();
Modified: jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java 2009-05-22 09:58:21 UTC (rev 4872)
+++ jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java 2009-05-22 10:03:00 UTC (rev 4873)
@@ -27,11 +27,9 @@
import org.jbpm.api.Problem;
import org.jbpm.jpdl.internal.xml.JpdlParser;
import org.junit.Assert;
-import org.junit.Ignore;
import org.junit.Test;
public class JpdlConverterTest {
-
@Test
public void runSimpleProcessFile() throws Exception {
testConvert("simple.xml");
@@ -48,6 +46,13 @@
}
+ @Test
+ public void testDescision() throws Exception {
+ testConvert("testDecision.xml");
+ }
+
+
+
public void testConvert(String resourcefile) throws Exception {
URL url = getClass().getClassLoader().getResource(resourcefile);
ConverterContext context = new ConverterContext();
@@ -58,9 +63,11 @@
Jpdl4Writer writer = new Jpdl4Writer();
java.io.ByteArrayOutputStream bout = new java.io.ByteArrayOutputStream();
writer.write(process, bout, false);
-
+
+
//Validate it with Jpdl4Parser
String jpdl4xml = new String(bout.toByteArray());
+
List<Problem> problems = new JpdlParser().createParse().setString(jpdl4xml).execute().getProblems();
Assert.assertEquals(problems.toString(), 0, problems.size());
}
Added: jbpm4/branches/jimma/modules/migration/src/test/resources/testDecision.xml
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/resources/testDecision.xml (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/test/resources/testDecision.xml 2009-05-22 10:03:00 UTC (rev 4873)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process-definition
+ xmlns="urn:jbpm.org:jpdl-3.2"
+ name="decision process">
+ <start-state name="start">
+ <transition name="to_state" to="make_decision">
+ <action name="action" class="com.sample.action.MessageActionHandler">
+ </action>
+ </transition>
+ </start-state>
+
+ <decision name="make_decision">
+ <transition to="second">
+ <condition>a=="OKOK"</condition>
+ </transition>
+ <transition to="second">
+ <condition>a=="NOK"</condition>
+ </transition>
+ </decision>
+
+ <state name="second">
+ <transition name="to_end" to="end">
+ <action name="action" class="com.sample.action.MessageActionHandler">
+ <message>About to finish!</message>
+ </action>
+ </transition>
+ </state>
+ <end-state name="end"></end-state>
+</process-definition>
16 years, 11 months
JBoss JBPM SVN: r4872 - in jbpm4/trunk: modules/api/src/main/java/org/jbpm/api and 17 other directories.
by do-not-reply@jboss.org
Author: ainze
Date: 2009-05-22 05:58:21 -0400 (Fri, 22 May 2009)
New Revision: 4872
Added:
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/test/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/test/spring/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/test/spring/applicationContext.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/test/spring/jbpm.cfg.xml
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/SpringContext.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionInterceptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SpringTransactionInterceptorBinding.java
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/test/
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/test/spring/
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/test/spring/applicationContext.xml
jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/test/spring/jbpm.cfg.xml
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/test/spring/
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/test/spring/applicationContext.xml
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/test/spring/jbpm.cfg.xml
Removed:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/HibernateSessionManager.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringCommandService.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringEnvironment.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringEnvironmentContext.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Configuration.java
jbpm4/trunk/modules/examples/pom.xml
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/SpringConfiguration.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/CommandTransactionCallback.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.wire.bindings.xml
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/Db.java
jbpm4/trunk/modules/test-db/pom.xml
jbpm4/trunk/pom.xml
Log:
spring integration - initial release
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Configuration.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Configuration.java 2009-05-22 09:23:50 UTC (rev 4871)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/Configuration.java 2009-05-22 09:58:21 UTC (rev 4872)
@@ -60,8 +60,8 @@
implementationClassNames = new HashMap<String, String>();
// null represents the default configuration (== the JbpmConfiguration)
implementationClassNames.put(null, "org.jbpm.pvm.internal.cfg.JbpmConfiguration");
+ implementationClassNames.put("spring-test", "org.jbpm.pvm.internal.cfg.SpringConfiguration");
// TODO
- // implementationClasses.put("spring", "org.jbpm.pvm.internal.cfg.SpringConfiguration");
// implementationClasses.put("mc", "org.jbpm.pvm.internal.cfg.McConfiguration");
// implementationClasses.put("programatic", "org.jbpm.pvm.internal.cfg.ProgramaticConfiguration");
}
Modified: jbpm4/trunk/modules/examples/pom.xml
===================================================================
--- jbpm4/trunk/modules/examples/pom.xml 2009-05-22 09:23:50 UTC (rev 4871)
+++ jbpm4/trunk/modules/examples/pom.xml 2009-05-22 09:58:21 UTC (rev 4872)
@@ -69,6 +69,12 @@
<groupId>org.subethamail</groupId>
<artifactId>subethasmtp-wiser</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/test/spring/applicationContext.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/test/spring/applicationContext.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/test/spring/applicationContext.xml 2009-05-22 09:58:21 UTC (rev 4872)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
+ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
+
+ <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
+ <property name="configLocation" value="classpath:jbpm.hibernate.cfg.xml" />
+ <!-- A best practice should be to keep split the config into multiple files
+ <property name="configLocations" value="hibernate.cfg.xml, hibernate.jbpm.cfg.xml" />
+ -->
+ </bean>
+
+ <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
+ <property name="sessionFactory" ref="sessionFactory" />
+ <property name="dataSource" ref="dataSource" />
+ </bean>
+
+ <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
+ <property name="url" value="jdbc:hsqldb:mem:." />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </bean>
+</beans>
\ No newline at end of file
Property changes on: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/test/spring/applicationContext.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/test/spring/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/test/spring/jbpm.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/test/spring/jbpm.cfg.xml 2009-05-22 09:58:21 UTC (rev 4872)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+ <import resource="jbpm.default.cfg.xml" />
+
+ <import resource="jbpm.jpdl.cfg.xml" />
+ <import resource="jbpm.identity.cfg.xml" />
+
+ <!-- Job executor is excluded for running the example test cases. -->
+ <!-- To enable timers and messages in production use, this should be included. -->
+ <!--
+ <import resource="jbpm.jobexecutor.cfg.xml" />
+ -->
+
+ <import resource="jbpm.mail.templates.examples.xml" />
+
+ <process-engine-context>
+ <command-service>
+ <retry-interceptor />
+ <environment-interceptor />
+ <spring-transaction-interceptor />
+ </command-service>
+ </process-engine-context>
+
+ <transaction-context>
+ <transaction />
+ <hibernate-session />
+ </transaction-context>
+
+</jbpm-configuration>
Property changes on: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/test/spring/jbpm.cfg.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/SpringConfiguration.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/SpringConfiguration.java 2009-05-22 09:23:50 UTC (rev 4871)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/SpringConfiguration.java 2009-05-22 09:58:21 UTC (rev 4872)
@@ -21,85 +21,147 @@
*/
package org.jbpm.pvm.internal.cfg;
-import java.util.HashSet;
+import java.io.IOException;
import java.util.List;
-import java.util.Set;
+import org.jbpm.api.ProcessEngine;
+import org.jbpm.api.env.Context;
import org.jbpm.api.env.Environment;
import org.jbpm.api.env.EnvironmentFactory;
import org.jbpm.api.env.WireObject;
-import org.jbpm.pvm.internal.spring.SpringEnvironment;
-import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.env.PvmEnvironment;
+import org.jbpm.pvm.internal.env.SpringContext;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.core.io.ClassPathResource;
-/** this environment factory will see only the singleton beans.
+/**
+ * this environment factory will see only the singleton beans.
*
- * The created {@link SpringEnvironment}s will see the prototype
- * beans and it will cache them.
- *
- * @author Tom Baeyens
+ * The created {@link SpringEnvironment}s will see the prototype beans and it
+ * will cache them.
+ *
+ * @author Andries Inze
*/
-public class SpringConfiguration implements EnvironmentFactory, ApplicationContextAware {
-
- // TODO pull up the common behaviour between this class and the SpringEnvironmentContext
-
- private static final long serialVersionUID = 1L;
-
- ApplicationContext applicationContext;
-
- public SpringEnvironment openEnvironment() {
- return new SpringEnvironment(this);
- }
+public class SpringConfiguration extends JbpmConfiguration implements
+ EnvironmentFactory, ProcessEngine, ApplicationContextAware {
- public boolean has(String key) {
- return applicationContext.isSingleton(key);
- }
+ private static final long serialVersionUID = 1L;
- public Object get(String key) {
- if (has(key)) {
- return applicationContext.getBean(key);
+ private ApplicationContext applicationContext;
+
+ private String jbpmConfigurationLocation;
+
+ /**
+ * Instantiates a new spring configuration.
+ */
+ public SpringConfiguration(String jbpmConfigurationLocation) {
+ try {
+ super.setInputStream(new ClassPathResource(
+ jbpmConfigurationLocation).getInputStream());
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
- return null;
- }
- public <T> T get(Class<T> type) {
- String name = ReflectUtil.getUnqualifiedClassName(type);
- name = name.substring(0, 1).toLowerCase() + name.substring(1);
- return (T) get(name);
- }
+ public SpringConfiguration() {
+ // By jbpmTestCase
+ }
- public Set<String> keys() {
- HashSet<String> keys = new HashSet<String>();
- for (String key : applicationContext.getBeanDefinitionNames()) {
- if (has(key)) {
- keys.add(key);
- }
+ @Override
+ public ProcessEngine buildProcessEngine() {
+ if (applicationContext == null) {
+ applicationContext = new ClassPathXmlApplicationContext(System
+ .getProperty("jbpm.test.cfg.applicationContext"));
+ }
+
+ return super.buildProcessEngine();
}
- return keys;
- }
-
- public ApplicationContext getApplicationContext() {
- return applicationContext;
- }
- public void setApplicationContext(ApplicationContext applicationContext) {
- this.applicationContext = applicationContext;
- }
+ /**
+ * {@inheritDoc)
-
- public void close() {
- }
+ */
+ @Override
+ public Environment openEnvironment(List<WireObject> txWireObjects) {
- public String getName() {
- return null;
- }
+ PvmEnvironment environment = new PvmEnvironment(this);
- public Object set(String key, Object value) {
- return null;
- }
+ // FIXME: All beneath should be a super call
- public Environment openEnvironment(List<WireObject> txWireObjects) {
- return null;
- }
+ // set the classloader
+ ClassLoader classLoader = processEngineWireContext.getClassLoader();
+ if (classLoader != null) {
+ environment.setClassLoader(classLoader);
+ }
+
+ // add the process-engine context
+ environment.addContext(new SpringContext(applicationContext));
+ environment.addContext(processEngineWireContext);
+
+ // add the transaction context
+ WireDefinition usedWireDefinition = transactionWireDefinition;
+ if (txWireObjects != null) {
+ usedWireDefinition = new WireDefinition(transactionWireDefinition,
+ txWireObjects);
+ }
+
+ WireContext transactionContext = new WireContext(usedWireDefinition,
+ Context.CONTEXTNAME_TRANSACTION, environment, true);
+ // add the environment block context to the environment
+ environment.addContext(transactionContext);
+
+ Environment.pushEnvironment(environment);
+ try {
+ // finish the creation of the environment wire context
+ transactionContext.create();
+
+ } catch (RuntimeException e) {
+ Environment.popEnvironment();
+ throw e;
+ }
+
+ // if all went well, return the created environment
+ return environment;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <T> T get(Class<T> type) {
+ String[] names = applicationContext.getBeanNamesForType(type);
+ if (names.length == 1) {
+ return (T) applicationContext.getBean(names[0]);
+ }
+
+ return super.get(type);
+ }
+
+ @Override
+ public Object get(String key) {
+ if (applicationContext.containsBean(key)) {
+ return applicationContext.getBean(key);
+ }
+
+ return super.get(key);
+ }
+
+ /**
+ * {@inheritDoc)
+
+ */
+ public void setApplicationContext(ApplicationContext applicationContext) {
+ this.applicationContext = applicationContext;
+ }
+
+ /**
+ * Gets the application context.
+ *
+ * @return the application context
+ */
+ public ApplicationContext getApplicationContext() {
+ return applicationContext;
+ }
}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/SpringContext.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/SpringContext.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/SpringContext.java 2009-05-22 09:58:21 UTC (rev 4872)
@@ -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.internal.env;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jbpm.api.env.Context;
+import org.springframework.context.ApplicationContext;
+
+/**
+ * @author Andries Inze
+ *
+ */
+public class SpringContext implements Context {
+
+ private ApplicationContext applicationContext;
+
+ public SpringContext(ApplicationContext applicationContext) {
+ this.applicationContext = applicationContext;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jbpm.api.env.Context#get(java.lang.String)
+ */
+ public Object get(String key) {
+ if (applicationContext.containsBean(key)) {
+ return applicationContext.getBean(key);
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T get(Class<T> type) {
+ String[] names = applicationContext.getBeanNamesForType(type);
+ if (names.length == 1) {
+ return (T) applicationContext.getBean(names[0]);
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jbpm.api.env.Context#getName()
+ */
+ public String getName() {
+ return "SpringContext";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jbpm.api.env.Context#has(java.lang.String)
+ */
+ public boolean has(String key) {
+ return applicationContext.containsBean(key);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jbpm.api.env.Context#keys()
+ */
+ public Set<String> keys() {
+ Set set = new HashSet<String>(Arrays.asList(applicationContext.getBeanDefinitionNames()));
+ return set;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jbpm.api.env.Context#set(java.lang.String, java.lang.Object)
+ */
+ public Object set(String key, Object value) {
+ throw new RuntimeException("Can't add to the spring context");
+ }
+
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/SpringContext.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/CommandTransactionCallback.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/CommandTransactionCallback.java 2009-05-22 09:23:50 UTC (rev 4871)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/CommandTransactionCallback.java 2009-05-22 09:58:21 UTC (rev 4872)
@@ -22,33 +22,31 @@
package org.jbpm.pvm.internal.spring;
import org.jbpm.api.cmd.Command;
-import org.jbpm.api.env.Environment;
-import org.jbpm.api.env.EnvironmentFactory;
+import org.jbpm.api.cmd.CommandService;
+import org.springframework.orm.hibernate3.HibernateTransactionManager;
+import org.springframework.orm.hibernate3.SessionFactoryUtils;
+import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallback;
+import org.springframework.util.Assert;
/**
- * @author Tom Baeyens
+ * @author Andries Inze
*/
public class CommandTransactionCallback<T> implements TransactionCallback {
-
- Command<T> command;
- EnvironmentFactory environmentFactory;
-
- public CommandTransactionCallback(Command<T> command, EnvironmentFactory environmentFactory) {
- this.command = command;
- this.environmentFactory = environmentFactory;
- }
- public T doInTransaction(TransactionStatus status) {
- Environment environment = environmentFactory.openEnvironment();
- try {
- return command.execute(environment);
- } catch (Exception e) {
- throw new RuntimeException("ooops", e);
- } finally {
- environment.close();
+ private Command<T> command;
+ private CommandService commandService;
+ private PlatformTransactionManager manager;
+
+ public CommandTransactionCallback(Command<T> command,
+ CommandService commandService, PlatformTransactionManager platformTransactionManager) {
+ this.command = command;
+ this.commandService = commandService;
+ this.manager = platformTransactionManager;
}
- }
+ public T doInTransaction(TransactionStatus status) {
+ return commandService.execute(command);
+ }
}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/HibernateSessionManager.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/HibernateSessionManager.java 2009-05-22 09:23:50 UTC (rev 4871)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/HibernateSessionManager.java 2009-05-22 09:58:21 UTC (rev 4872)
@@ -1,30 +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.internal.spring;
-
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
-
-/**
- * @author Tom Baeyens
- */
-public class HibernateSessionManager extends HibernateDaoSupport {
-}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringCommandService.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringCommandService.java 2009-05-22 09:23:50 UTC (rev 4871)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringCommandService.java 2009-05-22 09:58:21 UTC (rev 4872)
@@ -1,58 +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.internal.spring;
-
-import org.hibernate.Session;
-import org.jbpm.api.cmd.Command;
-import org.jbpm.api.cmd.CommandService;
-import org.jbpm.api.env.Environment;
-import org.jbpm.api.env.EnvironmentFactory;
-import org.springframework.orm.hibernate3.HibernateTransactionManager;
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
-import org.springframework.transaction.support.TransactionTemplate;
-
-
-/**
- * @author Tom Baeyens
- */
-public class SpringCommandService implements CommandService {
-
- TransactionTemplate transactionTemplate;
- EnvironmentFactory environmentFactory;
-
- public void setEnvironmentFactory(EnvironmentFactory environmentFactory) {
- this.environmentFactory = environmentFactory;
- }
-
- public void setTransactionManager(HibernateTransactionManager transactionManager) {
- this.transactionTemplate = new TransactionTemplate(transactionManager);
- }
-
- public <T> T execute(Command<T> command) {
- return (T) transactionTemplate.execute(
- new CommandTransactionCallback(command, environmentFactory)
- );
- }
-
-
-
-}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringEnvironment.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringEnvironment.java 2009-05-22 09:23:50 UTC (rev 4871)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringEnvironment.java 2009-05-22 09:58:21 UTC (rev 4872)
@@ -1,70 +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.internal.spring;
-
-import org.jbpm.api.env.EnvironmentFactory;
-import org.jbpm.pvm.internal.cfg.SpringConfiguration;
-import org.jbpm.pvm.internal.env.BasicEnvironment;
-import org.springframework.context.ApplicationContext;
-
-/** sees the prototype beans in the application context and
- * this environment will cache all the prototyped objects.
- *
- * @author Tom Baeyens
- */
-public class SpringEnvironment extends BasicEnvironment {
-
- private static final long serialVersionUID = 1L;
-
- protected ApplicationContext applicationContext;
-
- public SpringEnvironment(SpringConfiguration springConfiguration) {
- addContext(springConfiguration);
- addContext(new SpringEnvironmentContext(springConfiguration.getApplicationContext()));
- pushEnvironment(this);
- }
-
- public ClassLoader getClassLoader() {
- return null;
- }
-
- public EnvironmentFactory getEnvironmentFactory() {
- return null;
- }
-
- public Throwable getException() {
- return null;
- }
-
- public String getUserId() {
- return null;
- }
-
- public void setClassLoader(ClassLoader classLoader) {
- }
-
- public void setException(Throwable exception) {
- }
-
- public void setUserId(String userId) {
- }
-}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringEnvironmentContext.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringEnvironmentContext.java 2009-05-22 09:23:50 UTC (rev 4871)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/spring/SpringEnvironmentContext.java 2009-05-22 09:58:21 UTC (rev 4872)
@@ -1,98 +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.internal.spring;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.jbpm.api.env.Context;
-import org.jbpm.api.env.Environment;
-import org.jbpm.pvm.internal.util.ReflectUtil;
-import org.springframework.context.ApplicationContext;
-import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
-
-
-/**
- * @author Tom Baeyens
- */
-public class SpringEnvironmentContext implements Context {
-
- // TODO pull up the common behaviour between this class and the SpringEnvironmentFactory
-
- ApplicationContext applicationContext;
- Map<String, Object> cache = new HashMap<String, Object>();
-
- public SpringEnvironmentContext(ApplicationContext applicationContext) {
- this.applicationContext = applicationContext;
- }
-
- public boolean has(String key) {
- return applicationContext.isPrototype(key);
- }
-
- public Object get(String key) {
- if (cache.containsKey(key)) {
- return cache.get(key);
- }
- if (has(key)) {
- Object bean = applicationContext.getBean(key);
- // cache.put(key, bean);
- return bean;
- }
- return null;
- }
-
- public <T> T get(Class<T> type) {
- String name = ReflectUtil.getUnqualifiedClassName(type);
- name = name.substring(0, 1).toLowerCase() + name.substring(1);
- return (T) get(name);
- }
-
- public Set<String> keys() {
- HashSet<String> keys = new HashSet<String>();
- for (String key : applicationContext.getBeanDefinitionNames()) {
- if (has(key)) {
- keys.add(key);
- }
- }
- return keys;
- }
-
- public ApplicationContext getApplicationContext() {
- return applicationContext;
- }
-
- public void setApplicationContext(ApplicationContext applicationContext) {
- this.applicationContext = applicationContext;
- }
-
-
- public String getName() {
- return null;
- }
-
- public Object set(String key, Object value) {
- return null;
- }
-}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionInterceptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionInterceptor.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionInterceptor.java 2009-05-22 09:58:21 UTC (rev 4872)
@@ -0,0 +1,95 @@
+/*
+ * 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.internal.tx;
+
+import org.hibernate.Session;
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.api.env.Environment;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.spring.CommandTransactionCallback;
+import org.jbpm.pvm.internal.svc.Interceptor;
+import org.springframework.transaction.PlatformTransactionManager;
+import org.springframework.transaction.TransactionDefinition;
+import org.springframework.transaction.support.DefaultTransactionDefinition;
+import org.springframework.transaction.support.TransactionCallback;
+import org.springframework.transaction.support.TransactionTemplate;
+
+/**
+ * calls setRollbackOnly on the transaction in the environment in case an
+ * exception occurs during execution of the command.
+ *
+ * @author Andries Inze
+ */
+public class SpringTransactionInterceptor extends Interceptor {
+
+ private static final Log log = Log.getLog(SpringTransactionInterceptor.class.getName());
+
+ private boolean useCurrent;
+
+ @SuppressWarnings("unchecked")
+ public <T> T execute(Command<T> command) {
+ Environment environment = Environment.getCurrent();
+ if (environment == null) {
+ throw new JbpmException("no environment for managing hibernate transaction");
+ }
+
+ StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
+ if (standardTransaction == null) {
+ throw new JbpmException("no standard-transaction in environment");
+ }
+
+ PlatformTransactionManager platformTransactionManager = environment.get(PlatformTransactionManager.class);
+ if (platformTransactionManager == null) {
+ throw new JbpmException("No platformTransaction manager defined.");
+ }
+
+
+ standardTransaction.begin();
+
+ try {
+ DefaultTransactionDefinition definition = new DefaultTransactionDefinition();
+
+ if (useCurrent) {
+ definition.setPropagationBehavior(TransactionDefinition.PROPAGATION_MANDATORY);
+ }
+
+ TransactionTemplate template = new TransactionTemplate(platformTransactionManager, definition);
+ TransactionCallback transactionCallback = new CommandTransactionCallback<T>(command, next, platformTransactionManager);
+ T t = (T) template.execute(transactionCallback);
+
+ Session session = environment.get(Session.class);
+ session.flush();
+ return t;
+ } catch (RuntimeException e) {
+ standardTransaction.setRollbackOnly();
+ throw e;
+
+ } finally {
+ standardTransaction.complete();
+ }
+ }
+
+ public void setUseCurrent(Boolean useCurrent) {
+ this.useCurrent = useCurrent;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionInterceptor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SpringTransactionInterceptorBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SpringTransactionInterceptorBinding.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SpringTransactionInterceptorBinding.java 2009-05-22 09:58:21 UTC (rev 4872)
@@ -0,0 +1,55 @@
+/*
+ * 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.internal.wire.binding;
+
+import org.jbpm.pvm.internal.tx.SpringTransactionInterceptor;
+import org.jbpm.pvm.internal.tx.StandardTransactionInterceptor;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/** parses a descriptor for creating a {@link StandardTransactionInterceptor}.
+ *
+ * See schema docs for more details.
+ *
+ * @author Tom Baeyens
+ */
+public class SpringTransactionInterceptorBinding extends WireInterceptorBinding {
+
+ public SpringTransactionInterceptorBinding() {
+ super("spring-transaction-interceptor");
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+ SpringTransactionInterceptor springTransactionInterceptor = new SpringTransactionInterceptor();
+
+ Boolean useCurrent = XmlUtil.attributeBoolean(element, "current", false, parse);
+ if (useCurrent!=null) {
+ // set it accordingly
+ springTransactionInterceptor.setUseCurrent(useCurrent);
+ }
+
+ return new ProvidedObjectDescriptor(springTransactionInterceptor);
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SpringTransactionInterceptorBinding.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.wire.bindings.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.wire.bindings.xml 2009-05-22 09:23:50 UTC (rev 4871)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.wire.bindings.xml 2009-05-22 09:58:21 UTC (rev 4872)
@@ -98,5 +98,8 @@
<!-- jpdl bindings -->
<binding class="org.jbpm.jpdl.internal.xml.JpdlDeployerBinding" />
+
+ <!-- spring bindings -->
+ <binding class="org.jbpm.pvm.internal.wire.binding.SpringTransactionInterceptorBinding" />
</wire-bindings>
Added: jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/test/spring/applicationContext.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/test/spring/applicationContext.xml (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/test/spring/applicationContext.xml 2009-05-22 09:58:21 UTC (rev 4872)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
+ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
+
+ <bean id="testSF" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
+ <property name="configLocation" value="classpath:jbpm.hibernate.cfg.xml" />
+ <!-- A best practice should be to keep split the config into multiple files
+ <property name="configLocations" value="hibernate.cfg.xml, hibernate.jbpm.cfg.xml" />
+ -->
+ </bean>
+
+ <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
+ <property name="sessionFactory" ref="testSF" />
+ <property name="dataSource" ref="dataSource" />
+ </bean>
+
+ <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
+ <property name="url" value="jdbc:hsqldb:mem:." />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </bean>
+</beans>
\ No newline at end of file
Property changes on: jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/test/spring/applicationContext.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/test/spring/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/test/spring/jbpm.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/test/spring/jbpm.cfg.xml 2009-05-22 09:58:21 UTC (rev 4872)
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">
+
+ <process-engine-context>
+
+ <repository-service />
+ <repository-cache />
+ <execution-service />
+ <history-service />
+ <management-service />
+ <task-service />
+ <identity-service />
+ <command-service>
+ <retry-interceptor />
+ <environment-interceptor />
+ <spring-transaction-interceptor />
+ </command-service>
+
+ <hibernate-configuration>
+ <cfg resource="jbpm.hibernate.cfg.xml" />
+ </hibernate-configuration>
+
+
+ <script-manager default-expression-language="juel"
+ default-script-language="juel"
+ read-contexts="execution, environment, process-engine"
+ write-context="">
+ <script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
+ </script-manager>
+
+ <authentication />
+
+ <job-executor auto-start="false" />
+
+ <id-generator />
+ <types resource="jbpm.variable.types.xml" />
+
+ <business-calendar>
+ <monday hours="9:00-12:00 and 12:30-17:00"/>
+ <tuesday hours="9:00-12:00 and 12:30-17:00"/>
+ <wednesday hours="9:00-12:00 and 12:30-17:00"/>
+ <thursday hours="9:00-12:00 and 12:30-17:00"/>
+ <friday hours="9:00-12:00 and 12:30-17:00"/>
+ <holiday period="01/07/2008 - 31/08/2008"/>
+ </business-calendar>
+
+ </process-engine-context>
+
+ <transaction-context>
+ <repository-session />
+ <pvm-db-session />
+ <job-db-session />
+ <task-db-session />
+ <message-session />
+ <timer-session />
+ <history-session />
+ <hibernate-session />
+ <transaction />
+ <identity-session />
+ </transaction-context>
+
+</jbpm-configuration>
Property changes on: jbpm4/trunk/modules/pvm/src/test/resources/org/jbpm/test/spring/jbpm.cfg.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/Db.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/Db.java 2009-05-22 09:23:50 UTC (rev 4871)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/Db.java 2009-05-22 09:58:21 UTC (rev 4872)
@@ -1,194 +1,201 @@
-/*
- * 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.test;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.hibernate.Hibernate;
-import org.hibernate.SQLQuery;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.dialect.Dialect;
-import org.hibernate.dialect.MySQLDialect;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.mapping.ForeignKey;
-import org.hibernate.mapping.Table;
-import org.jbpm.api.ProcessEngine;
-import org.jbpm.api.env.EnvironmentFactory;
-import org.jbpm.internal.log.Log;
-
-
-/**
- * @author Tom Baeyens
- */
-public class Db {
-
- private static final Log log = Log.getLog(Db.class.getName());
-
- private static final String TABLE_NAMES_KEY = "tableNames";
- private static final String CLEAN_SQL_KEY = "cleanSql";
-
- public static void clean(ProcessEngine processEngine) {
- clean((EnvironmentFactory) processEngine);
- }
-
- public static void verifyClean(ProcessEngine processEngine) {
- verifyClean((EnvironmentFactory) processEngine);
- }
-
- public static void clean(EnvironmentFactory environmentFactory) {
- SessionFactory sessionFactory = environmentFactory.get(SessionFactory.class);
- // when running this with a remote ejb invocation configuration, there is no
- // session factory and no cleanup needs to be done
- if (sessionFactory==null) {
- return;
- }
-
- String[] cleanSql = (String[]) environmentFactory.get(CLEAN_SQL_KEY);
-
- if (cleanSql == null) {
- Configuration configuration = environmentFactory.get(Configuration.class);
-
- SessionFactoryImplementor sessionFactoryImplementor = (SessionFactoryImplementor) sessionFactory;
- Dialect dialect = sessionFactoryImplementor.getDialect();
-
- // loop over all foreign key constraints
- List<String> dropForeignKeysSql = new ArrayList<String>();
- List<String> createForeignKeysSql = new ArrayList<String>();
- Iterator<Table> iter = configuration.getTableMappings();
- while (iter.hasNext()) {
- Table table = (Table) iter.next();
- if (table.isPhysicalTable()) {
- String catalog = table.getCatalog();
- String schema = table.getSchema();
- Iterator<ForeignKey> subIter = table.getForeignKeyIterator();
- while (subIter.hasNext()) {
- ForeignKey fk = (ForeignKey) subIter.next();
- if (fk.isPhysicalConstraint()) {
- // collect the drop foreign key constraint sql
- dropForeignKeysSql.add(fk.sqlDropString(dialect, catalog, schema));
- // MySQLDialect creates an index for each foreign key.
- // see
- // http://opensource.atlassian.com/projects/hibernate/browse/HHH-2155
- // This index should be dropped or an error will be thrown during
- // the creation phase
- if (dialect instanceof MySQLDialect) {
- dropForeignKeysSql.add("alter table " + table.getName() + " drop key " + fk.getName());
- }
- // and collect the create foreign key constraint sql
- createForeignKeysSql.add(fk.sqlCreateString(dialect, sessionFactoryImplementor, catalog, schema));
- }
- }
- }
- }
-
- List<String> deleteSql = new ArrayList<String>();
- iter = configuration.getTableMappings();
- while (iter.hasNext()) {
- Table table = (Table) iter.next();
- if (table.isPhysicalTable()) {
- deleteSql.add("delete from " + table.getName());
- }
- }
-
- // glue
- // - drop foreign key constraints
- // - delete contents of all tables
- // - create foreign key constraints
- // together to form the clean script
- List<String> cleanSqlList = new ArrayList<String>();
- cleanSqlList.addAll(dropForeignKeysSql);
- cleanSqlList.addAll(deleteSql);
- cleanSqlList.addAll(createForeignKeysSql);
-
- cleanSql = (String[]) cleanSqlList.toArray(new String[cleanSqlList.size()]);
-
- environmentFactory.set(CLEAN_SQL_KEY, cleanSql);
- }
-
- Session session = sessionFactory.openSession();
- try {
- for (String query : cleanSql) {
- // log.trace(query);
- session.createSQLQuery(query).executeUpdate();
- }
- } finally {
- session.close();
- }
- }
-
- public static void verifyClean(EnvironmentFactory environmentFactory) {
- SessionFactory sessionFactory = environmentFactory.get(SessionFactory.class);
- // when running this with a remote ejb invocation configuration, there is no
- // session factory and no cleanup needs to be done
- if (sessionFactory==null) {
- return;
- }
-
- String[] tableNames = (String[]) environmentFactory.get(TABLE_NAMES_KEY);
-
- if (tableNames == null) {
- Configuration configuration = environmentFactory.get(Configuration.class);
-
- SessionFactoryImplementor sessionFactoryImplementor = (SessionFactoryImplementor) sessionFactory;
- Dialect dialect = sessionFactoryImplementor.getDialect();
-
- // loop over all foreign key constraints
- List<String> tableNamesList = new ArrayList<String>();
- Iterator iter = configuration.getTableMappings();
- while (iter.hasNext()) {
- Table table = (Table) iter.next();
- if (table.isPhysicalTable()) {
- tableNamesList.add(table.getName());
- }
- }
-
- tableNames = (String[]) tableNamesList.toArray(new String[tableNamesList.size()]);
-
- environmentFactory.set(TABLE_NAMES_KEY, tableNames);
- }
-
- boolean recordsLeft = false;
- Session session = sessionFactory.openSession();
- try {
- for (String tableName : tableNames) {
- String countSql = "select count(*) recordCount from "+tableName;
- SQLQuery sqlQuery = session.createSQLQuery(countSql);
- sqlQuery.addScalar("recordCount", Hibernate.INTEGER);
- Integer recordCount = (Integer) sqlQuery.uniqueResult();
- if (recordCount>0) {
- recordsLeft = true;
- log.error("FIXME: JBPM-2004 "+recordCount+" records left in table "+tableName);
- }
- }
- } finally {
- session.close();
- }
-
- if (recordsLeft) {
- clean(environmentFactory);
- }
- }
-}
+/*
+ * 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.test;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.hibernate.Hibernate;
+import org.hibernate.SQLQuery;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.dialect.Dialect;
+import org.hibernate.dialect.MySQLDialect;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.mapping.ForeignKey;
+import org.hibernate.mapping.Table;
+import org.jbpm.api.ProcessEngine;
+import org.jbpm.api.env.EnvironmentFactory;
+import org.jbpm.internal.log.Log;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Db {
+
+ private static final Log log = Log.getLog(Db.class.getName());
+
+ private static final String TABLE_NAMES_KEY = "tableNames";
+ private static final String CLEAN_SQL_KEY = "cleanSql";
+
+ public static void clean(ProcessEngine processEngine) {
+ clean((EnvironmentFactory) processEngine);
+ }
+
+ public static void verifyClean(ProcessEngine processEngine) {
+ verifyClean((EnvironmentFactory) processEngine);
+ }
+
+ public static void clean(EnvironmentFactory environmentFactory) {
+ SessionFactory sessionFactory = environmentFactory.get(SessionFactory.class);
+ // when running this with a remote ejb invocation configuration, there is no
+ // session factory and no cleanup needs to be done
+ if (sessionFactory==null) {
+ return;
+ }
+
+ String[] cleanSql = (String[]) environmentFactory.get(CLEAN_SQL_KEY);
+
+ if (cleanSql == null) {
+ Configuration configuration = environmentFactory.get(Configuration.class);
+
+ SessionFactoryImplementor sessionFactoryImplementor = (SessionFactoryImplementor) sessionFactory;
+ Dialect dialect = sessionFactoryImplementor.getDialect();
+
+ // loop over all foreign key constraints
+ List<String> dropForeignKeysSql = new ArrayList<String>();
+ List<String> createForeignKeysSql = new ArrayList<String>();
+ Iterator<Table> iter = configuration.getTableMappings();
+
+ //if no session-factory is build, the configuration is not fully initialized.
+ //Hence, the ForeignKey's won't have a referenced table. This is calculated on
+ //second pass.
+ configuration.buildMappings();
+
+
+ while (iter.hasNext()) {
+ Table table = (Table) iter.next();
+ if (table.isPhysicalTable()) {
+ String catalog = table.getCatalog();
+ String schema = table.getSchema();
+ Iterator<ForeignKey> subIter = table.getForeignKeyIterator();
+ while (subIter.hasNext()) {
+ ForeignKey fk = (ForeignKey) subIter.next();
+ if (fk.isPhysicalConstraint()) {
+ // collect the drop foreign key constraint sql
+ dropForeignKeysSql.add(fk.sqlDropString(dialect, catalog, schema));
+ // MySQLDialect creates an index for each foreign key.
+ // see
+ // http://opensource.atlassian.com/projects/hibernate/browse/HHH-2155
+ // This index should be dropped or an error will be thrown during
+ // the creation phase
+ if (dialect instanceof MySQLDialect) {
+ dropForeignKeysSql.add("alter table " + table.getName() + " drop key " + fk.getName());
+ }
+ // and collect the create foreign key constraint sql
+ createForeignKeysSql.add(fk.sqlCreateString(dialect, sessionFactoryImplementor, catalog, schema));
+ }
+ }
+ }
+ }
+
+ List<String> deleteSql = new ArrayList<String>();
+ iter = configuration.getTableMappings();
+ while (iter.hasNext()) {
+ Table table = (Table) iter.next();
+ if (table.isPhysicalTable()) {
+ deleteSql.add("delete from " + table.getName());
+ }
+ }
+
+ // glue
+ // - drop foreign key constraints
+ // - delete contents of all tables
+ // - create foreign key constraints
+ // together to form the clean script
+ List<String> cleanSqlList = new ArrayList<String>();
+ cleanSqlList.addAll(dropForeignKeysSql);
+ cleanSqlList.addAll(deleteSql);
+ cleanSqlList.addAll(createForeignKeysSql);
+
+ cleanSql = (String[]) cleanSqlList.toArray(new String[cleanSqlList.size()]);
+
+ environmentFactory.set(CLEAN_SQL_KEY, cleanSql);
+ }
+
+ Session session = sessionFactory.openSession();
+ try {
+ for (String query : cleanSql) {
+ // log.trace(query);
+ session.createSQLQuery(query).executeUpdate();
+ }
+ } finally {
+ session.close();
+ }
+ }
+
+ public static void verifyClean(EnvironmentFactory environmentFactory) {
+ SessionFactory sessionFactory = environmentFactory.get(SessionFactory.class);
+ // when running this with a remote ejb invocation configuration, there is no
+ // session factory and no cleanup needs to be done
+ if (sessionFactory==null) {
+ return;
+ }
+
+ String[] tableNames = (String[]) environmentFactory.get(TABLE_NAMES_KEY);
+
+ if (tableNames == null) {
+ Configuration configuration = environmentFactory.get(Configuration.class);
+
+ SessionFactoryImplementor sessionFactoryImplementor = (SessionFactoryImplementor) sessionFactory;
+ Dialect dialect = sessionFactoryImplementor.getDialect();
+
+ // loop over all foreign key constraints
+ List<String> tableNamesList = new ArrayList<String>();
+ Iterator iter = configuration.getTableMappings();
+ while (iter.hasNext()) {
+ Table table = (Table) iter.next();
+ if (table.isPhysicalTable()) {
+ tableNamesList.add(table.getName());
+ }
+ }
+
+ tableNames = (String[]) tableNamesList.toArray(new String[tableNamesList.size()]);
+
+ environmentFactory.set(TABLE_NAMES_KEY, tableNames);
+ }
+
+ boolean recordsLeft = false;
+ Session session = sessionFactory.openSession();
+ try {
+ for (String tableName : tableNames) {
+ String countSql = "select count(*) recordCount from "+tableName;
+ SQLQuery sqlQuery = session.createSQLQuery(countSql);
+ sqlQuery.addScalar("recordCount", Hibernate.INTEGER);
+ Integer recordCount = (Integer) sqlQuery.uniqueResult();
+ if (recordCount>0) {
+ recordsLeft = true;
+ log.error("FIXME: JBPM-2004 "+recordCount+" records left in table "+tableName);
+ }
+ }
+ } finally {
+ session.close();
+ }
+
+ if (recordsLeft) {
+ clean(environmentFactory);
+ }
+ }
+}
Modified: jbpm4/trunk/modules/test-db/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-db/pom.xml 2009-05-22 09:23:50 UTC (rev 4871)
+++ jbpm4/trunk/modules/test-db/pom.xml 2009-05-22 09:58:21 UTC (rev 4872)
@@ -47,6 +47,11 @@
<artifactId>jbpm-test-base</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
@@ -114,7 +119,9 @@
<skipTests>true</skipTests>
</properties>
</profile>
+
+
<!-- -Djboss.bind.address
<profile>
<id>integration.tests</id>
@@ -180,7 +187,8 @@
</plugin>
</plugins>
</build>
- </profile -->
+ </profile
+-->
</profiles>
</project>
\ No newline at end of file
Added: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/test/spring/applicationContext.xml
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/test/spring/applicationContext.xml (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/test/spring/applicationContext.xml 2009-05-22 09:58:21 UTC (rev 4872)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
+ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
+
+ <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
+ <property name="configLocation" value="classpath:jbpm.hibernate.cfg.xml" />
+ <!-- A best practice should be to keep split the config into multiple files
+ <property name="configLocations" value="hibernate.cfg.xml, hibernate.jbpm.cfg.xml" />
+ -->
+ </bean>
+
+ <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
+ <property name="sessionFactory" ref="sessionFactory" />
+ <property name="dataSource" ref="dataSource" />
+ </bean>
+
+ <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
+ <property name="url" value="jdbc:hsqldb:mem:." />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </bean>
+</beans>
\ No newline at end of file
Property changes on: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/test/spring/applicationContext.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/test/spring/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/test/spring/jbpm.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/test/spring/jbpm.cfg.xml 2009-05-22 09:58:21 UTC (rev 4872)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+ <import resource="jbpm.default.cfg.xml" />
+ <import resource="jbpm.jpdl.cfg.xml" />
+ <import resource="jbpm.identity.cfg.xml" />
+
+ <process-engine-context>
+ <command-service>
+ <retry-interceptor />
+ <environment-interceptor />
+ <spring-transaction-interceptor />
+ </command-service>
+ </process-engine-context>
+
+ <transaction-context>
+ <transaction />
+ <hibernate-session />
+ </transaction-context>
+</jbpm-configuration>
Property changes on: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/test/spring/jbpm.cfg.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/pom.xml
===================================================================
--- jbpm4/trunk/pom.xml 2009-05-22 09:23:50 UTC (rev 4871)
+++ jbpm4/trunk/pom.xml 2009-05-22 09:58:21 UTC (rev 4872)
@@ -63,7 +63,7 @@
<log4j.version>1.2.14</log4j.version>
<mail.version>1.4.1</mail.version>
<servlet-api.version>2.5</servlet-api.version>
- <spring.version>2.5.4</spring.version>
+ <spring.version>2.0.8</spring.version>
<stax.api.version>1.0.1</stax.api.version>
<wiser.version>1.2</wiser.version>
<woodstox.version>3.2.6</woodstox.version>
16 years, 11 months
JBoss JBPM SVN: r4871 - jbpm4/branches/idm/modules/pvm/src/main/resources.
by do-not-reply@jboss.org
Author: jeff.yuchang
Date: 2009-05-22 05:23:50 -0400 (Fri, 22 May 2009)
New Revision: 4871
Modified:
jbpm4/branches/idm/modules/pvm/src/main/resources/jbpm.jboss.idm.cfg.xml
Log:
* forgot to update the cfg file last time.
Modified: jbpm4/branches/idm/modules/pvm/src/main/resources/jbpm.jboss.idm.cfg.xml
===================================================================
--- jbpm4/branches/idm/modules/pvm/src/main/resources/jbpm.jboss.idm.cfg.xml 2009-05-22 07:35:10 UTC (rev 4870)
+++ jbpm4/branches/idm/modules/pvm/src/main/resources/jbpm.jboss.idm.cfg.xml 2009-05-22 09:23:50 UTC (rev 4871)
@@ -3,11 +3,11 @@
<jbpm-configuration>
<process-engine-context>
- <jboss-idm-identity-session-factory jndi="java:Idm" />
+ <jboss-idm-identity-session-factory jndi="java:/IdentitySessionFactory" />
</process-engine-context>
<transaction-context>
- <jboss-idm-identity-session realm="realm://jbpm-identity" />
+ <jboss-idm-identity-session realm="realm://JBossIdentity" />
</transaction-context>
</jbpm-configuration>
16 years, 11 months
JBoss JBPM SVN: r4870 - in jbpm4/branches/idm/modules: pvm/src/main/java/org/jbpm/pvm/internal/identity/impl and 1 other directory.
by do-not-reply@jboss.org
Author: jeff.yuchang
Date: 2009-05-22 03:35:10 -0400 (Fri, 22 May 2009)
New Revision: 4870
Modified:
jbpm4/branches/idm/modules/distro/src/main/files/jboss/build.xml
jbpm4/branches/idm/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JBossIdmIdentitySessionImpl.java
Log:
* Finish the idm integration.
Modified: jbpm4/branches/idm/modules/distro/src/main/files/jboss/build.xml
===================================================================
--- jbpm4/branches/idm/modules/distro/src/main/files/jboss/build.xml 2009-05-21 10:49:13 UTC (rev 4869)
+++ jbpm4/branches/idm/modules/distro/src/main/files/jboss/build.xml 2009-05-22 07:35:10 UTC (rev 4870)
@@ -21,6 +21,8 @@
<property name="jboss.distro.path" value="${jboss.distro.dir}/${jboss.filename}" />
<property name="jboss.server.configuration" value="default" />
<property name="jboss.server.config.dir" value="${jboss.home}/server/${jboss.server.configuration}" />
+
+ <property name="jbossidm.home" value="/local/deploy/jbossidm-1.0.0-SNAPSHOT" />
<!-- JDBC PROPERTIES -->
<property file="${user.home}/.jbpm4/jdbc/${database}.properties" />
@@ -108,6 +110,7 @@
description="installs jbpm into jboss">
<antcall target="internal.install.jbpm.into.jboss.common" />
<antcall target="internal.install.jbpm.into.jboss.500specifics" />
+ <antcall target="internal.install.idm.into.jboss" />
<antcall target="internal.install.jbpm.into.jboss.identity" />
<antcall target="internal.install.jbpm.into.jboss.db.${database}" />
</target>
@@ -192,9 +195,18 @@
</copy>
</target>
+ <target name="internal.install.idm.into.jboss" if="jbpm.identity.idm">
+ <ant antfile="${jbossidm.home}/jboss/build.xml" target="install.jbossidm.into.jboss">
+ <property name="jboss.home" value="${jboss.home}" />
+ <property name="jboss.server.configuration" value="${jboss.server.configuration}" />
+ <property name="database" value="${database}" />
+ <property name="jbossidm.home" value="${jbossidm.home}" />
+ </ant>
+ </target>
+
<target name="internal.install.jbpm.into.jboss.identity" if="jbpm.identity.idm">
<copy todir="${jboss.server.config.dir}/deploy/jbpm/jbpm-service.sar" overwrite="true">
- <fileset dir="${jbpm.home}/jbpm.cfg.idm">
+ <fileset dir="${jbpm.home}/jboss/jbpm.cfg.idm">
<include name="jbpm.cfg.xml"/>
</fileset>
</copy>
Modified: jbpm4/branches/idm/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JBossIdmIdentitySessionImpl.java
===================================================================
--- jbpm4/branches/idm/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JBossIdmIdentitySessionImpl.java 2009-05-21 10:49:13 UTC (rev 4869)
+++ jbpm4/branches/idm/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/JBossIdmIdentitySessionImpl.java 2009-05-22 07:35:10 UTC (rev 4870)
@@ -182,8 +182,19 @@
group.setType(idGroup.getGroupType());
group.setName(idGroup.getName());
- //TODO add parent group if necessary.
+ Collection<org.jboss.identity.idm.api.Group> idParentGroups =
+ identitySession.getRelationshipManager().findAssociatedGroups(idGroup, null, false, false);
+ if (idParentGroups.size() > 0) {
+ org.jboss.identity.idm.api.Group idParent = idParentGroups.iterator().next();
+ GroupImpl parentGroup = new GroupImpl();
+ parentGroup.setId(idParent.getId());
+ parentGroup.setType(idParent.getGroupType());
+ parentGroup.setName(idParent.getName());
+
+ group.setParent(parentGroup);
+ }
+
return group;
} catch (IdentityException e) {
16 years, 11 months
JBoss JBPM SVN: r4869 - in jbpm4/trunk/modules: examples/src/test/java/org/jbpm/examples/async/fork and 6 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-05-21 06:49:13 -0400 (Thu, 21 May 2009)
New Revision: 4869
Added:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/Application.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/AsyncForkTest.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/activity/process.png
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/fork/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/fork/process.jpdl.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/fork/process.png
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/AsyncContinuations.java
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.async.activity.png
jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.async.fork.png
Modified:
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/activity/process.jpdl.xml
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivityMessage.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivityMessage.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivityMessage.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTakeMessage.java
Log:
JBPM-2256 async fork
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/Application.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/Application.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/Application.java 2009-05-21 10:49:13 UTC (rev 4869)
@@ -0,0 +1,35 @@
+/*
+ * 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.async.fork;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class Application {
+
+ public void shipGoods() {
+ }
+
+ public void sendBill() {
+ }
+}
Property changes on: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/Application.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/AsyncForkTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/AsyncForkTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/AsyncForkTest.java 2009-05-21 10:49:13 UTC (rev 4869)
@@ -0,0 +1,72 @@
+/*
+ * 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.async.fork;
+
+import java.util.List;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.job.Job;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class AsyncForkTest extends JbpmTestCase {
+
+ long deploymentDbid;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ deploymentDbid = repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/examples/async/fork/process.jpdl.xml")
+ .deploy();
+ }
+
+ protected void tearDown() throws Exception {
+ repositoryService.deleteDeploymentCascade(deploymentDbid);
+
+ super.tearDown();
+ }
+
+ public void testAsyncFork() {
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("AsyncFork");
+ String processInstanceId = processInstance.getId();
+
+ List<Job> jobs = managementService.createJobQuery()
+ .processInstanceId(processInstanceId)
+ .list();
+
+ System.out.println(jobs);
+
+ assertEquals(2, jobs.size());
+
+ Job job = jobs.get(0);
+
+ managementService.executeJob(job.getDbid());
+
+ job = jobs.get(1);
+
+ managementService.executeJob(job.getDbid());
+ }
+}
Property changes on: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/async/fork/AsyncForkTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/activity/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/activity/process.jpdl.xml 2009-05-21 10:22:53 UTC (rev 4868)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/activity/process.jpdl.xml 2009-05-21 10:49:13 UTC (rev 4869)
@@ -22,6 +22,6 @@
<transition to="end"/>
</java>
- <end name="end" g="452,28,80,40"/>
+ <end name="end" g="330,28,80,40"/>
</process>
\ No newline at end of file
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/activity/process.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/activity/process.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/fork/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/fork/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/fork/process.jpdl.xml 2009-05-21 10:49:13 UTC (rev 4869)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="AsyncFork" xmlns="http://jbpm.org/4.0/jpdl">
+
+ <start g="22,69,80,40">
+ <transition to="fork"/>
+ </start>
+
+ <fork g="99,68,80,40" name="fork">
+ <on event="end" continue="exclusive" />
+ <transition g="122,41:" to="ship goods"/>
+ <transition g="123,142:" to="send bill"/>
+ </fork>
+
+ <java class="org.jbpm.examples.async.fork.Application" g="159,17,98,50" method="shipGoods" name="ship goods">
+ <transition g="297,42:" to="join"/>
+ </java>
+
+ <java class="org.jbpm.examples.async.fork.Application" g="159,117,98,50" method="sendBill" name="send bill">
+ <transition g="297,141:" to="join"/>
+ </java>
+
+ <join g="274,66,80,40" name="join">
+ <transition to="end"/>
+ </join>
+
+ <end g="353,67,48,48" name="end"/>
+
+</process>
Property changes on: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/fork/process.jpdl.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/fork/process.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/async/fork/process.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java 2009-05-21 10:22:53 UTC (rev 4868)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JoinActivity.java 2009-05-21 10:49:13 UTC (rev 4869)
@@ -54,6 +54,9 @@
if (Execution.STATE_ACTIVE_ROOT.equals(execution.getState())) {
// just pass through
Transition transition = activity.getDefaultOutgoingTransition();
+ if (transition==null) {
+ throw new JbpmException("join must have an outgoing transition");
+ }
execution.take(transition);
} else if (Execution.STATE_ACTIVE_CONCURRENT.equals(execution.getState())) {
@@ -78,6 +81,9 @@
execution.setActivity(activity, outgoingExecution);
Transition transition = activity.getDefaultOutgoingTransition();
+ if (transition==null) {
+ throw new JbpmException("join must have an outgoing transition");
+ }
outgoingExecution.take(transition);
}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/AsyncContinuations.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/AsyncContinuations.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/AsyncContinuations.java 2009-05-21 10:49:13 UTC (rev 4869)
@@ -0,0 +1,43 @@
+/*
+ * 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.internal.model.op;
+
+import org.jbpm.api.Execution;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class AsyncContinuations {
+
+ public static void restoreState(ExecutionImpl execution) {
+ ExecutionImpl parent = execution.getParent();
+ if ( (parent!=null)
+ && (Execution.STATE_INACTIVE_CONCURRENT_ROOT.equals(parent.getState()))
+ ) {
+ execution.setState(Execution.STATE_ACTIVE_CONCURRENT);
+ } else {
+ execution.setState(Execution.STATE_ACTIVE_ROOT);
+ }
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/AsyncContinuations.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivityMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivityMessage.java 2009-05-21 10:22:53 UTC (rev 4868)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/ExecuteActivityMessage.java 2009-05-21 10:49:13 UTC (rev 4869)
@@ -21,7 +21,6 @@
*/
package org.jbpm.pvm.internal.model.op;
-import org.jbpm.api.Execution;
import org.jbpm.api.env.Environment;
import org.jbpm.pvm.internal.job.MessageImpl;
import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
@@ -42,7 +41,7 @@
}
public Object execute(Environment environment) throws Exception {
- execution.setState(Execution.STATE_ACTIVE_ROOT);
+ AsyncContinuations.restoreState(execution);
execution.performAtomicOperationSync(ExecutionImpl.EXECUTE_ACTIVITY);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivityMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivityMessage.java 2009-05-21 10:22:53 UTC (rev 4868)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionEndActivityMessage.java 2009-05-21 10:49:13 UTC (rev 4869)
@@ -42,7 +42,7 @@
}
public Object execute(Environment environment) throws Exception {
- execution.setState(Execution.STATE_ACTIVE_ROOT);
+ AsyncContinuations.restoreState(execution);
execution.performAtomicOperationSync(ExecutionImpl.TRANSITION_END_ACTIVITY);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivityMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivityMessage.java 2009-05-21 10:22:53 UTC (rev 4868)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionStartActivityMessage.java 2009-05-21 10:49:13 UTC (rev 4869)
@@ -42,7 +42,8 @@
}
public Object execute(Environment environment) throws Exception {
- execution.setState(Execution.STATE_ACTIVE_ROOT);
+ AsyncContinuations.restoreState(execution);
+
execution.performAtomicOperationSync(ExecutionImpl.TRANSITION_START_ACTIVITY);
JobDbSession jobDbSession = environment.get(JobDbSession.class);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTakeMessage.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTakeMessage.java 2009-05-21 10:22:53 UTC (rev 4868)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/TransitionTakeMessage.java 2009-05-21 10:49:13 UTC (rev 4869)
@@ -43,7 +43,8 @@
}
public Object execute(Environment environment) throws Exception {
- execution.setState(Execution.STATE_ACTIVE_ROOT);
+ AsyncContinuations.restoreState(execution);
+
execution.performAtomicOperationSync(ExecutionImpl.TRANSITION_TAKE);
JobDbSession jobDbSession = environment.get(JobDbSession.class);
Added: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.async.activity.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.async.activity.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.async.fork.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/userguide/src/main/docbook/en/images/process.async.fork.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
16 years, 11 months
JBoss JBPM SVN: r4868 - in jbpm4/branches/jimma/modules/migration/src: main/java/org/jbpm/jpdl/internal/convert/util and 2 other directories.
by do-not-reply@jboss.org
Author: jim.ma
Date: 2009-05-21 06:22:53 -0400 (Thu, 21 May 2009)
New Revision: 4868
Added:
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/ForkConverter.java
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/JoinConverter.java
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/NodeConverter.java
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/SwimlaneConverter.java
jbpm4/branches/jimma/modules/migration/src/test/resources/businesstrip.xml
Modified:
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TaskNodeConverter.java
jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TransitionConverter.java
jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java
Log:
Added swimlane,join,fork and node conveter
Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java 2009-05-21 09:29:36 UTC (rev 4867)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/JpdlConverter.java 2009-05-21 10:22:53 UTC (rev 4868)
@@ -22,20 +22,29 @@
package org.jbpm.jpdl.internal.convert;
import java.net.URL;
+import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.jbpm.graph.def.Node;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.graph.node.EndState;
+import org.jbpm.graph.node.Fork;
+import org.jbpm.graph.node.Join;
import org.jbpm.graph.node.StartState;
import org.jbpm.graph.node.State;
import org.jbpm.graph.node.TaskNode;
import org.jbpm.jpdl.internal.convert.util.EndStateConverter;
+import org.jbpm.jpdl.internal.convert.util.ForkConverter;
+import org.jbpm.jpdl.internal.convert.util.JoinConverter;
+import org.jbpm.jpdl.internal.convert.util.NodeConverter;
import org.jbpm.jpdl.internal.convert.util.StartStateConverter;
import org.jbpm.jpdl.internal.convert.util.StateConverter;
+import org.jbpm.jpdl.internal.convert.util.SwimlaneConverter;
import org.jbpm.jpdl.internal.convert.util.TaskNodeConverter;
import org.jbpm.jpdl4.model.Process;
+import org.jbpm.taskmgmt.def.Swimlane;
+import org.jbpm.taskmgmt.def.TaskMgmtDefinition;
import org.xml.sax.InputSource;
public class JpdlConverter {
@@ -58,7 +67,20 @@
public Process mapProcessDef(ProcessDefinition def) {
Process process = new Process();
process.setName(def.getName());
-
+
+ //convert swimlane
+ TaskMgmtDefinition taskMgmtDefinition = def.getTaskMgmtDefinition();
+ Map swimlanesMap = taskMgmtDefinition.getSwimlanes();
+ if (swimlanesMap != null) {
+ Iterator iterator = swimlanesMap.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Map.Entry<String, Swimlane> entry = (Map.Entry<String, Swimlane>) iterator
+ .next();
+ org.jbpm.jpdl4.model.Swimlane item = SwimlaneConverter
+ .run(entry.getValue());
+ process.getSwimlaneAndOnAndTimer().add(item);
+ }
+ }
for (Node node : def.getNodes()) {
// map start state node
if (node.getNodeType().equals(Node.NodeType.StartState)) {
@@ -80,6 +102,15 @@
Set<Process.Task> tasks = TaskNodeConverter.run(taskNode);
process.getSwimlaneAndOnAndTimer().addAll(tasks);
}
+ } else if (node.getNodeType().equals(Node.NodeType.Fork)) {
+ Fork fork = (Fork)node;
+ process.getSwimlaneAndOnAndTimer().add(ForkConverter.run(fork));
+ } else if (node.getNodeType().equals(Node.NodeType.Join)) {
+ Join join = (Join)node;
+ process.getSwimlaneAndOnAndTimer().add(JoinConverter.run(join));
+ } else if (node.getNodeType().equals(Node.NodeType.Node)) {
+ Node tmpNode = (Node)node;
+ process.getSwimlaneAndOnAndTimer().add(NodeConverter.run(tmpNode));
}
}
Added: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/ForkConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/ForkConverter.java (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/ForkConverter.java 2009-05-21 10:22:53 UTC (rev 4868)
@@ -0,0 +1,40 @@
+/*
+ * 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.jpdl.internal.convert.util;
+
+import org.jbpm.graph.def.Transition;
+import org.jbpm.jpdl4.model.TransitionType;
+import org.jbpm.jpdl4.model.Process.Fork;;
+
+public class ForkConverter {
+ public static Fork run(org.jbpm.graph.node.Fork node) {
+ Fork result = new Fork();
+ result.setName(node.getName());
+
+ for(Transition trans : node.getLeavingTransitions()) {
+ TransitionType transType = TransitionConverter.run(trans, TransitionType.class);
+ result.getTransition().add(transType);
+ }
+ return result;
+ }
+
+}
Added: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/JoinConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/JoinConverter.java (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/JoinConverter.java 2009-05-21 10:22:53 UTC (rev 4868)
@@ -0,0 +1,40 @@
+/*
+ * 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.jpdl.internal.convert.util;
+
+import org.jbpm.graph.def.Transition;
+import org.jbpm.jpdl4.model.TransitionType;
+import org.jbpm.jpdl4.model.Process.Join;
+
+public class JoinConverter {
+ public static Join run(org.jbpm.graph.node.Join node) {
+ Join join = new Join();
+ join.setName(node.getName());
+ for (Transition trans : node.getLeavingTransitions()) {
+ join.getTransition().add(
+ TransitionConverter.run(trans, TransitionType.class));
+ }
+ return join;
+
+ }
+
+}
Added: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/NodeConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/NodeConverter.java (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/NodeConverter.java 2009-05-21 10:22:53 UTC (rev 4868)
@@ -0,0 +1,50 @@
+package org.jbpm.jpdl.internal.convert.util;
+
+import org.jbpm.graph.def.Action;
+import org.jbpm.graph.def.Node;
+import org.jbpm.instantiation.Delegation;
+import org.jbpm.jpdl4.model.Process;
+
+/*
+<action-type element="action" class="org.jbpm.graph.def.Action" />
+<action-type element="create-timer" class="org.jbpm.scheduler.def.CreateTimerAction" />
+<action-type element="cancel-timer" class="org.jbpm.scheduler.def.CancelTimerAction" />
+<action-type element="script" class="org.jbpm.graph.action.Script" />
+<action-type element="mail" class="org.jbpm.graph.action.MailAction" />*/
+public class NodeConverter {
+ public static Object run(Node node) {
+ String nodeName = node.getName();
+ Action action = node.getAction();
+ if (action instanceof Action) {
+ Process.Java result = new Process.Java();
+ result.setName(nodeName);
+ if (action.getActionExpression() != null) {
+ //REVISIT how to map expression
+ }
+ if (action.getActionDelegation() != null) {
+ result.setClazz(action.getActionDelegation().getClassName());
+ result.setMethod("execute");
+ }
+ return result;
+ }
+ //TODO:convert other action types
+ if (action instanceof org.jbpm.scheduler.def.CreateTimerAction) {
+
+ }
+ if (action instanceof org.jbpm.scheduler.def.CancelTimerAction) {
+
+ }
+ /*if (action instanceof org.jbpm.scheduler.def.Script) {
+
+ }
+
+ if (action instanceof org.jbpm.scheduler.def.MailAction) {
+
+ }*/
+
+ return null;
+
+
+ }
+
+}
Added: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/SwimlaneConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/SwimlaneConverter.java (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/SwimlaneConverter.java 2009-05-21 10:22:53 UTC (rev 4868)
@@ -0,0 +1,56 @@
+package org.jbpm.jpdl.internal.convert.util;
+import org.jbpm.instantiation.Delegation;
+import org.jbpm.jpdl4.model.Swimlane;
+public class SwimlaneConverter {
+ public static Swimlane run(org.jbpm.taskmgmt.def.Swimlane swimlane) {
+ Swimlane result = new Swimlane();
+ result.setName(swimlane.getName());
+ String actoridExpress = swimlane.getActorIdExpression();
+ String pooledActorIdExpression = swimlane.getPooledActorsExpression();
+ if (actoridExpress != null) {
+ result.setAssignee(actoridExpress);
+ } else if (pooledActorIdExpression != null) {
+ result.setCandidateGroups(pooledActorIdExpression);
+ } else {
+ //process the expression
+ Delegation delegation = swimlane.getAssignmentDelegation();
+ //If this className need to be map
+ //className = delegation.getClassName();
+
+ if (delegation != null) {
+ String configuration = delegation.getConfiguration();
+ // if the expression attribute is not empty , ex.
+ // <expression>a->b->c</expression>
+ if (configuration.startsWith("<expression>")) {
+ mapExpression(result, configuration);
+ } else if (configuration.startsWith("<actorId>")) {
+ // TODO: figure out set it in actorId or candidate-users.
+ // The class is needed to map
+ int beginIndex = "<actorId>".length();
+ int endIndex = configuration.indexOf("</actorId>");
+ String actorId = configuration.substring(beginIndex,
+ endIndex);
+ result.setAssignee(actorId);
+ } else if (configuration.startsWith("<pooledActors>")) {
+ // TODO: figure out set it in actorId or candidate-users?
+ int beginIndex = "<pooledActors>".length();
+ int endIndex = configuration.indexOf("</pooledActors>");
+ String pooledActorId = configuration.substring(beginIndex,
+ endIndex);
+ result.setCandidateGroups(pooledActorId);
+ } else {
+ // TODO: look at if we need to handle the case that there is
+ // no actorId, pooledActors and expression
+ }
+ }
+ }
+
+ return result;
+ }
+
+ //TODO: map expression to swimlane
+ public static void mapExpression(Swimlane result, String expression) {
+
+ }
+
+}
Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TaskNodeConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TaskNodeConverter.java 2009-05-21 09:29:36 UTC (rev 4867)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TaskNodeConverter.java 2009-05-21 10:22:53 UTC (rev 4868)
@@ -4,6 +4,7 @@
import org.jbpm.graph.node.TaskNode;
import org.jbpm.instantiation.Delegation;
+import org.jbpm.jpdl4.model.ObjectFactory;
import org.jbpm.jpdl4.model.Process;
import org.jbpm.jpdl4.model.WireObjectType;
import org.jbpm.taskmgmt.def.Task;
@@ -11,6 +12,7 @@
public class TaskNodeConverter {
public static Set<Process.Task> run(TaskNode taskNode) {
+
String taskNodeName = taskNode.getName();
Set<Process.Task> result = new java.util.HashSet<Process.Task>();
Set<Task> tasks = taskNode.getTasks();
@@ -19,7 +21,22 @@
if (taskArray != null && taskArray.length > 0) {
for (int i = 0 ; i < taskArray.length; i++) {
Task tmpTask =taskArray[i];
+
Process.Task tmpNewTask = convert(tmpTask);
+ //convert the swimlane information
+ if (tmpTask.getActorIdExpression() != null) {
+ tmpNewTask.setAssignee(tmpTask.getActorIdExpression());
+ } else if(tmpTask.getPooledActorsExpression() != null) {
+ tmpNewTask.setCandidateGroups(tmpTask.getPooledActorsExpression());
+ } else if (tmpTask.getSwimlane() != null) {
+ tmpNewTask.setSwimlane(tmpTask.getSwimlane().getName());
+ } else if (tmpTask.getAssignmentDelegation() != null) {
+ //TODO:revisit it
+ WireObjectType wireObjectType = new ObjectFactory().createWireObjectType();
+ wireObjectType.setClazz(tmpTask.getAssignmentDelegation().getClassName());
+ tmpNewTask.setAssignmentHandler(wireObjectType);
+ }
+
if (i ==0 ) {
tmpNewTask.setName(taskNodeName);
}
Modified: jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TransitionConverter.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TransitionConverter.java 2009-05-21 09:29:36 UTC (rev 4867)
+++ jbpm4/branches/jimma/modules/migration/src/main/java/org/jbpm/jpdl/internal/convert/util/TransitionConverter.java 2009-05-21 10:22:53 UTC (rev 4868)
@@ -39,8 +39,7 @@
try {
transType = claz.newInstance();
} catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+
}
// get the actions
if (transition.getEvents() != null) {
@@ -65,6 +64,7 @@
}
}
}
+ transType.setName(transition.getName());
transType.setTo(transition.getTo().getName());
return (T)transType;
}
Modified: jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java 2009-05-21 09:29:36 UTC (rev 4867)
+++ jbpm4/branches/jimma/modules/migration/src/test/java/org/jbpm/jpdl/internal/convert/JpdlConverterTest.java 2009-05-21 10:22:53 UTC (rev 4868)
@@ -27,6 +27,7 @@
import org.jbpm.api.Problem;
import org.jbpm.jpdl.internal.xml.JpdlParser;
import org.junit.Assert;
+import org.junit.Ignore;
import org.junit.Test;
public class JpdlConverterTest {
@@ -41,7 +42,12 @@
testConvert("assignment.xml");
}
+ @Test
+ public void runBusinessTrip() throws Exception {
+ testConvert("businesstrip.xml");
+ }
+
public void testConvert(String resourcefile) throws Exception {
URL url = getClass().getClassLoader().getResource(resourcefile);
ConverterContext context = new ConverterContext();
Added: jbpm4/branches/jimma/modules/migration/src/test/resources/businesstrip.xml
===================================================================
--- jbpm4/branches/jimma/modules/migration/src/test/resources/businesstrip.xml (rev 0)
+++ jbpm4/branches/jimma/modules/migration/src/test/resources/businesstrip.xml 2009-05-21 10:22:53 UTC (rev 4868)
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process-definition name="business trip request"
+ xmlns="urn:jbpm.org:jpdl-3.2">
+
+ <swimlane name="employee" />
+ <swimlane name="manager">
+ <assignment actor-id="manager" />
+ </swimlane>
+ <swimlane name="hr">
+ <assignment actor-id="hr" />
+ </swimlane>
+ <swimlane name="accountant">
+ <assignment actor-id="accountant" />
+ </swimlane>
+
+ <start-state name="submit business trip request">
+ <task swimlane="employee" />
+ <transition name="submit request" to="manager evaluation" />
+ </start-state>
+
+ <task-node name="manager evaluation">
+ <task swimlane="manager" />
+ <transition to="end" name="reject" />
+ <transition to="preparations" name="approve" />
+ </task-node>
+
+ <fork name="preparations">
+ <transition to="erp update" name="erp update"></transition>
+ <transition to="ticket purchase" name="book ticket"></transition>
+ </fork>
+
+ <node name="erp update">
+ <action
+ class="org.jbpm.examples.businesstrip.action.UpdateErpAction">
+ </action>
+ <transition to="join"></transition>
+ </node>
+
+ <node name="query travel agent db">
+ <action
+ class="org.jbpm.examples.businesstrip.action.QueryTravelAgentDbAction">
+ </action>
+ <transition to="join"></transition>
+ </node>
+
+ <task-node name="ticket purchase">
+ <task swimlane="accountant" />
+ <transition to="query travel agent db"></transition>
+ </task-node>
+
+ <join name="join">
+ <transition to="end"></transition>
+ </join>
+
+ <end-state name="end" />
+</process-definition>
\ No newline at end of file
16 years, 11 months
JBoss JBPM SVN: r4867 - in jbpm4/trunk/modules: api/src/main/java/org/jbpm/api/activity and 27 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-05-21 05:29:36 -0400 (Thu, 21 May 2009)
New Revision: 4867
Added:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/MailNotificationTest.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification/process.jpdl.xml
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskAssign.java
Removed:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/MailNotificationTest.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification/process.jpdl.xml
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ExecutionService.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/activity/ExternalActivityBehaviour.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/client/ClientExecution.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/OpenExecution.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/OpenTask.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/TaskHandler.java
jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/WaitState.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/mail/template/TemplateMailTest.java
jbpm4/trunk/modules/examples/src/test/resources/jbpm.mail.templates.examples.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/template/process.jpdl.xml
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/GroupActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/MailBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StateActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SignalCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceInLatestCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/VariablesCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/Signal.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycleState.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailTemplateBinding.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/activities/WaitState.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/WaitState.java
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/async/ExclusiveMessagesTest.java
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/async/WaitState.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticDecisionTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/BasicExecutionFlowTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExecutionStateTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExternalDecisionTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/FunctionalActivityTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/LoopingTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeStateTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableDeclarationTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/SubProcessTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/VariableTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/WaitState.java
Log:
JBPM-2254 restore build broken by query change in IdentitySessionImpl; reintroduce variable API change after clarifying the intent
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ExecutionService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ExecutionService.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ExecutionService.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -70,14 +70,14 @@
* @param variables are the initial values of the process variables that
* will be set before the execution starts (read: before the initial
* activity is executed). */
- ProcessInstance startProcessInstanceByKey(String processDefinitionKey, Map<String, Object> variables);
+ ProcessInstance startProcessInstanceByKey(String processDefinitionKey, Map<String, ?> variables);
/** starts a new process instance in the latest version of the given processDefinitionName.
* @param processDefinitionKey is the key of the process definition for which the latest version will be taken.
* @param variables are the initial values of the process variables that will be set before the execution starts.
* @param processInstanceKey is a user provided reference for the new execution that must be unique over all
* process versions with the same name. */
- ProcessInstance startProcessInstanceByKey(String processDefinitionKey, Map<String, Object> variables, String processInstanceKey);
+ ProcessInstance startProcessInstanceByKey(String processDefinitionKey, Map<String, ?> variables, String processInstanceKey);
/** the path of execution that is uniquely defined by the execution id. */
Execution findExecutionById(String executionId);
@@ -92,10 +92,10 @@
ProcessInstance signalExecutionById(String executionId, String signalName);
/** provides a named external trigger to an execution with parameters. */
- ProcessInstance signalExecutionById(String executionId, String signalName, Map<String, Object> parameters);
+ ProcessInstance signalExecutionById(String executionId, String signalName, Map<String, ?> parameters);
/** provides a external trigger to an execution with parameters. */
- ProcessInstance signalExecutionById(String executionId, Map<String, Object> parameters);
+ ProcessInstance signalExecutionById(String executionId, Map<String, ?> parameters);
/** search for process instances with criteria */
@@ -105,7 +105,7 @@
void setVariable(String executionId, String name, Object value);
/** creates or overwrites the variable values on the referenced execution */
- void setVariables(String executionId, Map<String, Object> variables);
+ void setVariables(String executionId, Map<String, ?> variables);
/** retrieves a variable */
Object getVariable(String executionId, String variableName);
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/activity/ExternalActivityBehaviour.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/activity/ExternalActivityBehaviour.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/activity/ExternalActivityBehaviour.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -64,5 +64,5 @@
* considered non recoverable. After an Exception, the execution should not be
* used any more and if this is during a transaction, the transaction should be
* rolled back. */
- void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception;
+ void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) throws Exception;
}
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/client/ClientExecution.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/client/ClientExecution.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/client/ClientExecution.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -94,7 +94,7 @@
*
* @see #signal() See the unnamed signal for more information
*/
- void signal(Map<String, Object> parameters);
+ void signal(Map<String, ?> parameters);
/** feeds a named {@link #signal() external trigger} into the execution with parameters.
*
@@ -111,7 +111,7 @@
*
* @see #signal() See the unnamed signal for more information
*/
- void signal(String signalName, Map<String, Object> parameters);
+ void signal(String signalName, Map<String, ?> parameters);
/** feeds a external trigger into the given execution.
*
@@ -154,7 +154,7 @@
*
* @see #signal() See the unnamed signal for more information
*/
- void signal(Map<String, Object> parameters, Execution execution);
+ void signal(Map<String, ?> parameters, Execution execution);
/** feeds a named {@link #signal() external trigger} into a given execution with parameters.
*
@@ -171,7 +171,7 @@
*
* @see #signal() See the unnamed signal for more information
*/
- void signal(String signalName, Map<String, Object> parameters, Execution execution);
+ void signal(String signalName, Map<String, ?> parameters, Execution execution);
/** suspends this execution and all it's child executions. Human tasks
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/OpenExecution.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/OpenExecution.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/OpenExecution.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -21,7 +21,6 @@
*/
package org.jbpm.api.model;
-import java.util.Collection;
import java.util.Map;
import java.util.Set;
@@ -29,7 +28,6 @@
import org.jbpm.api.JbpmException;
import org.jbpm.api.job.Timer;
-
/** execution that opens up access to the related
* objects in the execution and process definition
* model.
@@ -78,7 +76,7 @@
* variables will <b>not</b> be removed.
* @throws JbpmException is variables is not null and if null is present
* as a key in the provided variables map. */
- void setVariables(Map<String, Object> variables);
+ void setVariables(Map<String, ?> variables);
/** indicates presenve of the given key.
* No exception will be thrown if key is null.
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/OpenTask.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/OpenTask.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/OpenTask.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -37,6 +37,9 @@
/** fires a history event that marks the start of this task. */
void historyTaskStart();
+ /** fires a history event that marks the assignment of this task. */
+ void historyTaskAssign(String userId);
+
/** fires a history event that marks the completion of this task. */
void historyTaskComplete(String outcome);
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/TaskHandler.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/TaskHandler.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/TaskHandler.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -21,7 +21,6 @@
*/
package org.jbpm.api.task;
-
/** for advanced task customization.
*
* The default implementation can be found in {@link DefaultTaskHandler}.
@@ -30,7 +29,7 @@
*/
public class TaskHandler {
- /** is called after the task is created according
+ /** called after the task is created according
* to the task definition. This method allows to
* create subtasks.
* @return indicates if the process execution should wait. */
@@ -39,7 +38,7 @@
return true;
}
- /** is called when the related execution gets a
+ /** called when the related execution gets a
* signal. this method must either
* {@link OpenTask#setSignalling(boolean) remove signalling} from this task
* or {@link OpenTask#cancel(String) cancel} it. */
@@ -47,12 +46,17 @@
task.setSignalling(false);
}
- /** is called when this task is cancelled. */
+ /** called when the given task is assigned to an actor. */
+ public void taskAssign(OpenTask task, String userId) {
+ task.historyTaskAssign(userId);
+ }
+
+ /** called when the given task is cancelled. */
public void taskCancel(OpenTask task, String reason) {
task.historyTaskCancel(reason);
}
- /** is called when this task completes. The default behaviour
+ /** called when the given task completes. The default behaviour
* will send a signal to the execution if this task is still signalling. */
public void taskComplete(OpenTask task, String outcome) {
task.historyTaskComplete(outcome);
Modified: jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/WaitState.java
===================================================================
--- jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/WaitState.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/WaitState.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -39,7 +39,7 @@
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters)
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters)
throws Exception {
if (parameters != null) {
execution.setVariables(parameters);
Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/mail/template/TemplateMailTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/mail/template/TemplateMailTest.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/mail/template/TemplateMailTest.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -98,7 +98,7 @@
// start process instance
executionService.startProcessInstanceByKey("TemplateMail", variables);
- // examine produced message
+ // examine produced messages
List<WiserMessage> wisMessages = wiser.getMessages();
// winston, bb, innerparty(obrien), thinkpol(charr, obrien)
assertEquals(5, wisMessages.size());
Copied: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification (from rev 4865, jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification)
Deleted: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/MailNotificationTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/MailNotificationTest.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/MailNotificationTest.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -1,99 +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.examples.task.notification;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import javax.mail.Address;
-import javax.mail.MessagingException;
-import javax.mail.Message.RecipientType;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
-
-import org.subethamail.wiser.Wiser;
-import org.subethamail.wiser.WiserMessage;
-
-import org.jbpm.examples.task.assignee.Order;
-import org.jbpm.test.JbpmTestCase;
-
-/**
- * @author Alejandro Guizar
- */
-public class MailNotificationTest extends JbpmTestCase {
-
- Wiser wiser = new Wiser();
-
- protected void setUp() throws Exception {
- super.setUp();
-
- // deploy process
- long deploymentDbid = repositoryService.createDeployment()
- .addResourceFromClasspath("org/jbpm/examples/task/notification/process.jpdl.xml")
- .deploy();
- registerDeployment(deploymentDbid);
-
- // create actors
- identityService.createUser("johndoe", "John", "Doe", "john@doe");
-
- // start mail server
- wiser.setPort(2525);
- wiser.start();
- }
-
- protected void tearDown() throws Exception {
- // stop mail server
- wiser.stop();
-
- // delete actors
- identityService.deleteUser("johndoe");
-
- super.tearDown();
- }
-
- public void testTaskNotification() throws MessagingException, IOException {
- Map<String, Order> variables = Collections.singletonMap("order", new Order("johndoe"));
- executionService.startProcessInstanceByKey("TaskAssignee", variables);
-
- // examine produced messages
- List<WiserMessage> wiserMessages = wiser.getMessages();
- assertEquals(1, wiserMessages.size());
-
- WiserMessage wiserMessage = wiserMessages.get(0);
- MimeMessage message = wiserMessage.getMimeMessage();
- // from
- Address[] from = message.getFrom();
- assertEquals(1, from.length);
- assertEquals("noreply(a)jbpm.org", from[0].toString());
- // to
- Address[] expectedTo = InternetAddress.parse("john@doe");
- Address[] to = message.getRecipients(RecipientType.TO);
- assert Arrays.equals(expectedTo, to) : Arrays.asList(to);
- // subject
- assertEquals("review", message.getSubject());
- // text
- assertTextPresent("Task \"review\" has been assigned to you.", (String) message.getContent());
- }
-}
Copied: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/MailNotificationTest.java (from rev 4865, jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/MailNotificationTest.java)
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/MailNotificationTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/MailNotificationTest.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -0,0 +1,99 @@
+/*
+ * 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.task.notification;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import javax.mail.Address;
+import javax.mail.MessagingException;
+import javax.mail.Message.RecipientType;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+
+import org.subethamail.wiser.Wiser;
+import org.subethamail.wiser.WiserMessage;
+
+import org.jbpm.examples.task.assignee.Order;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class MailNotificationTest extends JbpmTestCase {
+
+ Wiser wiser = new Wiser();
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // deploy process
+ long deploymentDbid = repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/examples/task/notification/process.jpdl.xml")
+ .deploy();
+ registerDeployment(deploymentDbid);
+
+ // create actors
+ identityService.createUser("johndoe", "John", "Doe", "john@doe");
+
+ // start mail server
+ wiser.setPort(2525);
+ wiser.start();
+ }
+
+ protected void tearDown() throws Exception {
+ // stop mail server
+ wiser.stop();
+
+ // delete actors
+ identityService.deleteUser("johndoe");
+
+ super.tearDown();
+ }
+
+ public void testTaskNotification() throws MessagingException, IOException {
+ Map<String, Order> variables = Collections.singletonMap("order", new Order("johndoe"));
+ executionService.startProcessInstanceByKey("TaskAssignee", variables);
+
+ // examine produced messages
+ List<WiserMessage> wiserMessages = wiser.getMessages();
+ assertEquals(1, wiserMessages.size());
+
+ WiserMessage wiserMessage = wiserMessages.get(0);
+ MimeMessage message = wiserMessage.getMimeMessage();
+ // from
+ Address[] from = message.getFrom();
+ assertEquals(1, from.length);
+ assertEquals("noreply(a)jbpm.org", from[0].toString());
+ // to
+ Address[] expectedTo = InternetAddress.parse("john@doe");
+ Address[] to = message.getRecipients(RecipientType.TO);
+ assert Arrays.equals(expectedTo, to) : Arrays.asList(to);
+ // subject
+ assertEquals("review", message.getSubject());
+ // text
+ assertTextPresent("Task \"review\" has been assigned to you.", (String) message.getContent());
+ }
+}
Modified: jbpm4/trunk/modules/examples/src/test/resources/jbpm.mail.templates.examples.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/jbpm.mail.templates.examples.xml 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/examples/src/test/resources/jbpm.mail.templates.examples.xml 2009-05-21 09:29:36 UTC (rev 4867)
@@ -4,7 +4,29 @@
<process-engine-context>
- <mail-template name="rectify template">
+ <mail-template name='task-notification'>
+ <to users="${task.assignee}"/>
+ <subject>${task.name}</subject>
+ <text><![CDATA[Hi ${task.assignee},
+Task "${task.name}" has been assigned to you.
+${task.description}
+
+Sent by JBoss jBPM
+]]></text>
+ </mail-template>
+
+ <mail-template name='task-reminder'>
+ <to users="${task.assignee}"/>
+ <subject>${task.name}</subject>
+ <text><![CDATA[Hey ${task.assignee},
+Do not forget about task "${task.name}".
+${task.description}
+
+Sent by JBoss jBPM
+]]></text>
+ </mail-template>
+
+ <mail-template name="rectify-template">
<to addresses="${addressee}" />
<cc users="bb" groups="innerparty" />
<bcc groups="thinkpol" />
Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/template/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/template/process.jpdl.xml 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/template/process.jpdl.xml 2009-05-21 09:29:36 UTC (rev 4867)
@@ -6,7 +6,7 @@
<transition to="send rectify note" />
</start>
- <mail name="send rectify note" template="rectify template">
+ <mail name="send rectify note" template="rectify-template">
<transition to="end" />
</mail>
Copied: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification (from rev 4865, jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification)
Deleted: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification/process.jpdl.xml 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification/process.jpdl.xml 2009-05-21 09:29:36 UTC (rev 4867)
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<process name="TaskAssignee">
-
- <start g="20,20,48,48">
- <transition to="review"/>
- </start>
-
- <task name="review"
- assignee="#{order.owner}"
- g="96,16,127,52">
- <notification/>
- <transition to="wait"/>
- </task>
-
- <state name="wait" g="255,16,88,52"/>
-
-</process>
Copied: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification/process.jpdl.xml (from rev 4865, jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification/process.jpdl.xml)
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification/process.jpdl.xml 2009-05-21 09:29:36 UTC (rev 4867)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="TaskAssignee">
+
+ <start g="20,20,48,48">
+ <transition to="review"/>
+ </start>
+
+ <task name="review"
+ assignee="#{order.owner}"
+ g="96,16,127,52">
+ <notification/>
+ <transition to="wait"/>
+ </task>
+
+ <state name="wait" g="255,16,88,52"/>
+
+</process>
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/GroupActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/GroupActivity.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/GroupActivity.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -83,7 +83,7 @@
return startActivities;
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) throws Exception {
Transition transition = null;
Activity activity = execution.getActivity();
List<Transition> outgoingTransitions = activity.getOutgoingTransitions();
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/MailBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/MailBinding.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/MailBinding.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -23,14 +23,7 @@
import org.w3c.dom.Element;
-import org.jbpm.api.env.Environment;
-import org.jbpm.pvm.internal.email.impl.MailProducerImpl;
-import org.jbpm.pvm.internal.email.impl.MailTemplate;
-import org.jbpm.pvm.internal.email.impl.MailTemplateRegistry;
-import org.jbpm.pvm.internal.email.spi.MailProducer;
-import org.jbpm.pvm.internal.util.XmlUtil;
-import org.jbpm.pvm.internal.wire.binding.MailTemplateBinding;
-import org.jbpm.pvm.internal.wire.binding.ObjectBinding;
+import org.jbpm.jpdl.internal.xml.JpdlParser;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
@@ -39,48 +32,13 @@
*/
public class MailBinding extends JpdlBinding {
- private static final ObjectBinding objectBinding = new ObjectBinding();
- private static final MailTemplateBinding templateBinding = new MailTemplateBinding();
-
public MailBinding() {
super("mail");
}
public Object parse(Element element, Parse parse, Parser parser) {
MailActivity activity = new MailActivity();
- activity.setMailProducer(parseProducer(element, parse, parser));
+ activity.setMailProducer(JpdlParser.parseMailProducer(element, parse, null));
return activity;
}
-
- protected MailProducer parseProducer(Element element, Parse parse, Parser parser) {
- // check whether the element is a generic object descriptor
- if (ObjectBinding.isObjectDescriptor(element)) {
- return (MailProducer) objectBinding.parse(element, parse, parser);
- }
-
- // parse the default producer
- MailProducerImpl mailProducer = new MailProducerImpl();
- mailProducer.setTemplate(parseTemplate(element, parse, parser));
- return mailProducer;
- }
-
- protected MailTemplate parseTemplate(Element element, Parse parse, Parser parser) {
- MailTemplate template;
-
- // look for template reference
- String templateName = XmlUtil.attribute(element, "template");
- if (templateName != null) {
- // load template from configuration
- MailTemplateRegistry templateRegistry = Environment.getFromCurrent(MailTemplateRegistry.class);
- template = templateRegistry.getTemplate(templateName);
- if (template == null) {
- parse.addProblem("mail template not found: " + templateName, element);
- }
- }
- else {
- // parse inline template
- template = templateBinding.parseMailTemplate(element, parse, parser);
- }
- return template;
- }
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StateActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StateActivity.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StateActivity.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -40,7 +40,7 @@
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
Activity activity = execution.getActivity();
if (parameters!=null) {
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -87,7 +87,7 @@
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
JpdlExecution jpdlExecution = execution.getExtension(JpdlExecution.class);
ExecutionImpl subProcessInstance = jpdlExecution.getSubProcessInstance();
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -61,7 +61,7 @@
}
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
Activity activity = execution.getActivity();
if (parameters!=null) {
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -38,6 +38,10 @@
import org.jbpm.internal.log.Log;
import org.jbpm.jpdl.internal.activity.JpdlBinding;
import org.jbpm.jpdl.internal.model.JpdlProcessDefinition;
+import org.jbpm.pvm.internal.email.impl.MailProducerImpl;
+import org.jbpm.pvm.internal.email.impl.MailTemplate;
+import org.jbpm.pvm.internal.email.impl.MailTemplateRegistry;
+import org.jbpm.pvm.internal.email.spi.MailProducer;
import org.jbpm.pvm.internal.model.ActivityCoordinatesImpl;
import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.model.CompositeElementImpl;
@@ -58,6 +62,10 @@
import org.jbpm.pvm.internal.util.ReflectUtil;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+import org.jbpm.pvm.internal.wire.binding.MailTemplateBinding;
+import org.jbpm.pvm.internal.wire.binding.ObjectBinding;
import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
import org.jbpm.pvm.internal.wire.operation.Operation;
import org.jbpm.pvm.internal.wire.xml.WireParser;
@@ -461,6 +469,13 @@
JpdlParser.parseAssignmentAttributes(element, taskDefinition, parse);
+ // parse notification mail producer
+ Element notificationElement = XmlUtil.element(element, "notification");
+ if (notificationElement != null) {
+ MailProducer mailProducer = parseMailProducer(notificationElement, parse, "task-notification");
+ taskDefinition.setNotificationMailProducer(mailProducer);
+ }
+
return taskDefinition;
}
@@ -552,4 +567,49 @@
return variableOutDefinitionSet;
}
+ public static MailProducer parseMailProducer(Element element, Parse parse,
+ String defaultTemplateName) {
+ // check whether the element is a generic object descriptor
+ if (ObjectBinding.isObjectDescriptor(element)) {
+ // TODO test custom mail producer
+ ObjectDescriptor objectDescriptor = parseObjectDescriptor(element, parse);
+ WireDefinition wireDefinition = parse.findObject(WireDefinition.class);
+ return (MailProducer) objectDescriptor.construct(new WireContext(wireDefinition));
+ }
+
+ // parse the default producer
+ MailProducerImpl mailProducer = new MailProducerImpl();
+ mailProducer.setTemplate(parseMailTemplate(element, parse, defaultTemplateName));
+ return mailProducer;
+ }
+
+ private static MailTemplate parseMailTemplate(Element element, Parse parse,
+ String defaultTemplateName) {
+ if (element.hasAttribute("template")) {
+ // fetch template from configuration
+ return findTemplate(element, parse, element.getAttribute("template"));
+ }
+ if (!XmlUtil.isTextOnly(element)) {
+ // parse inline template
+ return MailTemplateBinding.parseMailTemplate(element, parse);
+ }
+ if (defaultTemplateName != null) {
+ // fetch default template
+ return findTemplate(element, parse, defaultTemplateName);
+ }
+ parse.addProblem("mail template must be referenced in the 'template' attribute "
+ + "or specified inline", element);
+ return null;
+ }
+
+ private static MailTemplate findTemplate(Element element, Parse parse, String templateName) {
+ MailTemplateRegistry templateRegistry = Environment.getFromCurrent(MailTemplateRegistry.class);
+ if (templateRegistry != null) {
+ MailTemplate template = templateRegistry.getTemplate(templateName);
+ if (template != null) return template;
+ }
+ parse.addProblem("mail template not found: " + templateName, element);
+ return null;
+ }
+
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SignalCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SignalCmd.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SignalCmd.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -38,9 +38,9 @@
protected String executionId;
protected String signalName;
- protected Map<String, Object> parameters;
+ protected Map<String, ?> parameters;
- public SignalCmd(String executionId, String signalName, Map<String, Object> parameters) {
+ public SignalCmd(String executionId, String signalName, Map<String, ?> parameters) {
if (executionId==null) {
throw new JbpmException("executionId is null");
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceInLatestCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceInLatestCmd.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceInLatestCmd.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -25,14 +25,12 @@
import org.hibernate.Session;
import org.jbpm.api.JbpmException;
-import org.jbpm.api.ProcessDefinitionQuery;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.client.ClientProcessDefinition;
import org.jbpm.api.client.ClientProcessInstance;
import org.jbpm.api.env.Environment;
import org.jbpm.api.session.RepositorySession;
-
/**
* @author Tom Baeyens
*/
@@ -43,13 +41,13 @@
protected String processDefinitionKey;
protected String executionKey;
- public StartProcessInstanceInLatestCmd(String processDefinitionKey, Map<String, Object> variables, String executionKey) {
+ public StartProcessInstanceInLatestCmd(String processDefinitionKey, Map<String, ?> variables, String executionKey) {
if (processDefinitionKey==null) {
throw new JbpmException("processDefinitionKey is null");
}
this.processDefinitionKey = processDefinitionKey;
- this.variables = variables;
this.executionKey = executionKey;
+ setVariables(variables);
}
public ProcessInstance execute(Environment environment) throws Exception {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/VariablesCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/VariablesCmd.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/VariablesCmd.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -36,28 +36,32 @@
private static final long serialVersionUID = 1L;
- protected Map<String, Object> variables;
+ protected Map<String, ?> variables;
+ private Map<String, Object> internalMap;
public void addVariable(String key, Object variable) {
- if (variables==null) {
- variables = new HashMap<String, Object>();
+ if (internalMap == null) {
+ if (variables != null) {
+ throw new JbpmException("variables were set externally");
+ }
+ variables = internalMap = new HashMap<String, Object>();
}
- variables.put(key, variable);
+ internalMap.put(key, variable);
}
- public Map<String, Object> getVariables() {
+ public Map<String, ?> getVariables() {
return variables;
}
- public void setVariables(Map<String, Object> variables) {
+ public void setVariables(Map<String, ?> variables) {
this.variables = variables;
}
-
+
protected ClientExecution getExecution(Environment environment, String executionId) {
PvmDbSession dbSession = environment.get(PvmDbSession.class);
ClientExecution execution = dbSession.findExecutionById(executionId);
- if (execution==null) {
- throw new JbpmException("execution "+executionId+" doesn't exist");
+ if (execution == null) {
+ throw new JbpmException("execution " + executionId + " doesn't exist");
}
return execution;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -21,8 +21,6 @@
*/
package org.jbpm.pvm.internal.email.impl;
-import java.net.URL;
-
/**
* @author Alejandro Guizar
*/
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -83,9 +83,16 @@
return new MimeMessage((Session) null);
}
+ /**
+ * Fills the <code>from</code> attribute of the given email. The sender addresses are an optional
+ * element in the mail template. If absent, each mail server supplies the current user's email
+ * address.
+ *
+ * @see {@link InternetAddress#getLocalAddress(Session)}
+ */
protected void fillFrom(Execution execution, Message email) {
AddressTemplate fromTemplate = template.getFrom();
- // from field is optional; if absent, each mail server will supply its "local address"
+ // "from" attribute is optional
if (fromTemplate == null) return;
// resolve and parse addresses
@@ -129,7 +136,10 @@
}
private String[] tokenizeActors(String recipients, Execution execution) {
- return evaluateExpression(recipients, execution).split("[,|\\s]+");
+ String[] actors = evaluateExpression(recipients, execution).split("[,|\\s]+");
+ if (actors.length == 0)
+ throw new JbpmException("recipient list is empty: " + recipients);
+ return actors;
}
/** construct recipient addresses from user entities */
@@ -219,16 +229,20 @@
}
protected void fillSubject(Execution execution, Message email) {
- String subject = evaluateExpression(template.getSubject(), execution);
- try {
- email.setSubject(subject);
+ String subject = template.getSubject();
+ if (subject != null) {
+ subject = evaluateExpression(subject, execution);
+ try {
+ email.setSubject(subject);
+ }
+ catch (MessagingException e) {
+ throw new JbpmException("failed to set subject to " + subject, e);
+ }
}
- catch (MessagingException e) {
- throw new JbpmException("failed to set subject to " + subject, e);
- }
}
protected void fillContent(Execution execution, Message email) {
+ String text = template.getText();
String html = template.getHtml();
List<AttachmentTemplate> attachmentTemplates = template.getAttachmentTemplates();
@@ -237,9 +251,9 @@
Multipart multipart = new MimeMultipart("related");
// text
- if (template.getText() != null) {
+ if (text != null) {
BodyPart textPart = new MimeBodyPart();
- String text = evaluateExpression(template.getText(), execution);
+ text = evaluateExpression(text, execution);
try {
textPart.setText(text);
multipart.addBodyPart(textPart);
@@ -274,9 +288,9 @@
throw new JbpmException("failed to set multipart content: " + multipart, e);
}
}
- else {
+ else if (text != null) {
// unipart
- String text = evaluateExpression(template.getText(), execution);
+ text = evaluateExpression(text, execution);
try {
email.setText(text);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -10,7 +10,6 @@
import javax.mail.Transport;
import javax.mail.Message.RecipientType;
import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
import org.jbpm.api.JbpmException;
import org.jbpm.pvm.internal.email.spi.MailSession;
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskAssign.java (from rev 4865, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskAssign.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskAssign.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskAssign.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -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.internal.history.events;
+
+import org.jbpm.pvm.internal.history.HistoryEvent;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class TaskAssign extends HistoryEvent {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String userId;
+
+ public TaskAssign(String userId) {
+ this.userId = userId;
+ }
+
+ @Override
+ public void process() {
+ // TODO
+ }
+
+}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -21,9 +21,9 @@
*/
package org.jbpm.pvm.internal.identity.impl;
+import java.util.Arrays;
import java.util.List;
-import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
@@ -39,7 +39,8 @@
protected Session session;
- public String createUser(String userName, String givenName, String familyName, String businessEmail) {
+ public String createUser(String userName, String givenName, String familyName,
+ String businessEmail) {
UserImpl user = new UserImpl(userName, givenName, familyName);
user.setBusinessEmail(businessEmail);
session.save(user);
@@ -54,7 +55,13 @@
}
public List<User> findUsersById(String... userIds) {
- return session.createCriteria(UserImpl.class).add(Restrictions.in("id", userIds)).list();
+ List<User> users = session.createCriteria(UserImpl.class)
+ .add(Restrictions.in("id", userIds))
+ .list();
+ if (userIds.length != users.size()) {
+ throw new JbpmException("not all users were found: " + Arrays.toString(userIds));
+ }
+ return users;
}
public List<User> findUsers() {
@@ -66,12 +73,9 @@
User user = findUserById(userId);
// cascade the deletion to the memberships
- Query query = session.createQuery("from "
- + MembershipImpl.class.getName()
- + " as m "
- + "where m.user is :user");
- query.setEntity("user", user);
- List<MembershipImpl> memberships = query.list();
+ List<MembershipImpl> memberships = session.createCriteria(MembershipImpl.class)
+ .add(Restrictions.eq("user", user))
+ .list();
// delete the related memberships
for (MembershipImpl membership : memberships) {
@@ -108,43 +112,31 @@
}
public GroupImpl findGroupById(String groupId) {
- GroupImpl group = (GroupImpl) session.createQuery("select group "
- + "from "
- + GroupImpl.class.getName()
- + " as group "
- + "where group.id = '"
- + groupId
- + "'").uniqueResult();
- return group;
+ return (GroupImpl) session.createCriteria(GroupImpl.class)
+ .add(Restrictions.eq("id", groupId))
+ .uniqueResult();
}
public List<Group> findGroupsByUserAndGroupType(String userId, String groupType) {
- Query query = session.createQuery("select distinct membership.group "
- + "from "
+ return session.createQuery("select distinct m.group"
+ + " from "
+ MembershipImpl.class.getName()
- + " as membership "
- + "where membership.user.id = '"
- + userId
- + "'"
- + " and membership.group.type = '"
- + groupType
- + "'");
- return query.list();
+ + " as m where m.user.id = :userId"
+ + " and m.group.type = :groupType")
+ .setString("userId", userId)
+ .setString("groupType", groupType)
+ .list();
}
public List<Group> findGroupsByUser(String userId) {
- Query query = session.createQuery("select distinct membership.group "
- + "from "
+ return session.createQuery("select distinct m.group"
+ + " from "
+ MembershipImpl.class.getName()
- + " as membership "
- + "where membership.user.id = '"
- + userId
- + "'");
- return query.list();
+ + " as m where m.user.id = :userId").setString("userId", userId).list();
}
public List<Group> findGroups() {
- return session.createQuery("from " + GroupImpl.class.getName()).list();
+ return session.createCriteria(GroupImpl.class).list();
}
public void deleteGroup(String groupId) {
@@ -152,12 +144,9 @@
GroupImpl group = findGroupById(groupId);
// cascade the deletion to the memberships
- Query query = session.createQuery("from "
- + MembershipImpl.class.getName()
- + " as m "
- + "where m.group is :group");
- query.setEntity("group", group);
- List<MembershipImpl> memberships = query.list();
+ List<MembershipImpl> memberships = session.createCriteria(MembershipImpl.class)
+ .add(Restrictions.eq("group", group))
+ .list();
// delete the related memberships
for (MembershipImpl membership : memberships) {
@@ -173,7 +162,7 @@
if (user == null) {
throw new JbpmException("user " + userId + " doesn't exist");
}
- GroupImpl group = findGroupById(groupId);
+ Group group = findGroupById(groupId);
if (group == null) {
throw new JbpmException("group " + groupId + " doesn't exist");
}
@@ -187,7 +176,13 @@
}
public void deleteMembership(String userId, String groupId, String role) {
- throw new UnsupportedOperationException("please implement me");
+ MembershipImpl membership = (MembershipImpl) session.createCriteria(MembershipImpl.class)
+ .createAlias("user", "u")
+ .createAlias("group", "g")
+ .add(Restrictions.eq("u.id", userId))
+ .add(Restrictions.eq("g.id", groupId))
+ .uniqueResult();
+ session.delete(membership);
}
public void setSession(Session session) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -363,18 +363,18 @@
// execution method : signal ////////////////////////////////////////////////
public void signal() {
- signal(null, (Map)null);
+ signal(null, (Map<String,?>)null);
}
public void signal(String signal) {
- signal(signal, (Map)null);
+ signal(signal, (Map<String,?>)null);
}
- public void signal(Map<String, Object> parameters) {
+ public void signal(Map<String, ?> parameters) {
signal(null, parameters);
}
- public void signal(String signal, Map<String, Object> parameters) {
+ public void signal(String signal, Map<String, ?> parameters) {
checkActive();
propagation = Propagation.EXPLICIT;
if (getActivity()!=null) {
@@ -387,18 +387,18 @@
}
public void signal(Execution execution) {
- ((ExecutionImpl)execution).signal(null, (Map)null);
+ ((ExecutionImpl)execution).signal(null, (Map<String,?>)null);
}
public void signal(String signalName, Execution execution) {
- ((ExecutionImpl)execution).signal(signalName, (Map)null);
+ ((ExecutionImpl)execution).signal(signalName, (Map<String,?>)null);
}
- public void signal(Map<String, Object> parameters, Execution execution) {
+ public void signal(Map<String, ?> parameters, Execution execution) {
((ExecutionImpl)execution).signal(null, parameters);
}
- public void signal(String signalName, Map<String, Object> parameters, Execution execution) {
+ public void signal(String signalName, Map<String, ?> parameters, Execution execution) {
((ExecutionImpl)execution).signal(signalName, parameters);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -33,13 +33,10 @@
import org.jbpm.api.Execution;
import org.jbpm.api.JbpmException;
-import org.jbpm.api.client.ClientExecution;
-import org.jbpm.api.client.ClientProcessDefinition;
import org.jbpm.api.env.Environment;
import org.jbpm.api.job.Timer;
import org.jbpm.api.session.TimerSession;
import org.jbpm.internal.log.Log;
-import org.jbpm.pvm.internal.hibernate.HibernatePvmDbSession;
import org.jbpm.pvm.internal.job.TimerImpl;
import org.jbpm.pvm.internal.type.Converter;
import org.jbpm.pvm.internal.type.Type;
@@ -168,18 +165,15 @@
}
}
- public void setVariables(Map<String, Object> variables) {
+ public void setVariables(Map<String, ?> variables) {
if (variables!=null) {
- for (String key: variables.keySet()) {
- Object value = variables.get(key);
- setVariable(key, value);
- }
+ for (Map.Entry<String, ?> entry : variables.entrySet()) {
+ setVariable(entry.getKey(), entry.getValue());
+ }
}
}
public Object getVariable(String key) {
- Object value = null;
-
Variable variable = getVariableObject(key);
if (variable!=null) {
return variable.getValue();
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/Signal.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/Signal.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/Signal.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -39,10 +39,10 @@
private static final Log log = Log.getLog(Signal.class.getName());
String signalName;
- Map<String, Object> parameters;
+ Map<String, ?> parameters;
ActivityImpl activity;
- public Signal(String signalName, Map<String, Object> parameters, ActivityImpl activity) {
+ public Signal(String signalName, Map<String, ?> parameters, ActivityImpl activity) {
this.signalName = signalName;
this.parameters = parameters;
this.activity = activity;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -22,7 +22,6 @@
package org.jbpm.pvm.internal.svc;
import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -33,7 +32,6 @@
import org.jbpm.pvm.internal.cmd.DeleteProcessInstance;
import org.jbpm.pvm.internal.cmd.EndProcessInstance;
import org.jbpm.pvm.internal.cmd.FindExecutionCmd;
-import org.jbpm.pvm.internal.cmd.FindExecutionsCmd;
import org.jbpm.pvm.internal.cmd.GetVariableNamesCmd;
import org.jbpm.pvm.internal.cmd.GetVariablesCmd;
import org.jbpm.pvm.internal.cmd.SetVariablesCmd;
@@ -42,7 +40,6 @@
import org.jbpm.pvm.internal.cmd.StartProcessInstanceInLatestCmd;
import org.jbpm.pvm.internal.query.ProcessInstanceQueryImpl;
-
/**
* @author Tom Baeyens
*/
@@ -68,7 +65,7 @@
return commandService.execute(new StartProcessInstanceInLatestCmd(processDefinitionKey, null, null));
}
- public ProcessInstance startProcessInstanceByKey(String processDefinitionKey, Map<String, Object> variables){
+ public ProcessInstance startProcessInstanceByKey(String processDefinitionKey, Map<String, ?> variables){
return commandService.execute(new StartProcessInstanceInLatestCmd(processDefinitionKey, variables, null));
}
@@ -76,7 +73,7 @@
return commandService.execute(new StartProcessInstanceInLatestCmd(processDefinitionKey, null, executionKey));
}
- public ProcessInstance startProcessInstanceByKey(String processDefinitionKey, Map<String, Object> variables, String executionKey){
+ public ProcessInstance startProcessInstanceByKey(String processDefinitionKey, Map<String, ?> variables, String executionKey){
return commandService.execute(new StartProcessInstanceInLatestCmd(processDefinitionKey, variables, executionKey));
}
@@ -90,11 +87,11 @@
return commandService.execute(new SignalCmd(executionId, signalName, null));
}
- public ProcessInstance signalExecutionById(String executionId, String signalName, Map<String, Object> parameters) {
+ public ProcessInstance signalExecutionById(String executionId, String signalName, Map<String, ?> parameters) {
return commandService.execute(new SignalCmd(executionId, signalName, parameters));
}
- public ProcessInstance signalExecutionById(String executionId, Map<String, Object> parameters) {
+ public ProcessInstance signalExecutionById(String executionId, Map<String, ?> parameters) {
return commandService.execute(new SignalCmd(executionId, null, parameters));
}
@@ -141,7 +138,7 @@
commandService.execute(cmd);
}
- public void setVariables(String executionId, Map<String, Object> variables) {
+ public void setVariables(String executionId, Map<String, ?> variables) {
SetVariablesCmd cmd = new SetVariablesCmd(executionId);
cmd.setVariables(variables);
commandService.execute(cmd);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycleState.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycleState.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycleState.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -38,7 +38,7 @@
}
public void signal(ActivityExecution execution, String signalName,
- Map<String, Object> parameters) throws Exception {
+ Map<String, ?> parameters) throws Exception {
execution.take(signalName);
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -24,6 +24,7 @@
import java.io.Serializable;
import java.util.List;
+import org.jbpm.pvm.internal.email.spi.MailProducer;
import org.jbpm.pvm.internal.util.Priority;
import org.jbpm.pvm.internal.wire.Descriptor;
@@ -41,6 +42,8 @@
protected SwimlaneDefinitionImpl swimlaneDefinition;
protected Descriptor taskHandlerDescriptor;
+ protected transient MailProducer notificationMailProducer;
+
public int getPriority() {
return priority;
}
@@ -77,4 +80,10 @@
public void setTaskHandlerDescriptor(Descriptor taskHandlerDescriptor) {
this.taskHandlerDescriptor = taskHandlerDescriptor;
}
+ public MailProducer getNotificationMailProducer() {
+ return notificationMailProducer;
+ }
+ public void setNotificationMailProducer(MailProducer notificationMailProducer) {
+ this.notificationMailProducer = notificationMailProducer;
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -23,12 +23,15 @@
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import javax.mail.Message;
+
import org.jbpm.api.Execution;
import org.jbpm.api.JbpmException;
import org.jbpm.api.env.Environment;
@@ -40,6 +43,9 @@
import org.jbpm.api.task.Swimlane;
import org.jbpm.api.task.Task;
import org.jbpm.api.task.TaskHandler;
+import org.jbpm.pvm.internal.email.spi.MailProducer;
+import org.jbpm.pvm.internal.email.spi.MailSession;
+import org.jbpm.pvm.internal.history.events.TaskAssign;
import org.jbpm.pvm.internal.history.events.TaskCancel;
import org.jbpm.pvm.internal.history.events.TaskComplete;
import org.jbpm.pvm.internal.history.events.TaskStart;
@@ -52,16 +58,15 @@
import org.jbpm.pvm.internal.wire.WireContext;
/**
- * is one task instance that can be assigned to an actor (read: put in
- * someones task list) and that can trigger the continuation of execution
- * of the token upon completion.
+ * is one task instance that can be assigned to an actor (read: put in someone's task list) and that
+ * can trigger the continuation of execution of the token upon completion.
*/
public class TaskImpl extends ScopeInstanceImpl implements Serializable, OpenTask, Assignable {
private static final long serialVersionUID = 1L;
-
+
// private static Log log = Log.getLog(TaskImpl.class.getName());
-
+
private static final TaskHandler DEFAULT_TASK_HANDLER = new TaskHandler();
protected String name;
@@ -85,48 +90,66 @@
protected String taskDefinitionName;
protected TaskDefinitionImpl taskDefinition;
-
+
protected ExecutionImpl execution;
protected ExecutionImpl processInstance;
protected SwimlaneImpl swimlane;
-
+
protected TaskImpl superTask;
protected Set<TaskImpl> subTasks;
-
+
protected Long executionDbid;
protected Long superTaskDbid;
public TaskImpl() {
}
-
+
// parent for variable lookup ///////////////////////////////////////////////
public ScopeInstanceImpl getParentVariableScope() {
return execution;
}
-
+
// assignment ///////////////////////////////////////////////////////////////
-
+
public void take(String userId) {
- if (assignee!=null) {
- throw new JbpmException("task already taken by "+this.assignee);
+ if (assignee != null) {
+ throw new JbpmException("task already taken by " + this.assignee);
}
setAssignee(userId, true);
}
-
+
public void setAssignee(String userId) {
- this.assignee = userId;
+ setAssignee(userId, false);
}
public void setAssignee(String userId, boolean propagateToSwimlane) {
this.assignee = userId;
+ notifyAssignee();
if (propagateToSwimlane) {
propagateAssigneeToSwimlane();
}
}
+ protected void notifyAssignee() {
+ if (taskDefinition == null) return;
+
+ MailProducer mailProducer = taskDefinition.getNotificationMailProducer();
+ if (mailProducer == null) return;
+
+ // TODO how to insert predefined variables cleanly?
+ execution.setVariable("task", this);
+ try {
+ Collection<Message> messages = mailProducer.produce(execution);
+ Environment.getFromCurrent(MailSession.class).send(messages);
+ }
+ finally {
+ execution.removeVariable("task");
+ }
+ }
+
protected void propagateAssigneeToSwimlane() {
- if (swimlane!=null) {
+ if (swimlane != null) {
swimlane.setAssignee(assignee);
}
}
@@ -135,7 +158,7 @@
// TODO: Why does it return the impl. not the interface?
public Set<ParticipationImpl> getParticipations() {
- if (participations ==null) {
+ if (participations == null) {
return Collections.emptySet();
}
return participations;
@@ -143,17 +166,18 @@
public Set<ParticipationImpl> getAllParticipants() {
Set<ParticipationImpl> allRoles = null;
- if (participations !=null) {
+ if (participations != null) {
allRoles = new HashSet<ParticipationImpl>(participations);
- } else {
+ }
+ else {
allRoles = new HashSet<ParticipationImpl>();
}
- if (swimlane!=null) {
- allRoles.addAll((Set)swimlane.getParticipations());
+ if (swimlane != null) {
+ allRoles.addAll((Set) swimlane.getParticipations());
}
return allRoles;
}
-
+
public void addCandidateGroup(String groupId) {
addParticipation(null, groupId, Participation.CANDIDATE);
}
@@ -165,10 +189,10 @@
public Participation addParticipation(String userId, String groupId, String type) {
return addParticipant(new ParticipationImpl(userId, groupId, type));
}
-
+
private Participation addParticipant(ParticipationImpl participation) {
participation.setTask(this);
- if (participations ==null) {
+ if (participations == null) {
participations = new HashSet<ParticipationImpl>();
}
participations.add(participation);
@@ -176,16 +200,14 @@
}
public void removeParticipant(ParticipationImpl participation) {
- if (participation==null) {
+ if (participation == null) {
throw new JbpmException("participant is null");
}
- if ( (participations !=null)
- && (participations.remove(participation))
- ) {
+ if ((participations != null) && (participations.remove(participation))) {
participation.setTask(null);
}
}
-
+
// completion ///////////////////////////////////////////////////////////////
public void complete() {
@@ -194,7 +216,7 @@
public void complete(String outcome) {
getTaskHandler().taskComplete(this, outcome);
- if (superTask!=null) {
+ if (superTask != null) {
superTask.subTaskComplete(this, outcome);
}
}
@@ -206,23 +228,21 @@
public void cancel(String reason) {
getTaskHandler().taskCancel(this, reason);
}
-
+
// state ////////////////////////////////////////////////////////////////////
-
+
public boolean isCompleted() {
if (Task.STATE_COMPLETED.equals(state)) {
return true;
}
- if ( (Task.STATE_OPEN.equals(state))
- || (Task.STATE_SUSPENDED.equals(state))
- ) {
+ if ((Task.STATE_OPEN.equals(state)) || (Task.STATE_SUSPENDED.equals(state))) {
return false;
}
return true;
}
// variables ////////////////////////////////////////////////////////////////
-
+
public void setVariable(String key, Object value) {
super.setVariable(key, value);
getTaskHandler().taskVariableUpdate(this, key, value);
@@ -231,14 +251,14 @@
// comments /////////////////////////////////////////////////////////////////
public List<Comment> getComments() {
- if (comments==null) {
+ if (comments == null) {
return Collections.emptyList();
}
return (List) comments;
}
public Comment createComment(String commentText) {
- if (comments==null) {
+ if (comments == null) {
comments = new ArrayList<CommentImpl>();
}
CommentImpl comment = new CommentImpl(commentText);
@@ -247,18 +267,18 @@
}
public void removeComment(Comment comment) {
- if (comment==null) {
+ if (comment == null) {
throw new JbpmException("comment is null");
}
- if (comments!=null) {
+ if (comments != null) {
comments.remove(comment);
}
}
-
+
// subtasks /////////////////////////////////////////////////////////////////
-
+
public Set<Task> getSubTasks() {
- if (subTasks==null) {
+ if (subTasks == null) {
return Collections.emptySet();
}
return (Set) subTasks;
@@ -267,7 +287,7 @@
public TaskImpl createSubTask() {
TaskDbSession taskDbSession = Environment.getFromCurrent(TaskDbSession.class);
TaskImpl subTask = (TaskImpl) taskDbSession.createTask();
- if (subTasks==null) {
+ if (subTasks == null) {
subTasks = new HashSet<TaskImpl>();
}
addSubTask(subTask);
@@ -281,9 +301,9 @@
subtask.setName(name);
return subtask;
}
-
+
public TaskImpl addSubTask(TaskImpl subtask) {
- if (subTasks==null) {
+ if (subTasks == null) {
subTasks = new HashSet<TaskImpl>();
}
subtask.setSuperTask(this);
@@ -292,211 +312,242 @@
}
public void removeSubTask(Task subtask) {
- if (subtask==null) {
+ if (subtask == null) {
throw new JbpmException("subtask is null");
}
- if ( (subTasks!=null)
- && (subTasks.remove(subtask))
- ) {
- ((TaskImpl)subtask).setSuperTask(null);
+ if ((subTasks != null) && (subTasks.remove(subtask))) {
+ ((TaskImpl) subtask).setSuperTask(null);
}
}
-
+
// equals ///////////////////////////////////////////////////////////////////
// hack to support comparing hibernate proxies against the real objects
// since this always falls back to ==, we don't need to overwrite the hashcode
public boolean equals(Object o) {
return EqualsUtil.equals(this, o);
}
-
+
public String toString() {
- return "Task("+name+")";
+ return "Task(" + name + ")";
}
public String getLifeCycleResource() {
// the default lifecycle can be overridden in subclasses
return "jbpm.task.lifecycle.xml";
}
-
+
// modified getters and setters /////////////////////////////////////////////
public void setProgress(Integer progress) {
- if ( (progress<0)
- || (progress>100)
- ) {
- throw new JbpmException("task progress is a percentage (integer) and must be expressed between 0 and 100");
+ if ((progress < 0) || (progress > 100)) {
+ throw new JbpmException(
+ "task progress is a percentage (integer) and must be expressed between 0 and 100");
}
this.progress = progress;
}
public boolean isPersisted() {
- return dbid!=0;
+ return dbid != 0;
}
public void cancelExecution(String signal) {
- if (execution!=null){
+ if (execution != null) {
execution.end("cancel");
}
}
+ public void historyTaskStart() {
+ if (execution != null) {
+ execution.fireHistoryEvent(new TaskStart(this));
+ }
+ }
+
+ public void historyTaskAssign(String userId) {
+ if (execution != null) {
+ execution.fireHistoryEvent(new TaskAssign(userId));
+ }
+ }
+
public void historyTaskCancel(String reason) {
- if (execution!=null){
+ if (execution != null) {
execution.fireHistoryEvent(new TaskCancel(reason));
}
}
public void historyTaskComplete(String outcome) {
- if (execution!=null){
+ if (execution != null) {
execution.fireHistoryEvent(new TaskComplete(outcome));
}
}
- public void historyTaskStart() {
- if (execution!=null){
- execution.fireHistoryEvent(new TaskStart(this));
- }
- }
-
public void signalExecution(String signalName) {
- if (execution!=null){
+ if (execution != null) {
execution.signal(signalName);
}
}
public TaskHandler getTaskHandler() {
- if ( (getTaskDefinition()==null)
- || (taskDefinition.getTaskHandlerDescriptor()==null)
- ) {
+ if ((getTaskDefinition() == null) || (taskDefinition.getTaskHandlerDescriptor() == null)) {
return DEFAULT_TASK_HANDLER;
}
-
+
TaskHandler taskHandler = (TaskHandler) WireContext.create(taskDefinition.getTaskHandlerDescriptor());
return taskHandler;
}
-
+
// special getters and setters //////////////////////////////////////////////
-
+
public TaskDefinitionImpl getTaskDefinition() {
- if ( (taskDefinition==null)
- && (taskDefinitionName!=null)
- && (execution!=null)
- ) {
+ if ((taskDefinition == null) && (taskDefinitionName != null) && (execution != null)) {
ProcessDefinitionImpl processDefinition = execution.getProcessDefinition();
taskDefinition = processDefinition.getTaskDefinition(taskDefinitionName);
}
-
+
return taskDefinition;
}
-
+
public void setTaskDefinition(TaskDefinitionImpl taskDefinition) {
this.taskDefinition = taskDefinition;
this.taskDefinitionName = taskDefinition.getName();
}
-
// getters and setters //////////////////////////////////////////////////////
-
+
public long getDbid() {
return dbid;
}
+
public String getName() {
return name;
}
+
public void setName(String name) {
this.name = name;
}
+
public String getDescription() {
return description;
}
+
public void setDescription(String description) {
this.description = description;
}
+
public int getPriority() {
return priority;
}
+
public void setPriority(int priority) {
this.priority = priority;
}
+
public void setComments(List<CommentImpl> comments) {
this.comments = comments;
}
+
public Date getCreate() {
return create;
}
+
public void setCreate(Date create) {
this.create = create;
}
+
public Date getDueDate() {
return dueDate;
}
+
public void setDueDate(Date dueDate) {
this.dueDate = dueDate;
}
+
public ExecutionImpl getExecution() {
return execution;
}
+
public void setExecution(Execution execution) {
this.execution = (ExecutionImpl) execution;
}
+
public String getState() {
return state;
}
+
public String getAssignee() {
return assignee;
}
+
public Swimlane getSwimlane() {
return swimlane;
}
+
public void setSwimlane(SwimlaneImpl swimlane) {
this.swimlane = swimlane;
}
+
public TaskImpl getSuperTask() {
return superTask;
}
+
public void setSuperTask(TaskImpl superTask) {
this.superTask = superTask;
}
+
public Integer getProgress() {
return progress;
}
+
public Long getExecutionDbid() {
return executionDbid;
}
+
public void setExecutionDbid(Long executionDbid) {
this.executionDbid = executionDbid;
}
+
public Long getSuperTaskDbid() {
return superTaskDbid;
}
+
public void setSuperTaskDbid(Long parentTaskDbid) {
this.superTaskDbid = parentTaskDbid;
}
+
public void setParticipations(Set<ParticipationImpl> participations) {
this.participations = participations;
}
+
public void setState(String state) {
this.state = state;
}
+
public void setExecution(ExecutionImpl execution) {
this.execution = execution;
}
+
public void setSubTasks(Set<TaskImpl> subTasks) {
this.subTasks = subTasks;
}
+
public ExecutionImpl getProcessInstance() {
return processInstance;
}
+
public void setProcessInstance(ExecutionImpl processInstance) {
this.processInstance = processInstance;
}
+
public boolean isSignalling() {
return isSignalling;
}
+
public void setSignalling(boolean isSignalling) {
this.isSignalling = isSignalling;
}
+
public String getForm() {
return form;
}
+
public void setForm(String form) {
this.form = form;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -247,14 +247,11 @@
}
public static boolean isTextOnly(Element element) {
- boolean isTextOnly = true;
- NodeList activityList = element.getChildNodes();
- for (int i = 0; ((i < activityList.getLength()) && (isTextOnly)); i++) {
- if (Element.class.isAssignableFrom(activityList.item(i).getClass())) {
- isTextOnly = false;
- }
+ for (Node child = element.getFirstChild(); child != null; child = child.getNextSibling()) {
+ if (child.getNodeType() == Node.ELEMENT_NODE)
+ return false;
}
- return isTextOnly;
+ return true;
}
public static List<Attr> attributes(Element element) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailTemplateBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailTemplateBinding.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailTemplateBinding.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -47,7 +47,7 @@
public Object parse(Element element, Parse parse, Parser parser) {
// MailTemplateRegistry is added to the WireDescriptor with a ProvidedObjectDescriptor
// The MailTemplateRegistry descriptor is lazy initialized by this binding
- // mail-templates will add a MailTemplate to the MailTemplateRegistry
+ // mail-template will add a MailTemplate to the MailTemplateRegistry
ProvidedObjectDescriptor templateRegistryDescriptor;
MailTemplateRegistry templateRegistry;
@@ -57,7 +57,6 @@
if (templateRegistryDescriptorName != null) {
templateRegistryDescriptor = (ProvidedObjectDescriptor) wireDefinition.getDescriptor(templateRegistryDescriptorName);
templateRegistry = (MailTemplateRegistry) templateRegistryDescriptor.getProvidedObject();
- templateRegistryDescriptor = null; // setting it to null so that the wire parser doesn't add it to the wiredefinition again
}
else {
templateRegistry = new MailTemplateRegistry();
@@ -65,21 +64,21 @@
}
// create the mail template and add it to the registry
- MailTemplate mailTemplate = parseMailTemplate(element, parse, parser);
+ MailTemplate mailTemplate = parseMailTemplate(element, parse);
String templateName = XmlUtil.attribute(element, "name", true, parse);
templateRegistry.addTemplate(templateName, mailTemplate);
return templateRegistryDescriptor;
}
- public MailTemplate parseMailTemplate(Element element, Parse parse, Parser parser) {
+ public static MailTemplate parseMailTemplate(Element element, Parse parse) {
MailTemplate mailTemplate = new MailTemplate();
mailTemplate.setLanguage(XmlUtil.attribute(element, "language"));
- mailTemplate.setFrom(parseRecipientTemplate(element, "from", parse, parser));
- mailTemplate.setTo(parseRecipientTemplate(element, "to", parse, parser));
- mailTemplate.setCc(parseRecipientTemplate(element, "cc", parse, parser));
- mailTemplate.setBcc(parseRecipientTemplate(element, "bcc", parse, parser));
+ mailTemplate.setFrom(parseRecipientTemplate(element, "from", parse));
+ mailTemplate.setTo(parseRecipientTemplate(element, "to", parse));
+ mailTemplate.setCc(parseRecipientTemplate(element, "cc", parse));
+ mailTemplate.setBcc(parseRecipientTemplate(element, "bcc", parse));
Element subjectElement = XmlUtil.element(element, "subject");
if (subjectElement != null) {
@@ -117,15 +116,22 @@
return mailTemplate;
}
- protected AddressTemplate parseRecipientTemplate(Element element, String tagName, Parse parse,
- Parser parser) {
+ private static AddressTemplate parseRecipientTemplate(Element element, String tagName, Parse parse) {
Element recipientElement = XmlUtil.element(element, tagName);
if (recipientElement == null) return null;
+ String addresses = XmlUtil.attribute(recipientElement, "addresses");
+ String users = XmlUtil.attribute(recipientElement, "users");
+ String groups = XmlUtil.attribute(recipientElement, "groups");
+
+ if (addresses == null && users == null && groups == null) {
+ parse.addProblem(tagName + " does not specify any recipient", element);
+ }
+
AddressTemplate addressTemplate = new AddressTemplate();
- addressTemplate.setAddresses(XmlUtil.attribute(recipientElement, "addresses"));
- addressTemplate.setUsers(XmlUtil.attribute(recipientElement, "users"));
- addressTemplate.setGroups(XmlUtil.attribute(recipientElement, "groups"));
+ addressTemplate.setAddresses(addresses);
+ addressTemplate.setUsers(users);
+ addressTemplate.setGroups(groups);
return addressTemplate;
}
}
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/activities/WaitState.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/activities/WaitState.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/activities/WaitState.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -39,7 +39,7 @@
public void signal(ActivityExecution execution,
String signalName,
- Map<String, Object> parameters) {
+ Map<String, ?> parameters) {
execution.setVariables(parameters);
execution.take(signalName);
}
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/WaitState.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/WaitState.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/WaitState.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -40,7 +40,7 @@
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) throws Exception {
execution.take(signalName);
}
}
\ No newline at end of file
Modified: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/async/ExclusiveMessagesTest.java
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/async/ExclusiveMessagesTest.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/async/ExclusiveMessagesTest.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -92,7 +92,7 @@
public void execute(ActivityExecution execution) throws Exception {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) throws Exception {
execution.take(signalName);
}
}
Modified: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/async/WaitState.java
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/async/WaitState.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/async/WaitState.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -40,7 +40,7 @@
ContinuationTest.recorder.record(execution.getId(), "execute("+execution.getActivity().getName()+")");
}
- public void signal(ActivityExecution execution, String signal, Map<String, Object> parameters) throws Exception {
+ public void signal(ActivityExecution execution, String signal, Map<String, ?> parameters) throws Exception {
throw new UnsupportedOperationException();
}
}
\ No newline at end of file
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticDecisionTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticDecisionTest.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticDecisionTest.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -60,7 +60,7 @@
public void execute(ActivityExecution execution) {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
execution.take(signalName);
}
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/BasicExecutionFlowTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/BasicExecutionFlowTest.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/BasicExecutionFlowTest.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -64,7 +64,7 @@
events.add("execute["+execution.getActivityName()+"]");
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) throws Exception {
events.add("signal["+execution.getActivityName()+"]");
execution.take(signalName);
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventTest.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventTest.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -170,7 +170,7 @@
public void execute(ActivityExecution execution) throws Exception {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signal, Map<String, Object> parameters) throws Exception {
+ public void signal(ActivityExecution execution, String signal, Map<String, ?> parameters) throws Exception {
Activity activity = execution.getActivity();
if ( (signal!=null)
&& (activity!=null)
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -44,7 +44,7 @@
public void execute(ActivityExecution execution) {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters){
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters){
}
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExecutionStateTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExecutionStateTest.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExecutionStateTest.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -70,7 +70,7 @@
assertEquals(Execution.STATE_ACTIVE_ROOT, execution.getState());
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
assertEquals(Execution.STATE_ACTIVE_ROOT, execution.getState());
execution.take(signalName);
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExternalDecisionTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExternalDecisionTest.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExternalDecisionTest.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -42,7 +42,7 @@
public void execute(ActivityExecution execution) throws Exception {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) throws Exception {
execution.take(signalName);
}
}
@@ -52,7 +52,7 @@
public void execute(ActivityExecution execution) {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
execution.take(signalName);
}
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/FunctionalActivityTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/FunctionalActivityTest.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/FunctionalActivityTest.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -141,7 +141,7 @@
Activity nestedActivity = execution.getActivity().getActivities().get(0);
execution.execute(nestedActivity);
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
}
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/LoopingTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/LoopingTest.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/LoopingTest.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -45,7 +45,7 @@
}
}
}
- public void signal(ActivityExecution execution, String signal, Map<String, Object> parameters) throws Exception {
+ public void signal(ActivityExecution execution, String signal, Map<String, ?> parameters) throws Exception {
throw new UnsupportedOperationException();
}
@@ -77,7 +77,7 @@
public void execute(ActivityExecution execution) {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters){
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters){
}
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeStateTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeStateTest.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeStateTest.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -51,7 +51,7 @@
assertEquals(Execution.STATE_ACTIVE_ROOT, execution.getState());
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) throws Exception {
assertEquals(Execution.STATE_ACTIVE_ROOT, execution.getState());
execution.take(signalName);
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableDeclarationTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableDeclarationTest.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableDeclarationTest.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -45,7 +45,7 @@
public void execute(ActivityExecution execution) {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
execution.take(signalName);
}
}
@@ -56,7 +56,7 @@
Activity child = execution.getActivity().getActivities().get(0);
execution.execute(child);
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
}
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableTest.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableTest.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -23,7 +23,6 @@
import java.util.Map;
-import org.jbpm.api.JbpmException;
import org.jbpm.api.activity.ActivityExecution;
import org.jbpm.api.activity.ExternalActivityBehaviour;
import org.jbpm.api.client.ClientExecution;
@@ -50,7 +49,7 @@
public void execute(ActivityExecution execution) {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
execution.take(signalName);
}
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/SubProcessTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/SubProcessTest.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/SubProcessTest.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -51,7 +51,7 @@
execution.waitForSignal();
}
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) throws Exception {
}
}
@@ -66,11 +66,12 @@
public void execute(ActivityExecution execution) {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters){
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters){
}
}
public static class EndState implements ActivityBehaviour {
+ private static final long serialVersionUID = 1L;
public void execute(ActivityExecution execution) throws Exception {
execution.end();
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/VariableTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/VariableTest.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/VariableTest.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -44,7 +44,7 @@
public void execute(ActivityExecution execution) {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters){
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters){
}
}
@@ -195,7 +195,7 @@
execution.setVariable("message", "Killroy was here");
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
}
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/WaitState.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/WaitState.java 2009-05-21 07:42:27 UTC (rev 4866)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/WaitState.java 2009-05-21 09:29:36 UTC (rev 4867)
@@ -39,6 +39,6 @@
public void signal(ActivityExecution execution,
String signalName,
- Map<String, Object> parameters) {
+ Map<String, ?> parameters) {
}
}
16 years, 11 months
JBoss JBPM SVN: r4866 - in jbpm4/trunk/modules: api/src/main/java/org/jbpm/api/activity and 25 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-05-21 03:42:27 -0400 (Thu, 21 May 2009)
New Revision: 4866
Removed:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/task/notification/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/task/notification/
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskAssign.java
Modified:
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ExecutionService.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/activity/ExternalActivityBehaviour.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/client/ClientExecution.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/OpenExecution.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/OpenTask.java
jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/TaskHandler.java
jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/WaitState.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/mail/template/TemplateMailTest.java
jbpm4/trunk/modules/examples/src/test/resources/jbpm.mail.templates.examples.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/template/process.jpdl.xml
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/GroupActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/MailBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StateActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SignalCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceInLatestCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/VariablesCmd.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/Signal.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycleState.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailTemplateBinding.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/activities/WaitState.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/WaitState.java
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/async/ExclusiveMessagesTest.java
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/async/WaitState.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticDecisionTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/BasicExecutionFlowTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExecutionStateTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExternalDecisionTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/FunctionalActivityTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/LoopingTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeStateTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableDeclarationTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/SubProcessTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/VariableTest.java
jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/WaitState.java
Log:
JBPM-2254 rolling back r4865. build broken and not discussed api change.
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ExecutionService.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ExecutionService.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/ExecutionService.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -70,14 +70,14 @@
* @param variables are the initial values of the process variables that
* will be set before the execution starts (read: before the initial
* activity is executed). */
- ProcessInstance startProcessInstanceByKey(String processDefinitionKey, Map<String, ?> variables);
+ ProcessInstance startProcessInstanceByKey(String processDefinitionKey, Map<String, Object> variables);
/** starts a new process instance in the latest version of the given processDefinitionName.
* @param processDefinitionKey is the key of the process definition for which the latest version will be taken.
* @param variables are the initial values of the process variables that will be set before the execution starts.
* @param processInstanceKey is a user provided reference for the new execution that must be unique over all
* process versions with the same name. */
- ProcessInstance startProcessInstanceByKey(String processDefinitionKey, Map<String, ?> variables, String processInstanceKey);
+ ProcessInstance startProcessInstanceByKey(String processDefinitionKey, Map<String, Object> variables, String processInstanceKey);
/** the path of execution that is uniquely defined by the execution id. */
Execution findExecutionById(String executionId);
@@ -92,10 +92,10 @@
ProcessInstance signalExecutionById(String executionId, String signalName);
/** provides a named external trigger to an execution with parameters. */
- ProcessInstance signalExecutionById(String executionId, String signalName, Map<String, ?> parameters);
+ ProcessInstance signalExecutionById(String executionId, String signalName, Map<String, Object> parameters);
/** provides a external trigger to an execution with parameters. */
- ProcessInstance signalExecutionById(String executionId, Map<String, ?> parameters);
+ ProcessInstance signalExecutionById(String executionId, Map<String, Object> parameters);
/** search for process instances with criteria */
@@ -105,7 +105,7 @@
void setVariable(String executionId, String name, Object value);
/** creates or overwrites the variable values on the referenced execution */
- void setVariables(String executionId, Map<String, ?> variables);
+ void setVariables(String executionId, Map<String, Object> variables);
/** retrieves a variable */
Object getVariable(String executionId, String variableName);
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/activity/ExternalActivityBehaviour.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/activity/ExternalActivityBehaviour.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/activity/ExternalActivityBehaviour.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -64,5 +64,5 @@
* considered non recoverable. After an Exception, the execution should not be
* used any more and if this is during a transaction, the transaction should be
* rolled back. */
- void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) throws Exception;
+ void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception;
}
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/client/ClientExecution.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/client/ClientExecution.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/client/ClientExecution.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -94,7 +94,7 @@
*
* @see #signal() See the unnamed signal for more information
*/
- void signal(Map<String, ?> parameters);
+ void signal(Map<String, Object> parameters);
/** feeds a named {@link #signal() external trigger} into the execution with parameters.
*
@@ -111,7 +111,7 @@
*
* @see #signal() See the unnamed signal for more information
*/
- void signal(String signalName, Map<String, ?> parameters);
+ void signal(String signalName, Map<String, Object> parameters);
/** feeds a external trigger into the given execution.
*
@@ -154,7 +154,7 @@
*
* @see #signal() See the unnamed signal for more information
*/
- void signal(Map<String, ?> parameters, Execution execution);
+ void signal(Map<String, Object> parameters, Execution execution);
/** feeds a named {@link #signal() external trigger} into a given execution with parameters.
*
@@ -171,7 +171,7 @@
*
* @see #signal() See the unnamed signal for more information
*/
- void signal(String signalName, Map<String, ?> parameters, Execution execution);
+ void signal(String signalName, Map<String, Object> parameters, Execution execution);
/** suspends this execution and all it's child executions. Human tasks
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/OpenExecution.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/OpenExecution.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/model/OpenExecution.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -21,6 +21,7 @@
*/
package org.jbpm.api.model;
+import java.util.Collection;
import java.util.Map;
import java.util.Set;
@@ -28,6 +29,7 @@
import org.jbpm.api.JbpmException;
import org.jbpm.api.job.Timer;
+
/** execution that opens up access to the related
* objects in the execution and process definition
* model.
@@ -76,7 +78,7 @@
* variables will <b>not</b> be removed.
* @throws JbpmException is variables is not null and if null is present
* as a key in the provided variables map. */
- void setVariables(Map<String, ?> variables);
+ void setVariables(Map<String, Object> variables);
/** indicates presenve of the given key.
* No exception will be thrown if key is null.
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/OpenTask.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/OpenTask.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/OpenTask.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -37,9 +37,6 @@
/** fires a history event that marks the start of this task. */
void historyTaskStart();
- /** fires a history event that marks the assignment of this task. */
- void historyTaskAssign(String userId);
-
/** fires a history event that marks the completion of this task. */
void historyTaskComplete(String outcome);
Modified: jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/TaskHandler.java
===================================================================
--- jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/TaskHandler.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/api/src/main/java/org/jbpm/api/task/TaskHandler.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -21,6 +21,7 @@
*/
package org.jbpm.api.task;
+
/** for advanced task customization.
*
* The default implementation can be found in {@link DefaultTaskHandler}.
@@ -29,7 +30,7 @@
*/
public class TaskHandler {
- /** called after the task is created according
+ /** is called after the task is created according
* to the task definition. This method allows to
* create subtasks.
* @return indicates if the process execution should wait. */
@@ -38,7 +39,7 @@
return true;
}
- /** called when the related execution gets a
+ /** is called when the related execution gets a
* signal. this method must either
* {@link OpenTask#setSignalling(boolean) remove signalling} from this task
* or {@link OpenTask#cancel(String) cancel} it. */
@@ -46,17 +47,12 @@
task.setSignalling(false);
}
- /** called when the given task is assigned to an actor. */
- public void taskAssign(OpenTask task, String userId) {
- task.historyTaskAssign(userId);
- }
-
- /** called when the given task is cancelled. */
+ /** is called when this task is cancelled. */
public void taskCancel(OpenTask task, String reason) {
task.historyTaskCancel(reason);
}
- /** called when the given task completes. The default behaviour
+ /** is called when this task completes. The default behaviour
* will send a signal to the execution if this task is still signalling. */
public void taskComplete(OpenTask task, String outcome) {
task.historyTaskComplete(outcome);
Modified: jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/WaitState.java
===================================================================
--- jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/WaitState.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/enterprise/src/test/java/org/jbpm/enterprise/internal/custom/WaitState.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -39,7 +39,7 @@
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters)
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters)
throws Exception {
if (parameters != null) {
execution.setVariables(parameters);
Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/mail/template/TemplateMailTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/mail/template/TemplateMailTest.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/mail/template/TemplateMailTest.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -98,7 +98,7 @@
// start process instance
executionService.startProcessInstanceByKey("TemplateMail", variables);
- // examine produced messages
+ // examine produced message
List<WiserMessage> wisMessages = wiser.getMessages();
// winston, bb, innerparty(obrien), thinkpol(charr, obrien)
assertEquals(5, wisMessages.size());
Modified: jbpm4/trunk/modules/examples/src/test/resources/jbpm.mail.templates.examples.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/jbpm.mail.templates.examples.xml 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/examples/src/test/resources/jbpm.mail.templates.examples.xml 2009-05-21 07:42:27 UTC (rev 4866)
@@ -4,29 +4,7 @@
<process-engine-context>
- <mail-template name='task-notification'>
- <to users="${task.assignee}"/>
- <subject>${task.name}</subject>
- <text><![CDATA[Hi ${task.assignee},
-Task "${task.name}" has been assigned to you.
-${task.description}
-
-Sent by JBoss jBPM
-]]></text>
- </mail-template>
-
- <mail-template name='task-reminder'>
- <to users="${task.assignee}"/>
- <subject>${task.name}</subject>
- <text><![CDATA[Hey ${task.assignee},
-Do not forget about task "${task.name}".
-${task.description}
-
-Sent by JBoss jBPM
-]]></text>
- </mail-template>
-
- <mail-template name="rectify-template">
+ <mail-template name="rectify template">
<to addresses="${addressee}" />
<cc users="bb" groups="innerparty" />
<bcc groups="thinkpol" />
Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/template/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/template/process.jpdl.xml 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/mail/template/process.jpdl.xml 2009-05-21 07:42:27 UTC (rev 4866)
@@ -6,7 +6,7 @@
<transition to="send rectify note" />
</start>
- <mail name="send rectify note" template="rectify-template">
+ <mail name="send rectify note" template="rectify template">
<transition to="end" />
</mail>
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/GroupActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/GroupActivity.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/GroupActivity.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -83,7 +83,7 @@
return startActivities;
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) throws Exception {
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
Transition transition = null;
Activity activity = execution.getActivity();
List<Transition> outgoingTransitions = activity.getOutgoingTransitions();
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/MailBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/MailBinding.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/MailBinding.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -23,7 +23,14 @@
import org.w3c.dom.Element;
-import org.jbpm.jpdl.internal.xml.JpdlParser;
+import org.jbpm.api.env.Environment;
+import org.jbpm.pvm.internal.email.impl.MailProducerImpl;
+import org.jbpm.pvm.internal.email.impl.MailTemplate;
+import org.jbpm.pvm.internal.email.impl.MailTemplateRegistry;
+import org.jbpm.pvm.internal.email.spi.MailProducer;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.binding.MailTemplateBinding;
+import org.jbpm.pvm.internal.wire.binding.ObjectBinding;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
@@ -32,13 +39,48 @@
*/
public class MailBinding extends JpdlBinding {
+ private static final ObjectBinding objectBinding = new ObjectBinding();
+ private static final MailTemplateBinding templateBinding = new MailTemplateBinding();
+
public MailBinding() {
super("mail");
}
public Object parse(Element element, Parse parse, Parser parser) {
MailActivity activity = new MailActivity();
- activity.setMailProducer(JpdlParser.parseMailProducer(element, parse, null));
+ activity.setMailProducer(parseProducer(element, parse, parser));
return activity;
}
+
+ protected MailProducer parseProducer(Element element, Parse parse, Parser parser) {
+ // check whether the element is a generic object descriptor
+ if (ObjectBinding.isObjectDescriptor(element)) {
+ return (MailProducer) objectBinding.parse(element, parse, parser);
+ }
+
+ // parse the default producer
+ MailProducerImpl mailProducer = new MailProducerImpl();
+ mailProducer.setTemplate(parseTemplate(element, parse, parser));
+ return mailProducer;
+ }
+
+ protected MailTemplate parseTemplate(Element element, Parse parse, Parser parser) {
+ MailTemplate template;
+
+ // look for template reference
+ String templateName = XmlUtil.attribute(element, "template");
+ if (templateName != null) {
+ // load template from configuration
+ MailTemplateRegistry templateRegistry = Environment.getFromCurrent(MailTemplateRegistry.class);
+ template = templateRegistry.getTemplate(templateName);
+ if (template == null) {
+ parse.addProblem("mail template not found: " + templateName, element);
+ }
+ }
+ else {
+ // parse inline template
+ template = templateBinding.parseMailTemplate(element, parse, parser);
+ }
+ return template;
+ }
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StateActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StateActivity.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/StateActivity.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -40,7 +40,7 @@
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
Activity activity = execution.getActivity();
if (parameters!=null) {
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/SubProcessActivity.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -87,7 +87,7 @@
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
JpdlExecution jpdlExecution = execution.getExtension(JpdlExecution.class);
ExecutionImpl subProcessInstance = jpdlExecution.getSubProcessInstance();
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskActivity.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -61,7 +61,7 @@
}
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
Activity activity = execution.getActivity();
if (parameters!=null) {
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -38,10 +38,6 @@
import org.jbpm.internal.log.Log;
import org.jbpm.jpdl.internal.activity.JpdlBinding;
import org.jbpm.jpdl.internal.model.JpdlProcessDefinition;
-import org.jbpm.pvm.internal.email.impl.MailProducerImpl;
-import org.jbpm.pvm.internal.email.impl.MailTemplate;
-import org.jbpm.pvm.internal.email.impl.MailTemplateRegistry;
-import org.jbpm.pvm.internal.email.spi.MailProducer;
import org.jbpm.pvm.internal.model.ActivityCoordinatesImpl;
import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.model.CompositeElementImpl;
@@ -62,10 +58,6 @@
import org.jbpm.pvm.internal.util.ReflectUtil;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
-import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.wire.WireDefinition;
-import org.jbpm.pvm.internal.wire.binding.MailTemplateBinding;
-import org.jbpm.pvm.internal.wire.binding.ObjectBinding;
import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
import org.jbpm.pvm.internal.wire.operation.Operation;
import org.jbpm.pvm.internal.wire.xml.WireParser;
@@ -469,13 +461,6 @@
JpdlParser.parseAssignmentAttributes(element, taskDefinition, parse);
- // parse notification mail producer
- Element notificationElement = XmlUtil.element(element, "notification");
- if (notificationElement != null) {
- MailProducer mailProducer = parseMailProducer(notificationElement, parse, "task-notification");
- taskDefinition.setNotificationMailProducer(mailProducer);
- }
-
return taskDefinition;
}
@@ -567,49 +552,4 @@
return variableOutDefinitionSet;
}
- public static MailProducer parseMailProducer(Element element, Parse parse,
- String defaultTemplateName) {
- // check whether the element is a generic object descriptor
- if (ObjectBinding.isObjectDescriptor(element)) {
- // TODO test custom mail producer
- ObjectDescriptor objectDescriptor = parseObjectDescriptor(element, parse);
- WireDefinition wireDefinition = parse.findObject(WireDefinition.class);
- return (MailProducer) objectDescriptor.construct(new WireContext(wireDefinition));
- }
-
- // parse the default producer
- MailProducerImpl mailProducer = new MailProducerImpl();
- mailProducer.setTemplate(parseMailTemplate(element, parse, defaultTemplateName));
- return mailProducer;
- }
-
- private static MailTemplate parseMailTemplate(Element element, Parse parse,
- String defaultTemplateName) {
- if (element.hasAttribute("template")) {
- // fetch template from configuration
- return findTemplate(element, parse, element.getAttribute("template"));
- }
- if (!XmlUtil.isTextOnly(element)) {
- // parse inline template
- return MailTemplateBinding.parseMailTemplate(element, parse);
- }
- if (defaultTemplateName != null) {
- // fetch default template
- return findTemplate(element, parse, defaultTemplateName);
- }
- parse.addProblem("mail template must be referenced in the 'template' attribute "
- + "or specified inline", element);
- return null;
- }
-
- private static MailTemplate findTemplate(Element element, Parse parse, String templateName) {
- MailTemplateRegistry templateRegistry = Environment.getFromCurrent(MailTemplateRegistry.class);
- if (templateRegistry != null) {
- MailTemplate template = templateRegistry.getTemplate(templateName);
- if (template != null) return template;
- }
- parse.addProblem("mail template not found: " + templateName, element);
- return null;
- }
-
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SignalCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SignalCmd.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/SignalCmd.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -38,9 +38,9 @@
protected String executionId;
protected String signalName;
- protected Map<String, ?> parameters;
+ protected Map<String, Object> parameters;
- public SignalCmd(String executionId, String signalName, Map<String, ?> parameters) {
+ public SignalCmd(String executionId, String signalName, Map<String, Object> parameters) {
if (executionId==null) {
throw new JbpmException("executionId is null");
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceInLatestCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceInLatestCmd.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/StartProcessInstanceInLatestCmd.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -25,12 +25,14 @@
import org.hibernate.Session;
import org.jbpm.api.JbpmException;
+import org.jbpm.api.ProcessDefinitionQuery;
import org.jbpm.api.ProcessInstance;
import org.jbpm.api.client.ClientProcessDefinition;
import org.jbpm.api.client.ClientProcessInstance;
import org.jbpm.api.env.Environment;
import org.jbpm.api.session.RepositorySession;
+
/**
* @author Tom Baeyens
*/
@@ -41,13 +43,13 @@
protected String processDefinitionKey;
protected String executionKey;
- public StartProcessInstanceInLatestCmd(String processDefinitionKey, Map<String, ?> variables, String executionKey) {
+ public StartProcessInstanceInLatestCmd(String processDefinitionKey, Map<String, Object> variables, String executionKey) {
if (processDefinitionKey==null) {
throw new JbpmException("processDefinitionKey is null");
}
this.processDefinitionKey = processDefinitionKey;
+ this.variables = variables;
this.executionKey = executionKey;
- setVariables(variables);
}
public ProcessInstance execute(Environment environment) throws Exception {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/VariablesCmd.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/VariablesCmd.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cmd/VariablesCmd.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -36,32 +36,28 @@
private static final long serialVersionUID = 1L;
- protected Map<String, ?> variables;
- private Map<String, Object> internalMap;
+ protected Map<String, Object> variables;
public void addVariable(String key, Object variable) {
- if (internalMap == null) {
- if (variables != null) {
- throw new JbpmException("variables were set externally");
- }
- variables = internalMap = new HashMap<String, Object>();
+ if (variables==null) {
+ variables = new HashMap<String, Object>();
}
- internalMap.put(key, variable);
+ variables.put(key, variable);
}
- public Map<String, ?> getVariables() {
+ public Map<String, Object> getVariables() {
return variables;
}
- public void setVariables(Map<String, ?> variables) {
+ public void setVariables(Map<String, Object> variables) {
this.variables = variables;
}
-
+
protected ClientExecution getExecution(Environment environment, String executionId) {
PvmDbSession dbSession = environment.get(PvmDbSession.class);
ClientExecution execution = dbSession.findExecutionById(executionId);
- if (execution == null) {
- throw new JbpmException("execution " + executionId + " doesn't exist");
+ if (execution==null) {
+ throw new JbpmException("execution "+executionId+" doesn't exist");
}
return execution;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -21,6 +21,8 @@
*/
package org.jbpm.pvm.internal.email.impl;
+import java.net.URL;
+
/**
* @author Alejandro Guizar
*/
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -83,16 +83,9 @@
return new MimeMessage((Session) null);
}
- /**
- * Fills the <code>from</code> attribute of the given email. The sender addresses are an optional
- * element in the mail template. If absent, each mail server supplies the current user's email
- * address.
- *
- * @see {@link InternetAddress#getLocalAddress(Session)}
- */
protected void fillFrom(Execution execution, Message email) {
AddressTemplate fromTemplate = template.getFrom();
- // "from" attribute is optional
+ // from field is optional; if absent, each mail server will supply its "local address"
if (fromTemplate == null) return;
// resolve and parse addresses
@@ -136,10 +129,7 @@
}
private String[] tokenizeActors(String recipients, Execution execution) {
- String[] actors = evaluateExpression(recipients, execution).split("[,|\\s]+");
- if (actors.length == 0)
- throw new JbpmException("recipient list is empty: " + recipients);
- return actors;
+ return evaluateExpression(recipients, execution).split("[,|\\s]+");
}
/** construct recipient addresses from user entities */
@@ -229,20 +219,16 @@
}
protected void fillSubject(Execution execution, Message email) {
- String subject = template.getSubject();
- if (subject != null) {
- subject = evaluateExpression(subject, execution);
- try {
- email.setSubject(subject);
- }
- catch (MessagingException e) {
- throw new JbpmException("failed to set subject to " + subject, e);
- }
+ String subject = evaluateExpression(template.getSubject(), execution);
+ try {
+ email.setSubject(subject);
}
+ catch (MessagingException e) {
+ throw new JbpmException("failed to set subject to " + subject, e);
+ }
}
protected void fillContent(Execution execution, Message email) {
- String text = template.getText();
String html = template.getHtml();
List<AttachmentTemplate> attachmentTemplates = template.getAttachmentTemplates();
@@ -251,9 +237,9 @@
Multipart multipart = new MimeMultipart("related");
// text
- if (text != null) {
+ if (template.getText() != null) {
BodyPart textPart = new MimeBodyPart();
- text = evaluateExpression(text, execution);
+ String text = evaluateExpression(template.getText(), execution);
try {
textPart.setText(text);
multipart.addBodyPart(textPart);
@@ -288,9 +274,9 @@
throw new JbpmException("failed to set multipart content: " + multipart, e);
}
}
- else if (text != null) {
+ else {
// unipart
- text = evaluateExpression(text, execution);
+ String text = evaluateExpression(template.getText(), execution);
try {
email.setText(text);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -10,6 +10,7 @@
import javax.mail.Transport;
import javax.mail.Message.RecipientType;
import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
import org.jbpm.api.JbpmException;
import org.jbpm.pvm.internal.email.spi.MailSession;
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskAssign.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskAssign.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/events/TaskAssign.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -1,44 +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.internal.history.events;
-
-import org.jbpm.pvm.internal.history.HistoryEvent;
-
-/**
- * @author Alejandro Guizar
- */
-public class TaskAssign extends HistoryEvent {
-
- private static final long serialVersionUID = 1L;
-
- protected String userId;
-
- public TaskAssign(String userId) {
- this.userId = userId;
- }
-
- @Override
- public void process() {
- // TODO
- }
-
-}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/IdentitySessionImpl.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -21,10 +21,9 @@
*/
package org.jbpm.pvm.internal.identity.impl;
-import java.util.Arrays;
import java.util.List;
-import org.hibernate.Criteria;
+import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
@@ -40,8 +39,7 @@
protected Session session;
- public String createUser(String userName, String givenName, String familyName,
- String businessEmail) {
+ public String createUser(String userName, String givenName, String familyName, String businessEmail) {
UserImpl user = new UserImpl(userName, givenName, familyName);
user.setBusinessEmail(businessEmail);
session.save(user);
@@ -56,11 +54,7 @@
}
public List<User> findUsersById(String... userIds) {
- List users = session.createCriteria(UserImpl.class).add(Restrictions.in("id", userIds)).list();
- if (userIds.length != users.size()) {
- throw new JbpmException("not all users were found: " + Arrays.toString(userIds));
- }
- return users;
+ return session.createCriteria(UserImpl.class).add(Restrictions.in("id", userIds)).list();
}
public List<User> findUsers() {
@@ -72,9 +66,12 @@
User user = findUserById(userId);
// cascade the deletion to the memberships
- List<MembershipImpl> memberships = session.createCriteria(MembershipImpl.class)
- .add(Restrictions.eq("user", user))
- .list();
+ Query query = session.createQuery("from "
+ + MembershipImpl.class.getName()
+ + " as m "
+ + "where m.user is :user");
+ query.setEntity("user", user);
+ List<MembershipImpl> memberships = query.list();
// delete the related memberships
for (MembershipImpl membership : memberships) {
@@ -111,33 +108,43 @@
}
public GroupImpl findGroupById(String groupId) {
- return (GroupImpl) session.createCriteria(GroupImpl.class)
- .add(Restrictions.eq("id", groupId))
- .uniqueResult();
+ GroupImpl group = (GroupImpl) session.createQuery("select group "
+ + "from "
+ + GroupImpl.class.getName()
+ + " as group "
+ + "where group.id = '"
+ + groupId
+ + "'").uniqueResult();
+ return group;
}
public List<Group> findGroupsByUserAndGroupType(String userId, String groupType) {
- return session.createCriteria(MembershipImpl.class)
- .createAlias("user", "u")
- .createAlias("group", "g")
- .add(Restrictions.eq("u.id", userId))
- .add(Restrictions.eq("g.type", groupType))
- .setProjection(Projections.property("group"))
- .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
- .list();
+ Query query = session.createQuery("select distinct membership.group "
+ + "from "
+ + MembershipImpl.class.getName()
+ + " as membership "
+ + "where membership.user.id = '"
+ + userId
+ + "'"
+ + " and membership.group.type = '"
+ + groupType
+ + "'");
+ return query.list();
}
public List<Group> findGroupsByUser(String userId) {
- return session.createCriteria(MembershipImpl.class)
- .createAlias("user", "u")
- .add(Restrictions.eq("u.id", userId))
- .setProjection(Projections.property("group"))
- .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
- .list();
+ Query query = session.createQuery("select distinct membership.group "
+ + "from "
+ + MembershipImpl.class.getName()
+ + " as membership "
+ + "where membership.user.id = '"
+ + userId
+ + "'");
+ return query.list();
}
public List<Group> findGroups() {
- return session.createCriteria(GroupImpl.class).list();
+ return session.createQuery("from " + GroupImpl.class.getName()).list();
}
public void deleteGroup(String groupId) {
@@ -145,9 +152,12 @@
GroupImpl group = findGroupById(groupId);
// cascade the deletion to the memberships
- List<MembershipImpl> memberships = session.createCriteria(MembershipImpl.class)
- .add(Restrictions.eq("group", group))
- .list();
+ Query query = session.createQuery("from "
+ + MembershipImpl.class.getName()
+ + " as m "
+ + "where m.group is :group");
+ query.setEntity("group", group);
+ List<MembershipImpl> memberships = query.list();
// delete the related memberships
for (MembershipImpl membership : memberships) {
@@ -163,7 +173,7 @@
if (user == null) {
throw new JbpmException("user " + userId + " doesn't exist");
}
- Group group = findGroupById(groupId);
+ GroupImpl group = findGroupById(groupId);
if (group == null) {
throw new JbpmException("group " + groupId + " doesn't exist");
}
@@ -177,13 +187,7 @@
}
public void deleteMembership(String userId, String groupId, String role) {
- MembershipImpl membership = (MembershipImpl) session.createCriteria(MembershipImpl.class)
- .createAlias("user", "u")
- .createAlias("group", "g")
- .add(Restrictions.eq("u.id", userId))
- .add(Restrictions.eq("g.id", groupId))
- .uniqueResult();
- session.delete(membership);
+ throw new UnsupportedOperationException("please implement me");
}
public void setSession(Session session) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -363,18 +363,18 @@
// execution method : signal ////////////////////////////////////////////////
public void signal() {
- signal(null, (Map<String,?>)null);
+ signal(null, (Map)null);
}
public void signal(String signal) {
- signal(signal, (Map<String,?>)null);
+ signal(signal, (Map)null);
}
- public void signal(Map<String, ?> parameters) {
+ public void signal(Map<String, Object> parameters) {
signal(null, parameters);
}
- public void signal(String signal, Map<String, ?> parameters) {
+ public void signal(String signal, Map<String, Object> parameters) {
checkActive();
propagation = Propagation.EXPLICIT;
if (getActivity()!=null) {
@@ -387,18 +387,18 @@
}
public void signal(Execution execution) {
- ((ExecutionImpl)execution).signal(null, (Map<String,?>)null);
+ ((ExecutionImpl)execution).signal(null, (Map)null);
}
public void signal(String signalName, Execution execution) {
- ((ExecutionImpl)execution).signal(signalName, (Map<String,?>)null);
+ ((ExecutionImpl)execution).signal(signalName, (Map)null);
}
- public void signal(Map<String, ?> parameters, Execution execution) {
+ public void signal(Map<String, Object> parameters, Execution execution) {
((ExecutionImpl)execution).signal(null, parameters);
}
- public void signal(String signalName, Map<String, ?> parameters, Execution execution) {
+ public void signal(String signalName, Map<String, Object> parameters, Execution execution) {
((ExecutionImpl)execution).signal(signalName, parameters);
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ScopeInstanceImpl.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -33,10 +33,13 @@
import org.jbpm.api.Execution;
import org.jbpm.api.JbpmException;
+import org.jbpm.api.client.ClientExecution;
+import org.jbpm.api.client.ClientProcessDefinition;
import org.jbpm.api.env.Environment;
import org.jbpm.api.job.Timer;
import org.jbpm.api.session.TimerSession;
import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.hibernate.HibernatePvmDbSession;
import org.jbpm.pvm.internal.job.TimerImpl;
import org.jbpm.pvm.internal.type.Converter;
import org.jbpm.pvm.internal.type.Type;
@@ -165,15 +168,18 @@
}
}
- public void setVariables(Map<String, ?> variables) {
+ public void setVariables(Map<String, Object> variables) {
if (variables!=null) {
- for (Map.Entry<String, ?> entry : variables.entrySet()) {
- setVariable(entry.getKey(), entry.getValue());
- }
+ for (String key: variables.keySet()) {
+ Object value = variables.get(key);
+ setVariable(key, value);
+ }
}
}
public Object getVariable(String key) {
+ Object value = null;
+
Variable variable = getVariableObject(key);
if (variable!=null) {
return variable.getValue();
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/Signal.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/Signal.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/op/Signal.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -39,10 +39,10 @@
private static final Log log = Log.getLog(Signal.class.getName());
String signalName;
- Map<String, ?> parameters;
+ Map<String, Object> parameters;
ActivityImpl activity;
- public Signal(String signalName, Map<String, ?> parameters, ActivityImpl activity) {
+ public Signal(String signalName, Map<String, Object> parameters, ActivityImpl activity) {
this.signalName = signalName;
this.parameters = parameters;
this.activity = activity;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/svc/ExecutionServiceImpl.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -22,6 +22,7 @@
package org.jbpm.pvm.internal.svc;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -32,6 +33,7 @@
import org.jbpm.pvm.internal.cmd.DeleteProcessInstance;
import org.jbpm.pvm.internal.cmd.EndProcessInstance;
import org.jbpm.pvm.internal.cmd.FindExecutionCmd;
+import org.jbpm.pvm.internal.cmd.FindExecutionsCmd;
import org.jbpm.pvm.internal.cmd.GetVariableNamesCmd;
import org.jbpm.pvm.internal.cmd.GetVariablesCmd;
import org.jbpm.pvm.internal.cmd.SetVariablesCmd;
@@ -40,6 +42,7 @@
import org.jbpm.pvm.internal.cmd.StartProcessInstanceInLatestCmd;
import org.jbpm.pvm.internal.query.ProcessInstanceQueryImpl;
+
/**
* @author Tom Baeyens
*/
@@ -65,7 +68,7 @@
return commandService.execute(new StartProcessInstanceInLatestCmd(processDefinitionKey, null, null));
}
- public ProcessInstance startProcessInstanceByKey(String processDefinitionKey, Map<String, ?> variables){
+ public ProcessInstance startProcessInstanceByKey(String processDefinitionKey, Map<String, Object> variables){
return commandService.execute(new StartProcessInstanceInLatestCmd(processDefinitionKey, variables, null));
}
@@ -73,7 +76,7 @@
return commandService.execute(new StartProcessInstanceInLatestCmd(processDefinitionKey, null, executionKey));
}
- public ProcessInstance startProcessInstanceByKey(String processDefinitionKey, Map<String, ?> variables, String executionKey){
+ public ProcessInstance startProcessInstanceByKey(String processDefinitionKey, Map<String, Object> variables, String executionKey){
return commandService.execute(new StartProcessInstanceInLatestCmd(processDefinitionKey, variables, executionKey));
}
@@ -87,11 +90,11 @@
return commandService.execute(new SignalCmd(executionId, signalName, null));
}
- public ProcessInstance signalExecutionById(String executionId, String signalName, Map<String, ?> parameters) {
+ public ProcessInstance signalExecutionById(String executionId, String signalName, Map<String, Object> parameters) {
return commandService.execute(new SignalCmd(executionId, signalName, parameters));
}
- public ProcessInstance signalExecutionById(String executionId, Map<String, ?> parameters) {
+ public ProcessInstance signalExecutionById(String executionId, Map<String, Object> parameters) {
return commandService.execute(new SignalCmd(executionId, null, parameters));
}
@@ -138,7 +141,7 @@
commandService.execute(cmd);
}
- public void setVariables(String executionId, Map<String, ?> variables) {
+ public void setVariables(String executionId, Map<String, Object> variables) {
SetVariablesCmd cmd = new SetVariablesCmd(executionId);
cmd.setVariables(variables);
commandService.execute(cmd);
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycleState.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycleState.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/LifeCycleState.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -38,7 +38,7 @@
}
public void signal(ActivityExecution execution, String signalName,
- Map<String, ?> parameters) throws Exception {
+ Map<String, Object> parameters) throws Exception {
execution.take(signalName);
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskDefinitionImpl.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -24,7 +24,6 @@
import java.io.Serializable;
import java.util.List;
-import org.jbpm.pvm.internal.email.spi.MailProducer;
import org.jbpm.pvm.internal.util.Priority;
import org.jbpm.pvm.internal.wire.Descriptor;
@@ -42,8 +41,6 @@
protected SwimlaneDefinitionImpl swimlaneDefinition;
protected Descriptor taskHandlerDescriptor;
- protected transient MailProducer notificationMailProducer;
-
public int getPriority() {
return priority;
}
@@ -80,10 +77,4 @@
public void setTaskHandlerDescriptor(Descriptor taskHandlerDescriptor) {
this.taskHandlerDescriptor = taskHandlerDescriptor;
}
- public MailProducer getNotificationMailProducer() {
- return notificationMailProducer;
- }
- public void setNotificationMailProducer(MailProducer notificationMailProducer) {
- this.notificationMailProducer = notificationMailProducer;
- }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/TaskImpl.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -23,15 +23,12 @@
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import javax.mail.Message;
-
import org.jbpm.api.Execution;
import org.jbpm.api.JbpmException;
import org.jbpm.api.env.Environment;
@@ -43,9 +40,6 @@
import org.jbpm.api.task.Swimlane;
import org.jbpm.api.task.Task;
import org.jbpm.api.task.TaskHandler;
-import org.jbpm.pvm.internal.email.spi.MailProducer;
-import org.jbpm.pvm.internal.email.spi.MailSession;
-import org.jbpm.pvm.internal.history.events.TaskAssign;
import org.jbpm.pvm.internal.history.events.TaskCancel;
import org.jbpm.pvm.internal.history.events.TaskComplete;
import org.jbpm.pvm.internal.history.events.TaskStart;
@@ -58,15 +52,16 @@
import org.jbpm.pvm.internal.wire.WireContext;
/**
- * is one task instance that can be assigned to an actor (read: put in someone's task list) and that
- * can trigger the continuation of execution of the token upon completion.
+ * is one task instance that can be assigned to an actor (read: put in
+ * someones task list) and that can trigger the continuation of execution
+ * of the token upon completion.
*/
public class TaskImpl extends ScopeInstanceImpl implements Serializable, OpenTask, Assignable {
private static final long serialVersionUID = 1L;
-
+
// private static Log log = Log.getLog(TaskImpl.class.getName());
-
+
private static final TaskHandler DEFAULT_TASK_HANDLER = new TaskHandler();
protected String name;
@@ -90,66 +85,48 @@
protected String taskDefinitionName;
protected TaskDefinitionImpl taskDefinition;
-
+
protected ExecutionImpl execution;
protected ExecutionImpl processInstance;
protected SwimlaneImpl swimlane;
-
+
protected TaskImpl superTask;
protected Set<TaskImpl> subTasks;
-
+
protected Long executionDbid;
protected Long superTaskDbid;
public TaskImpl() {
}
-
+
// parent for variable lookup ///////////////////////////////////////////////
public ScopeInstanceImpl getParentVariableScope() {
return execution;
}
-
+
// assignment ///////////////////////////////////////////////////////////////
-
+
public void take(String userId) {
- if (assignee != null) {
- throw new JbpmException("task already taken by " + this.assignee);
+ if (assignee!=null) {
+ throw new JbpmException("task already taken by "+this.assignee);
}
setAssignee(userId, true);
}
-
+
public void setAssignee(String userId) {
- setAssignee(userId, false);
+ this.assignee = userId;
}
public void setAssignee(String userId, boolean propagateToSwimlane) {
this.assignee = userId;
- notifyAssignee();
if (propagateToSwimlane) {
propagateAssigneeToSwimlane();
}
}
- protected void notifyAssignee() {
- if (taskDefinition == null) return;
-
- MailProducer mailProducer = taskDefinition.getNotificationMailProducer();
- if (mailProducer == null) return;
-
- // TODO how to insert predefined variables cleanly?
- execution.setVariable("task", this);
- try {
- Collection<Message> messages = mailProducer.produce(execution);
- Environment.getFromCurrent(MailSession.class).send(messages);
- }
- finally {
- execution.removeVariable("task");
- }
- }
-
protected void propagateAssigneeToSwimlane() {
- if (swimlane != null) {
+ if (swimlane!=null) {
swimlane.setAssignee(assignee);
}
}
@@ -158,7 +135,7 @@
// TODO: Why does it return the impl. not the interface?
public Set<ParticipationImpl> getParticipations() {
- if (participations == null) {
+ if (participations ==null) {
return Collections.emptySet();
}
return participations;
@@ -166,18 +143,17 @@
public Set<ParticipationImpl> getAllParticipants() {
Set<ParticipationImpl> allRoles = null;
- if (participations != null) {
+ if (participations !=null) {
allRoles = new HashSet<ParticipationImpl>(participations);
- }
- else {
+ } else {
allRoles = new HashSet<ParticipationImpl>();
}
- if (swimlane != null) {
- allRoles.addAll((Set) swimlane.getParticipations());
+ if (swimlane!=null) {
+ allRoles.addAll((Set)swimlane.getParticipations());
}
return allRoles;
}
-
+
public void addCandidateGroup(String groupId) {
addParticipation(null, groupId, Participation.CANDIDATE);
}
@@ -189,10 +165,10 @@
public Participation addParticipation(String userId, String groupId, String type) {
return addParticipant(new ParticipationImpl(userId, groupId, type));
}
-
+
private Participation addParticipant(ParticipationImpl participation) {
participation.setTask(this);
- if (participations == null) {
+ if (participations ==null) {
participations = new HashSet<ParticipationImpl>();
}
participations.add(participation);
@@ -200,14 +176,16 @@
}
public void removeParticipant(ParticipationImpl participation) {
- if (participation == null) {
+ if (participation==null) {
throw new JbpmException("participant is null");
}
- if ((participations != null) && (participations.remove(participation))) {
+ if ( (participations !=null)
+ && (participations.remove(participation))
+ ) {
participation.setTask(null);
}
}
-
+
// completion ///////////////////////////////////////////////////////////////
public void complete() {
@@ -216,7 +194,7 @@
public void complete(String outcome) {
getTaskHandler().taskComplete(this, outcome);
- if (superTask != null) {
+ if (superTask!=null) {
superTask.subTaskComplete(this, outcome);
}
}
@@ -228,21 +206,23 @@
public void cancel(String reason) {
getTaskHandler().taskCancel(this, reason);
}
-
+
// state ////////////////////////////////////////////////////////////////////
-
+
public boolean isCompleted() {
if (Task.STATE_COMPLETED.equals(state)) {
return true;
}
- if ((Task.STATE_OPEN.equals(state)) || (Task.STATE_SUSPENDED.equals(state))) {
+ if ( (Task.STATE_OPEN.equals(state))
+ || (Task.STATE_SUSPENDED.equals(state))
+ ) {
return false;
}
return true;
}
// variables ////////////////////////////////////////////////////////////////
-
+
public void setVariable(String key, Object value) {
super.setVariable(key, value);
getTaskHandler().taskVariableUpdate(this, key, value);
@@ -251,14 +231,14 @@
// comments /////////////////////////////////////////////////////////////////
public List<Comment> getComments() {
- if (comments == null) {
+ if (comments==null) {
return Collections.emptyList();
}
return (List) comments;
}
public Comment createComment(String commentText) {
- if (comments == null) {
+ if (comments==null) {
comments = new ArrayList<CommentImpl>();
}
CommentImpl comment = new CommentImpl(commentText);
@@ -267,18 +247,18 @@
}
public void removeComment(Comment comment) {
- if (comment == null) {
+ if (comment==null) {
throw new JbpmException("comment is null");
}
- if (comments != null) {
+ if (comments!=null) {
comments.remove(comment);
}
}
-
+
// subtasks /////////////////////////////////////////////////////////////////
-
+
public Set<Task> getSubTasks() {
- if (subTasks == null) {
+ if (subTasks==null) {
return Collections.emptySet();
}
return (Set) subTasks;
@@ -287,7 +267,7 @@
public TaskImpl createSubTask() {
TaskDbSession taskDbSession = Environment.getFromCurrent(TaskDbSession.class);
TaskImpl subTask = (TaskImpl) taskDbSession.createTask();
- if (subTasks == null) {
+ if (subTasks==null) {
subTasks = new HashSet<TaskImpl>();
}
addSubTask(subTask);
@@ -301,9 +281,9 @@
subtask.setName(name);
return subtask;
}
-
+
public TaskImpl addSubTask(TaskImpl subtask) {
- if (subTasks == null) {
+ if (subTasks==null) {
subTasks = new HashSet<TaskImpl>();
}
subtask.setSuperTask(this);
@@ -312,242 +292,211 @@
}
public void removeSubTask(Task subtask) {
- if (subtask == null) {
+ if (subtask==null) {
throw new JbpmException("subtask is null");
}
- if ((subTasks != null) && (subTasks.remove(subtask))) {
- ((TaskImpl) subtask).setSuperTask(null);
+ if ( (subTasks!=null)
+ && (subTasks.remove(subtask))
+ ) {
+ ((TaskImpl)subtask).setSuperTask(null);
}
}
-
+
// equals ///////////////////////////////////////////////////////////////////
// hack to support comparing hibernate proxies against the real objects
// since this always falls back to ==, we don't need to overwrite the hashcode
public boolean equals(Object o) {
return EqualsUtil.equals(this, o);
}
-
+
public String toString() {
- return "Task(" + name + ")";
+ return "Task("+name+")";
}
public String getLifeCycleResource() {
// the default lifecycle can be overridden in subclasses
return "jbpm.task.lifecycle.xml";
}
-
+
// modified getters and setters /////////////////////////////////////////////
public void setProgress(Integer progress) {
- if ((progress < 0) || (progress > 100)) {
- throw new JbpmException(
- "task progress is a percentage (integer) and must be expressed between 0 and 100");
+ if ( (progress<0)
+ || (progress>100)
+ ) {
+ throw new JbpmException("task progress is a percentage (integer) and must be expressed between 0 and 100");
}
this.progress = progress;
}
public boolean isPersisted() {
- return dbid != 0;
+ return dbid!=0;
}
public void cancelExecution(String signal) {
- if (execution != null) {
+ if (execution!=null){
execution.end("cancel");
}
}
- public void historyTaskStart() {
- if (execution != null) {
- execution.fireHistoryEvent(new TaskStart(this));
- }
- }
-
- public void historyTaskAssign(String userId) {
- if (execution != null) {
- execution.fireHistoryEvent(new TaskAssign(userId));
- }
- }
-
public void historyTaskCancel(String reason) {
- if (execution != null) {
+ if (execution!=null){
execution.fireHistoryEvent(new TaskCancel(reason));
}
}
public void historyTaskComplete(String outcome) {
- if (execution != null) {
+ if (execution!=null){
execution.fireHistoryEvent(new TaskComplete(outcome));
}
}
+ public void historyTaskStart() {
+ if (execution!=null){
+ execution.fireHistoryEvent(new TaskStart(this));
+ }
+ }
+
public void signalExecution(String signalName) {
- if (execution != null) {
+ if (execution!=null){
execution.signal(signalName);
}
}
public TaskHandler getTaskHandler() {
- if ((getTaskDefinition() == null) || (taskDefinition.getTaskHandlerDescriptor() == null)) {
+ if ( (getTaskDefinition()==null)
+ || (taskDefinition.getTaskHandlerDescriptor()==null)
+ ) {
return DEFAULT_TASK_HANDLER;
}
-
+
TaskHandler taskHandler = (TaskHandler) WireContext.create(taskDefinition.getTaskHandlerDescriptor());
return taskHandler;
}
-
+
// special getters and setters //////////////////////////////////////////////
-
+
public TaskDefinitionImpl getTaskDefinition() {
- if ((taskDefinition == null) && (taskDefinitionName != null) && (execution != null)) {
+ if ( (taskDefinition==null)
+ && (taskDefinitionName!=null)
+ && (execution!=null)
+ ) {
ProcessDefinitionImpl processDefinition = execution.getProcessDefinition();
taskDefinition = processDefinition.getTaskDefinition(taskDefinitionName);
}
-
+
return taskDefinition;
}
-
+
public void setTaskDefinition(TaskDefinitionImpl taskDefinition) {
this.taskDefinition = taskDefinition;
this.taskDefinitionName = taskDefinition.getName();
}
+
// getters and setters //////////////////////////////////////////////////////
-
+
public long getDbid() {
return dbid;
}
-
public String getName() {
return name;
}
-
public void setName(String name) {
this.name = name;
}
-
public String getDescription() {
return description;
}
-
public void setDescription(String description) {
this.description = description;
}
-
public int getPriority() {
return priority;
}
-
public void setPriority(int priority) {
this.priority = priority;
}
-
public void setComments(List<CommentImpl> comments) {
this.comments = comments;
}
-
public Date getCreate() {
return create;
}
-
public void setCreate(Date create) {
this.create = create;
}
-
public Date getDueDate() {
return dueDate;
}
-
public void setDueDate(Date dueDate) {
this.dueDate = dueDate;
}
-
public ExecutionImpl getExecution() {
return execution;
}
-
public void setExecution(Execution execution) {
this.execution = (ExecutionImpl) execution;
}
-
public String getState() {
return state;
}
-
public String getAssignee() {
return assignee;
}
-
public Swimlane getSwimlane() {
return swimlane;
}
-
public void setSwimlane(SwimlaneImpl swimlane) {
this.swimlane = swimlane;
}
-
public TaskImpl getSuperTask() {
return superTask;
}
-
public void setSuperTask(TaskImpl superTask) {
this.superTask = superTask;
}
-
public Integer getProgress() {
return progress;
}
-
public Long getExecutionDbid() {
return executionDbid;
}
-
public void setExecutionDbid(Long executionDbid) {
this.executionDbid = executionDbid;
}
-
public Long getSuperTaskDbid() {
return superTaskDbid;
}
-
public void setSuperTaskDbid(Long parentTaskDbid) {
this.superTaskDbid = parentTaskDbid;
}
-
public void setParticipations(Set<ParticipationImpl> participations) {
this.participations = participations;
}
-
public void setState(String state) {
this.state = state;
}
-
public void setExecution(ExecutionImpl execution) {
this.execution = execution;
}
-
public void setSubTasks(Set<TaskImpl> subTasks) {
this.subTasks = subTasks;
}
-
public ExecutionImpl getProcessInstance() {
return processInstance;
}
-
public void setProcessInstance(ExecutionImpl processInstance) {
this.processInstance = processInstance;
}
-
public boolean isSignalling() {
return isSignalling;
}
-
public void setSignalling(boolean isSignalling) {
this.isSignalling = isSignalling;
}
-
public String getForm() {
return form;
}
-
public void setForm(String form) {
this.form = form;
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -247,11 +247,14 @@
}
public static boolean isTextOnly(Element element) {
- for (Node child = element.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child.getNodeType() == Node.ELEMENT_NODE)
- return false;
+ boolean isTextOnly = true;
+ NodeList activityList = element.getChildNodes();
+ for (int i = 0; ((i < activityList.getLength()) && (isTextOnly)); i++) {
+ if (Element.class.isAssignableFrom(activityList.item(i).getClass())) {
+ isTextOnly = false;
+ }
}
- return true;
+ return isTextOnly;
}
public static List<Attr> attributes(Element element) {
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailTemplateBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailTemplateBinding.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailTemplateBinding.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -47,7 +47,7 @@
public Object parse(Element element, Parse parse, Parser parser) {
// MailTemplateRegistry is added to the WireDescriptor with a ProvidedObjectDescriptor
// The MailTemplateRegistry descriptor is lazy initialized by this binding
- // mail-template will add a MailTemplate to the MailTemplateRegistry
+ // mail-templates will add a MailTemplate to the MailTemplateRegistry
ProvidedObjectDescriptor templateRegistryDescriptor;
MailTemplateRegistry templateRegistry;
@@ -57,6 +57,7 @@
if (templateRegistryDescriptorName != null) {
templateRegistryDescriptor = (ProvidedObjectDescriptor) wireDefinition.getDescriptor(templateRegistryDescriptorName);
templateRegistry = (MailTemplateRegistry) templateRegistryDescriptor.getProvidedObject();
+ templateRegistryDescriptor = null; // setting it to null so that the wire parser doesn't add it to the wiredefinition again
}
else {
templateRegistry = new MailTemplateRegistry();
@@ -64,21 +65,21 @@
}
// create the mail template and add it to the registry
- MailTemplate mailTemplate = parseMailTemplate(element, parse);
+ MailTemplate mailTemplate = parseMailTemplate(element, parse, parser);
String templateName = XmlUtil.attribute(element, "name", true, parse);
templateRegistry.addTemplate(templateName, mailTemplate);
return templateRegistryDescriptor;
}
- public static MailTemplate parseMailTemplate(Element element, Parse parse) {
+ public MailTemplate parseMailTemplate(Element element, Parse parse, Parser parser) {
MailTemplate mailTemplate = new MailTemplate();
mailTemplate.setLanguage(XmlUtil.attribute(element, "language"));
- mailTemplate.setFrom(parseRecipientTemplate(element, "from", parse));
- mailTemplate.setTo(parseRecipientTemplate(element, "to", parse));
- mailTemplate.setCc(parseRecipientTemplate(element, "cc", parse));
- mailTemplate.setBcc(parseRecipientTemplate(element, "bcc", parse));
+ mailTemplate.setFrom(parseRecipientTemplate(element, "from", parse, parser));
+ mailTemplate.setTo(parseRecipientTemplate(element, "to", parse, parser));
+ mailTemplate.setCc(parseRecipientTemplate(element, "cc", parse, parser));
+ mailTemplate.setBcc(parseRecipientTemplate(element, "bcc", parse, parser));
Element subjectElement = XmlUtil.element(element, "subject");
if (subjectElement != null) {
@@ -116,22 +117,15 @@
return mailTemplate;
}
- private static AddressTemplate parseRecipientTemplate(Element element, String tagName, Parse parse) {
+ protected AddressTemplate parseRecipientTemplate(Element element, String tagName, Parse parse,
+ Parser parser) {
Element recipientElement = XmlUtil.element(element, tagName);
if (recipientElement == null) return null;
- String addresses = XmlUtil.attribute(recipientElement, "addresses");
- String users = XmlUtil.attribute(recipientElement, "users");
- String groups = XmlUtil.attribute(recipientElement, "groups");
-
- if (addresses == null && users == null && groups == null) {
- parse.addProblem(tagName + " does not specify any recipient", element);
- }
-
AddressTemplate addressTemplate = new AddressTemplate();
- addressTemplate.setAddresses(addresses);
- addressTemplate.setUsers(users);
- addressTemplate.setGroups(groups);
+ addressTemplate.setAddresses(XmlUtil.attribute(recipientElement, "addresses"));
+ addressTemplate.setUsers(XmlUtil.attribute(recipientElement, "users"));
+ addressTemplate.setGroups(XmlUtil.attribute(recipientElement, "groups"));
return addressTemplate;
}
}
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/activities/WaitState.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/activities/WaitState.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/activities/WaitState.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -39,7 +39,7 @@
public void signal(ActivityExecution execution,
String signalName,
- Map<String, ?> parameters) {
+ Map<String, Object> parameters) {
execution.setVariables(parameters);
execution.take(signalName);
}
Modified: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/WaitState.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/WaitState.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/executionmode/embedded/WaitState.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -40,7 +40,7 @@
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) throws Exception {
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
execution.take(signalName);
}
}
\ No newline at end of file
Modified: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/async/ExclusiveMessagesTest.java
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/async/ExclusiveMessagesTest.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/async/ExclusiveMessagesTest.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -92,7 +92,7 @@
public void execute(ActivityExecution execution) throws Exception {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) throws Exception {
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
execution.take(signalName);
}
}
Modified: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/async/WaitState.java
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/async/WaitState.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/async/WaitState.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -40,7 +40,7 @@
ContinuationTest.recorder.record(execution.getId(), "execute("+execution.getActivity().getName()+")");
}
- public void signal(ActivityExecution execution, String signal, Map<String, ?> parameters) throws Exception {
+ public void signal(ActivityExecution execution, String signal, Map<String, Object> parameters) throws Exception {
throw new UnsupportedOperationException();
}
}
\ No newline at end of file
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticDecisionTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticDecisionTest.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/AutomaticDecisionTest.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -60,7 +60,7 @@
public void execute(ActivityExecution execution) {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
execution.take(signalName);
}
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/BasicExecutionFlowTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/BasicExecutionFlowTest.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/BasicExecutionFlowTest.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -64,7 +64,7 @@
events.add("execute["+execution.getActivityName()+"]");
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) throws Exception {
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
events.add("signal["+execution.getActivityName()+"]");
execution.take(signalName);
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventTest.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/EventTest.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -170,7 +170,7 @@
public void execute(ActivityExecution execution) throws Exception {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signal, Map<String, ?> parameters) throws Exception {
+ public void signal(ActivityExecution execution, String signal, Map<String, Object> parameters) throws Exception {
Activity activity = execution.getActivity();
if ( (signal!=null)
&& (activity!=null)
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExceptionHandlerTest.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -44,7 +44,7 @@
public void execute(ActivityExecution execution) {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters){
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters){
}
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExecutionStateTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExecutionStateTest.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExecutionStateTest.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -70,7 +70,7 @@
assertEquals(Execution.STATE_ACTIVE_ROOT, execution.getState());
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
assertEquals(Execution.STATE_ACTIVE_ROOT, execution.getState());
execution.take(signalName);
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExternalDecisionTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExternalDecisionTest.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ExternalDecisionTest.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -42,7 +42,7 @@
public void execute(ActivityExecution execution) throws Exception {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) throws Exception {
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
execution.take(signalName);
}
}
@@ -52,7 +52,7 @@
public void execute(ActivityExecution execution) {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
execution.take(signalName);
}
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/FunctionalActivityTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/FunctionalActivityTest.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/FunctionalActivityTest.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -141,7 +141,7 @@
Activity nestedActivity = execution.getActivity().getActivities().get(0);
execution.execute(nestedActivity);
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
}
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/LoopingTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/LoopingTest.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/LoopingTest.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -45,7 +45,7 @@
}
}
}
- public void signal(ActivityExecution execution, String signal, Map<String, ?> parameters) throws Exception {
+ public void signal(ActivityExecution execution, String signal, Map<String, Object> parameters) throws Exception {
throw new UnsupportedOperationException();
}
@@ -77,7 +77,7 @@
public void execute(ActivityExecution execution) {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters){
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters){
}
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeStateTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeStateTest.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeStateTest.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -51,7 +51,7 @@
assertEquals(Execution.STATE_ACTIVE_ROOT, execution.getState());
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) throws Exception {
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
assertEquals(Execution.STATE_ACTIVE_ROOT, execution.getState());
execution.take(signalName);
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableDeclarationTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableDeclarationTest.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableDeclarationTest.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -45,7 +45,7 @@
public void execute(ActivityExecution execution) {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
execution.take(signalName);
}
}
@@ -56,7 +56,7 @@
Activity child = execution.getActivity().getActivities().get(0);
execution.execute(child);
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
}
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableTest.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/ScopeVariableTest.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -23,6 +23,7 @@
import java.util.Map;
+import org.jbpm.api.JbpmException;
import org.jbpm.api.activity.ActivityExecution;
import org.jbpm.api.activity.ExternalActivityBehaviour;
import org.jbpm.api.client.ClientExecution;
@@ -49,7 +50,7 @@
public void execute(ActivityExecution execution) {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
execution.take(signalName);
}
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/SubProcessTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/SubProcessTest.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/SubProcessTest.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -51,7 +51,7 @@
execution.waitForSignal();
}
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) throws Exception {
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
}
}
@@ -66,12 +66,11 @@
public void execute(ActivityExecution execution) {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters){
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters){
}
}
public static class EndState implements ActivityBehaviour {
- private static final long serialVersionUID = 1L;
public void execute(ActivityExecution execution) throws Exception {
execution.end();
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/VariableTest.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/VariableTest.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/VariableTest.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -44,7 +44,7 @@
public void execute(ActivityExecution execution) {
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters){
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters){
}
}
@@ -195,7 +195,7 @@
execution.setVariable("message", "Killroy was here");
execution.waitForSignal();
}
- public void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) {
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) {
}
}
Modified: jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/WaitState.java
===================================================================
--- jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/WaitState.java 2009-05-21 06:16:03 UTC (rev 4865)
+++ jbpm4/trunk/modules/test-pojo/src/main/java/org/jbpm/test/activities/WaitState.java 2009-05-21 07:42:27 UTC (rev 4866)
@@ -39,6 +39,6 @@
public void signal(ActivityExecution execution,
String signalName,
- Map<String, ?> parameters) {
+ Map<String, Object> parameters) {
}
}
16 years, 11 months