JBoss JBPM SVN: r5985 - in jbpm4/trunk/modules: examples/src/test/java/org/jbpm/examples and 18 other directories.
by do-not-reply@jboss.org
Author: koen.aers(a)jboss.com
Date: 2009-12-17 19:39:59 -0500 (Thu, 17 Dec 2009)
New Revision: 5985
Added:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/ejb/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/jms/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/jms/map/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/jms/map/MapMessageTest.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/jms/object/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/jms/object/ObjectMessageTest.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/jms/text/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/jms/text/TextMessageTest.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/ejb/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/ejb/process.jpdl.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/jms/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/jms/map/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/jms/map/process.jpdl.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/jms/object/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/jms/object/process.jpdl.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/jms/text/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/jms/text/process.jpdl.xml
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/jms/
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/jms/JbpmJmsMockTestCase.java
Removed:
jbpm4/trunk/modules/test-enterprise/test-enterprise-ejb/src/main/java/org/jbpm/test/enterprise/mdb/
Modified:
jbpm4/trunk/modules/examples/.classpath
jbpm4/trunk/modules/examples/pom.xml
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JavaBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsBinding.java
jbpm4/trunk/modules/test-base/pom.xml
jbpm4/trunk/modules/test-cactus/pom.xml
jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/ejb/EjbTest.java
jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/map/MapMessageTest.java
Log:
In memory test of the JMS activity with MockRunner
Modified: jbpm4/trunk/modules/examples/.classpath
===================================================================
--- jbpm4/trunk/modules/examples/.classpath 2009-12-17 23:23:31 UTC (rev 5984)
+++ jbpm4/trunk/modules/examples/.classpath 2009-12-18 00:39:59 UTC (rev 5985)
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
- <classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
Modified: jbpm4/trunk/modules/examples/pom.xml
===================================================================
--- jbpm4/trunk/modules/examples/pom.xml 2009-12-17 23:23:31 UTC (rev 5984)
+++ jbpm4/trunk/modules/examples/pom.xml 2009-12-18 00:39:59 UTC (rev 5985)
@@ -77,6 +77,24 @@
<artifactId>spring</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.mockejb</groupId>
+ <artifactId>mockejb</artifactId>
+ <version>0.6-beta2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib-nodep</artifactId>
+ <version>2.1_3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>apache-oro</groupId>
+ <artifactId>jakarta-oro</artifactId>
+ <version>2.0.8</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/jms/map/MapMessageTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/jms/map/MapMessageTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/jms/map/MapMessageTest.java 2009-12-18 00:39:59 UTC (rev 5985)
@@ -0,0 +1,38 @@
+package org.jbpm.examples.jms.map;
+
+import javax.jms.Connection;
+import javax.jms.MapMessage;
+import javax.jms.MessageConsumer;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+
+import org.jbpm.test.jms.JbpmJmsMockTestCase;
+
+public class MapMessageTest extends JbpmJmsMockTestCase {
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ bindToContext("ConnectionFactory", getConnectionFactory());
+ bindToContext("queue/jbpm-test-queue", getQueue());
+ registerDeployment(repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/examples/jms/map/process.jpdl.xml")
+ .deploy());
+ }
+
+ public void testJmsMap() throws Exception {
+ Connection connection = getConnectionFactory().createConnection();
+ Session session = connection.createSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+ connection.start();
+ MessageConsumer messageConsumer = session.createConsumer(getQueue());
+
+ executionService.startProcessInstanceByKey("JMS_map_queue");
+ MapMessage mapMessage = (MapMessage)messageConsumer.receive();
+ assertTrue(mapMessage.itemExists("x"));
+ assertEquals("foo", mapMessage.getObject("x"));
+
+ connection.stop();
+ session.close();
+ connection.close();
+ }
+
+}
Property changes on: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/jms/map/MapMessageTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/jms/object/ObjectMessageTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/jms/object/ObjectMessageTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/jms/object/ObjectMessageTest.java 2009-12-18 00:39:59 UTC (rev 5985)
@@ -0,0 +1,46 @@
+package org.jbpm.examples.jms.object;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jms.Connection;
+import javax.jms.MessageConsumer;
+import javax.jms.ObjectMessage;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+
+import org.jbpm.test.jms.JbpmJmsMockTestCase;
+
+public class ObjectMessageTest extends JbpmJmsMockTestCase
+{
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ bindToContext("ConnectionFactory", getConnectionFactory());
+ bindToContext("queue/jbpm-test-queue", getQueue());
+ registerDeployment(repositoryService
+ .createDeployment()
+ .addResourceFromClasspath("org/jbpm/examples/jms/object/process.jpdl.xml")
+ .deploy());
+ }
+
+ public void testQueueMessage() throws Exception
+ {
+ Connection connection = getConnectionFactory().createConnection();
+ Session session = connection.createSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+ connection.start();
+ MessageConsumer messageConsumer = session.createConsumer(getQueue());
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("object", "this is the object");
+ executionService.startProcessInstanceByKey("JMS_object_queue", variables);
+ ObjectMessage objectMessage = (ObjectMessage)messageConsumer.receive();
+ assertEquals("this is the object", objectMessage.getObject());
+
+ connection.stop();
+ session.close();
+ connection.close();
+ }
+
+}
Property changes on: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/jms/object/ObjectMessageTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/jms/text/TextMessageTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/jms/text/TextMessageTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/jms/text/TextMessageTest.java 2009-12-18 00:39:59 UTC (rev 5985)
@@ -0,0 +1,66 @@
+/*
+ * 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.jms.text;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.jbpm.test.jms.JbpmJmsMockTestCase;
+
+/**
+ * @author Koen Aers
+ */
+public class TextMessageTest extends JbpmJmsMockTestCase
+{
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ bindToContext("ConnectionFactory", getConnectionFactory());
+ bindToContext("queue/jbpm-test-queue", getQueue());
+ registerDeployment(repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/examples/jms/text/process.jpdl.xml")
+ .deploy());
+ }
+
+ public void testTextMessage() throws JMSException
+ {
+ Connection connection = getConnectionFactory().createConnection();
+ Session session = connection.createSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+ connection.start();
+ MessageConsumer messageConsumer = session.createConsumer(getQueue());
+
+ executionService.startProcessInstanceByKey("JMS_text_queue");
+ TextMessage textMessage = (TextMessage)messageConsumer.receive();
+ assertEquals("This is the body", textMessage.getText());
+
+ connection.stop();
+ session.close();
+ connection.close();
+
+ }
+
+}
Property changes on: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/jms/text/TextMessageTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/ejb/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/ejb/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/ejb/process.jpdl.xml 2009-12-18 00:39:59 UTC (rev 5985)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="EJB" xmlns="http://jbpm.org/4.3/jpdl">
+
+ <start g="20,20,48,48">
+ <transition to="calculate" />
+ </start>
+
+ <java name="calculate"
+ jndi="CalculatorBean"
+ method="add"
+ var="answer"
+ g="96,16,83,52">
+
+ <arg><int value="25"/></arg>
+ <arg><int value="38"/></arg>
+
+ <transition to="wait" />
+ </java>
+
+ <state name="wait" g="352,17,88,52"/>
+
+</process>
Property changes on: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/ejb/process.jpdl.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/jms/map/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/jms/map/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/jms/map/process.jpdl.xml 2009-12-18 00:39:59 UTC (rev 5985)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="JMS_map_queue">
+
+ <start g="20,20,48,48">
+ <transition to="send message" />
+ </start>
+
+ <jms name="send message"
+ connection-factory="ConnectionFactory"
+ destination="queue/jbpm-test-queue"
+ g="96,16,83,52">
+ <map>
+ <entry>
+ <key><string value="x"/></key>
+ <value><string value="foo"/></value>
+ </entry>
+ </map>
+ <transition to="wait" />
+ </jms>
+
+ <state name="wait" g="352,17,88,52"/>
+
+</process>
Property changes on: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/jms/map/process.jpdl.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/jms/object/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/jms/object/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/jms/object/process.jpdl.xml 2009-12-18 00:39:59 UTC (rev 5985)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="JMS_object_queue">
+
+ <start g="20,20,48,48">
+ <transition to="send message" />
+ </start>
+
+ <jms name="send message"
+ connection-factory="ConnectionFactory"
+ destination="queue/jbpm-test-queue"
+ g="96,16,83,52">
+ <object expr="${object}"/>
+ <transition to="wait" />
+ </jms>
+
+ <state name="wait" g="352,17,88,52"/>
+
+</process>
Property changes on: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/jms/object/process.jpdl.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/jms/text/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/jms/text/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/jms/text/process.jpdl.xml 2009-12-18 00:39:59 UTC (rev 5985)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<process name="JMS_text_queue">
+
+ <start g="20,20,48,48">
+ <transition to="send message" />
+ </start>
+
+ <jms name="send message"
+ connection-factory="ConnectionFactory"
+ destination="queue/jbpm-test-queue"
+ g="96,16,83,52">
+ <text>This is the body</text>
+ <transition to="wait" />
+ </jms>
+
+ <state name="wait" g="352,17,88,52"/>
+
+</process>
Property changes on: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/jms/text/process.jpdl.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JavaBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JavaBinding.java 2009-12-17 23:23:31 UTC (rev 5984)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JavaBinding.java 2009-12-18 00:39:59 UTC (rev 5985)
@@ -44,6 +44,7 @@
JavaActivity javaActivity = new JavaActivity();
if (XmlUtil.attribute(element, "method", true, parse, null)!=null) {
+
UserCodeReference invocationReference = parser.parseUserCodeReference(element, parse);
javaActivity.setInvocationReference(invocationReference);
@@ -54,6 +55,8 @@
javaActivity.setMethodName(objectDescriptor.getMethodName());
objectDescriptor.setMethodName(null);
+ } else {
+ // TODO Add problem to parse
}
String variableName = XmlUtil.attribute(element, "var");
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsBinding.java 2009-12-17 23:23:31 UTC (rev 5984)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/JmsBinding.java 2009-12-18 00:39:59 UTC (rev 5985)
@@ -25,8 +25,6 @@
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
import org.jbpm.pvm.internal.wire.descriptor.MapDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.pvm.internal.xml.Binding;
import org.jbpm.pvm.internal.xml.Parse;
import org.w3c.dom.Element;
@@ -63,21 +61,18 @@
Element objectElement = XmlUtil.element(element, "object", false, parse);
if (objectElement != null)
{
- String expr = XmlUtil.attribute(objectElement, "expr");
- if (expr != null)
- {
- jmsActivity.setType("object");
- jmsActivity.setExpression(expr);
- }
+ jmsActivity.setType("object");
+ jmsActivity.setExpression(XmlUtil.attribute(objectElement, "expr"));
}
Element mapElement = XmlUtil.element(element, "map", false, parse);
if (mapElement != null) {
- Descriptor descriptor = parser.parseObjectDescriptor(mapElement, parse);
- if (descriptor instanceof MapDescriptor) {
+ jmsActivity.setType("map");
+ Descriptor descriptor = parser.parseDescriptor(mapElement, parse);
+ if (descriptor instanceof MapDescriptor) {
jmsActivity.setMapDescriptor((MapDescriptor)descriptor);
} else {
- System.out.println("descriptor is not of class MadDescriptor");
+ parse.addProblem("the parser did not return a descriptor of type MapDescriptor");
}
}
Modified: jbpm4/trunk/modules/test-base/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-base/pom.xml 2009-12-17 23:23:31 UTC (rev 5984)
+++ jbpm4/trunk/modules/test-base/pom.xml 2009-12-18 00:39:59 UTC (rev 5985)
@@ -63,6 +63,11 @@
<artifactId>spring-mock</artifactId>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>com.mockrunner</groupId>
+ <artifactId>mockrunner</artifactId>
+ <version>0.4.1</version>
+ </dependency>
</dependencies>
<!-- Plugins -->
Added: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/jms/JbpmJmsMockTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/jms/JbpmJmsMockTestCase.java (rev 0)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/jms/JbpmJmsMockTestCase.java 2009-12-18 00:39:59 UTC (rev 5985)
@@ -0,0 +1,99 @@
+package org.jbpm.test.jms;
+import javax.jms.ConnectionFactory;
+import javax.jms.Queue;
+
+import org.jbpm.test.JbpmTestCase;
+
+import com.mockrunner.ejb.EJBTestModule;
+import com.mockrunner.jms.DestinationManager;
+import com.mockrunner.jms.JMSTestModule;
+import com.mockrunner.mock.ejb.EJBMockObjectFactory;
+import com.mockrunner.mock.jms.JMSMockObjectFactory;
+
+
+public class JbpmJmsMockTestCase extends JbpmTestCase
+{
+
+ private EJBMockObjectFactory ejbMockFactory;
+ private JMSMockObjectFactory jmsMockFactory;
+ private EJBTestModule ejbTestModule;
+ private JMSTestModule jmsTestModule;
+
+ private ConnectionFactory connectionFactory;
+ private Queue queue;
+
+ private EJBTestModule createEJBTestModule()
+ {
+ return new EJBTestModule(getEJBMockObjectFactory());
+ }
+
+ private EJBMockObjectFactory createEJBMockObjectFactory()
+ {
+ return new EJBMockObjectFactory();
+ }
+
+ private EJBMockObjectFactory getEJBMockObjectFactory()
+ {
+ synchronized(EJBMockObjectFactory.class)
+ {
+ if(ejbMockFactory == null)
+ {
+ ejbMockFactory = createEJBMockObjectFactory();
+ }
+ }
+ return ejbMockFactory;
+ }
+
+ private JMSTestModule createJMSTestModule(JMSMockObjectFactory mockFactory)
+ {
+ return new JMSTestModule(mockFactory);
+ }
+
+ private JMSMockObjectFactory createJMSMockObjectFactory()
+ {
+ return new JMSMockObjectFactory();
+ }
+
+ private JMSMockObjectFactory getJMSMockObjectFactory()
+ {
+ synchronized(JMSMockObjectFactory.class)
+ {
+ if(jmsMockFactory == null)
+ {
+ jmsMockFactory = createJMSMockObjectFactory();
+ }
+ }
+ return jmsMockFactory;
+ }
+
+ private DestinationManager getDestinationManager()
+ {
+ return jmsTestModule.getDestinationManager();
+ }
+
+ protected ConnectionFactory getConnectionFactory() {
+ if (connectionFactory == null) {
+ connectionFactory = getJMSMockObjectFactory().createMockConnectionFactory();
+ }
+ return connectionFactory;
+ }
+
+ protected Queue getQueue() {
+ if (queue == null) {
+ queue = getDestinationManager().createQueue("testQueue");
+ }
+ return queue;
+ }
+
+ protected void bindToContext(String name, Object object) {
+ ejbTestModule.bindToContext(name, object);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ jmsTestModule = createJMSTestModule(getJMSMockObjectFactory());
+ ejbTestModule = createEJBTestModule();
+ }
+
+}
Property changes on: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/jms/JbpmJmsMockTestCase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/test-cactus/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-cactus/pom.xml 2009-12-17 23:23:31 UTC (rev 5984)
+++ jbpm4/trunk/modules/test-cactus/pom.xml 2009-12-18 00:39:59 UTC (rev 5985)
@@ -157,6 +157,82 @@
</build>
</profile>
+ <profile>
+ <id>enterprise</id>
+ <properties>
+ <skipTests>true</skipTests>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy.libs</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>target/jbpm.test.webapp.libs</outputDirectory>
+ <artifactItems>
+ <artifactItem>
+ <groupId>aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ </artifactItem>
+ <artifactItem>
+ <groupId>cactus</groupId>
+ <artifactId>cactus.core</artifactId>
+ </artifactItem>
+ <artifactItem>
+ <groupId>cactus</groupId>
+ <artifactId>cactus.integration.ant</artifactId>
+ </artifactItem>
+ <artifactItem>
+ <groupId>cactus</groupId>
+ <artifactId>cactus.integration.shared.api</artifactId>
+ </artifactItem>
+ <artifactItem>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-examples</artifactId>
+ <classifier>tests</classifier>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-test-db</artifactId>
+ <classifier>tests</classifier>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-console-reports</artifactId>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.subethamail</groupId>
+ <artifactId>subethasmtp-wiser</artifactId>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.subethamail</groupId>
+ <artifactId>subethasmtp-smtp</artifactId>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
<profile>
<id>runtest</id>
Modified: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/ejb/EjbTest.java
===================================================================
--- jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/ejb/EjbTest.java 2009-12-17 23:23:31 UTC (rev 5984)
+++ jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/ejb/EjbTest.java 2009-12-18 00:39:59 UTC (rev 5985)
@@ -1,26 +1,31 @@
package org.jbpm.test.ejb;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
import junit.framework.Test;
-import junit.framework.TestCase;
import org.apache.cactus.ServletTestSuite;
-import org.jbpm.test.enterprise.stateless.bean.Calculator;
+import org.jbpm.test.JbpmTestCase;
-public class EjbTest extends TestCase {
+public class EjbTest extends JbpmTestCase {
- public static Test suite() {
- ServletTestSuite servletTestSuite = new ServletTestSuite();
- servletTestSuite.addTestSuite(EjbTest.class);
- return servletTestSuite;
- }
-
+ public static Test suite() {
+ ServletTestSuite servletTestSuite = new ServletTestSuite();
+ servletTestSuite.addTestSuite(EjbTest.class);
+ return servletTestSuite;
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ registerDeployment(repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/test/ejb/process.jpdl.xml")
+ .deploy());
+ }
+
public void testEjbInvocation() throws Exception {
- Context context = new InitialContext();
- Calculator calculator = (Calculator)context.lookup("CalculatorBean/local");
- assertEquals(59, calculator.add(24, 35));
+ String executionId = executionService
+ .startProcessInstanceByKey("EJB")
+ .getProcessInstance()
+ .getId();
+ assertEquals(59, executionService.getVariable(executionId, "answer"));
}
}
Modified: jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/map/MapMessageTest.java
===================================================================
--- jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/map/MapMessageTest.java 2009-12-17 23:23:31 UTC (rev 5984)
+++ jbpm4/trunk/modules/test-enterprise/test-enterprise-suite/src/test/java/org/jbpm/test/jms/map/MapMessageTest.java 2009-12-18 00:39:59 UTC (rev 5985)
@@ -15,19 +15,18 @@
return servletTestSuite;
}
-// protected void setUp() throws Exception {
-// super.setUp();
-// registerDeployment(repositoryService.createDeployment()
-// .addResourceFromClasspath("org/jbpm/test/jms/map/process.jpdl.xml")
-// .deploy());
-// }
+ protected void setUp() throws Exception {
+ super.setUp();
+ registerDeployment(repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/test/jms/map/process.jpdl.xml")
+ .deploy());
+ }
public void testJmsText() throws Exception {
- assertTrue(true);
-// executionService.startProcessInstanceByKey("JMS_map_queue");
-// MapMessage mapMessage = (MapMessage)messageConsumer.receive();
-// assertTrue(mapMessage.itemExists("x"));
-// assertEquals("foo", mapMessage.getObject("x"));
+ executionService.startProcessInstanceByKey("JMS_map_queue");
+ MapMessage mapMessage = (MapMessage)messageConsumer.receive();
+ assertTrue(mapMessage.itemExists("x"));
+ assertEquals("foo", mapMessage.getObject("x"));
}
}
16 years, 4 months
JBoss JBPM SVN: r5984 - in jbpm4/trunk/modules: bpmn/src/main/java/org/jbpm/bpmn/flownodes and 8 other directories.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-12-17 18:23:31 -0500 (Thu, 17 Dec 2009)
New Revision: 5984
Added:
jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.script.task.png
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/task/script/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/task/script/ScriptTaskTest.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/script/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/script/script_task.bpmn.xml
Removed:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/ScriptTaskTest.java
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/bpmn/scriptTask.bpmn.xml
Modified:
jbpm4/trunk/modules/bpmn/pom.xml
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskBinding.java
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml
Log:
JBPM-2666: revisited, documented and enhanced BPMN 2.0 Script Task
Modified: jbpm4/trunk/modules/bpmn/pom.xml
===================================================================
--- jbpm4/trunk/modules/bpmn/pom.xml 2009-12-17 21:30:45 UTC (rev 5983)
+++ jbpm4/trunk/modules/bpmn/pom.xml 2009-12-17 23:23:31 UTC (rev 5984)
@@ -81,9 +81,6 @@
<configuration>
<excludes>
<exclude>org/jbpm/test/xml/DbGenTest.java</exclude>
- <exclude>org/jbpm/bpmn/flownodes/ExclusiveGatewayTest.java</exclude>
- <exclude>org/jbpm/bpmn/flownodes/ScriptTaskTest.java</exclude>
- <exclude>org/jbpm/bpmn/flownodes/UserTaskTest.java</exclude>
</excludes>
</configuration>
</plugin>
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskActivity.java 2009-12-17 21:30:45 UTC (rev 5983)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskActivity.java 2009-12-17 23:23:31 UTC (rev 5984)
@@ -21,36 +21,44 @@
*/
package org.jbpm.bpmn.flownodes;
+import org.jbpm.api.JbpmException;
import org.jbpm.api.model.OpenExecution;
-import org.jbpm.bpmn.parser.ExpressionEvaluator;
-import org.jbpm.bpmn.parser.ExpressionEvaluatorDescriptor;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.wire.WireException;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.script.ScriptManager;
public class ScriptTaskActivity extends BpmnAutomaticActivity {
- private static final long serialVersionUID = 1L;
-
- private ExpressionEvaluatorDescriptor script;
+ private static final long serialVersionUID = 1L;
- public void perform(OpenExecution execution) throws Exception {
- try {
-
- //TODO: return values etc...
- ((ExpressionEvaluator) WireContext.create(script)).evaluateExpression(execution);
+ private String language;
- } catch (Exception e) {
- throw new WireException("couldn't run script: " + e.getMessage(), e);
- }
- }
+ private String script;
- public void setScript(ExpressionEvaluatorDescriptor expressionDescriptor) {
- this.script = expressionDescriptor;
- }
+ public void perform(OpenExecution execution) throws Exception {
+ try {
- public ExpressionEvaluatorDescriptor getScript() {
- return this.script;
- }
-
+ ScriptManager scriptManager = EnvironmentImpl.getFromCurrent(ScriptManager.class);
+ scriptManager.evaluateScript(script, language);
+
+ } catch (Exception e) {
+ throw new JbpmException("couldn't run script: " + e.getMessage(), e);
+ }
+ }
+
+ public String getLanguage() {
+ return language;
+ }
+
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ public String getScript() {
+ return script;
+ }
+
+ public void setScript(String script) {
+ this.script = script;
+ }
+
}
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskBinding.java 2009-12-17 21:30:45 UTC (rev 5983)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskBinding.java 2009-12-17 23:23:31 UTC (rev 5984)
@@ -21,7 +21,6 @@
*/
package org.jbpm.bpmn.flownodes;
-import org.jbpm.bpmn.parser.ExpressionEvaluatorDescriptor;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
@@ -36,15 +35,14 @@
}
public Object parse(Element element, Parse parse, Parser parser) {
- ScriptTaskActivity scriptTaskActivity = new ScriptTaskActivity();
- String scriptLanguage = XmlUtil.attribute(element, "scriptLanguage");
+ String scriptLanguage = XmlUtil.attribute(element, "scriptLanguage");
String script = XmlUtil.element(element, "script").getTextContent();
- if (script != null) {
- ExpressionEvaluatorDescriptor expressionDescriptor = new ExpressionEvaluatorDescriptor(script, scriptLanguage);
- scriptTaskActivity.setScript(expressionDescriptor);
- }
+ ScriptTaskActivity scriptTaskActivity = new ScriptTaskActivity();
+ scriptTaskActivity.setLanguage(scriptLanguage);
+ scriptTaskActivity.setScript(script);
+
return scriptTaskActivity;
}
}
Added: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.script.task.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.script.task.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml 2009-12-17 21:30:45 UTC (rev 5983)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml 2009-12-17 23:23:31 UTC (rev 5984)
@@ -577,12 +577,62 @@
<para>
<emphasis role="bold">Important note: Interfaces, ItemDefinitions and messages are
- defined outside the <process>.</emphasis>. See the example <emphasis role="bold">
+ defined outside the <process>.</emphasis> See the example <emphasis role="bold">
ServiceTaskTest</emphasis> for a concrete process and unit test.
</para>
</section>
+ <section id="scriptTask">
+
+ <title>Task: Script Task</title>
+
+ <para>
+ A script task is a an automatic activity upon which the process engine will execute
+ a script when the task is reached. The script task is used as follows:
+ <programlisting>
+<scriptTask id="scriptTask" name="Script Task" scriptLanguage="bsh">
+ <script><![CDATA[
+ for(int i=0; i < input.length; i++){
+ System.out.println(input[i] + " x 2 = " + (input[i]*2));
+ }]]>
+ </script>
+</scriptTask>
+ </programlisting>
+ The script task, besides the required <emphasis role="bold">id</emphasis> and the optional
+ <emphasis role="bold">name</emphasis>, allows for specifying a <emphasis role="bold">
+ scriptLanguage</emphasis> and a <emphasis role="bold">script</emphasis>.
+ Since we're using JSR-223 ('Scripting for the Java platform'), changing the script language involves
+ <itemizedlist>
+ <listitem>changing the scriptLanguage attribute to the JSR-223 compliant name</listitem>
+ <listitem>adding the ScriptEngine implementation of the specification to the classpath</listitem>
+ </itemizedlist>
+ The XML above is visualized as follows (adding a none start and end event).
+ </para>
+
+ <mediaobject><imageobject><imagedata align="center" fileref="images/bpmn2.script.task.png"/></imageobject></mediaobject>
+
+ <para>
+ As shown in the example, process variables are usable inside the scripts. We can now start
+ a process instance, while also supplying some random input variables:
+ <programlisting>
+Map<String, Object> variables = new HashMap<String, Object>();
+Integer[] values = { 11, 23, 56, 980, 67543, 8762524 };
+variables.put("input", values);
+ </programlisting>
+ In the output console, we can now see the script being executed:
+ <programlisting>
+11 x 2 = 22
+23 x 2 = 46
+56 x 2 = 112
+980 x 2 = 1960
+67543 x 2 = 135086
+8762524 x 2 = 17525048
+ </programlisting>
+ </para>
+
+ </section>
+
<section id="manualTask">
<title>Task: Manual task</title>
Added: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/task/script/ScriptTaskTest.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/task/script/ScriptTaskTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/task/script/ScriptTaskTest.java 2009-12-17 23:23:31 UTC (rev 5984)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.examples.bpmn.task.script;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.api.NewDeployment;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ * @author Ronald van Kuijk (kukeltje)
+ * @author Joram Barrez
+ */
+public class ScriptTaskTest extends JbpmTestCase {
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ NewDeployment deployment = repositoryService.createDeployment();
+ deployment
+ .addResourceFromClasspath("org/jbpm/examples/bpmn/task/script/script_task.bpmn.xml");
+ registerDeployment(deployment.deploy());
+ }
+
+ public void testProcessExecution() {
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ Integer[] values = { 11, 23, 56, 980, 67543, 8762524 };
+ variables.put("input", values);
+
+ ProcessInstance pi = executionService.startProcessInstanceByKey("ScriptTask", variables);
+
+ assertProcessInstanceEnded(pi);
+ }
+}
Copied: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/script/script_task.bpmn.xml (from rev 5970, jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/bpmn/scriptTask.bpmn.xml)
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/script/script_task.bpmn.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/script/script_task.bpmn.xml 2009-12-17 23:23:31 UTC (rev 5984)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions id="ExclusiveGatewayNormal"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://schema.omg.org/spec/BPMN/2.0 ../../../../../../../../../../bpmn/src/main/resources/BPMN20.xsd"
+ xmlns="http://schema.omg.org/spec/BPMN/2.0" typeLanguage="http://www.w3.org/2001/XMLSchema"
+ expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://jbpm.org/example/bpmn2/scriptTask">
+
+ <process id="ScriptTask" name="ScriptTask">
+
+ <startEvent id="Start" />
+
+ <sequenceFlow id="flow1" sourceRef="Start"
+ targetRef="scriptTask" name="Start->ScriptTask" />
+
+ <scriptTask id="scriptTask" name="Script Task" scriptLanguage="bsh">
+ <script><![CDATA[
+for(int i=0; i < input.length; i++){
+ System.out.println(input[i] + " x 2 = " + (input[i]*2));
+}]]>
+ </script>
+ </scriptTask>
+
+ <sequenceFlow id="flow2" sourceRef="scriptTask"
+ targetRef="End" />
+
+ <endEvent id="End" name="End" />
+
+ </process>
+</definitions>
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/ScriptTaskTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/ScriptTaskTest.java 2009-12-17 21:30:45 UTC (rev 5983)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/ScriptTaskTest.java 2009-12-17 23:23:31 UTC (rev 5984)
@@ -1,78 +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.bpmn;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.jbpm.api.ProcessInstance;
-import org.jbpm.bpmn.parser.BpmnParser;
-import org.jbpm.pvm.internal.xml.Problem;
-import org.jbpm.test.JbpmTestCase;
-
-/**
- * @author Tom Baeyens
- * @author Ronald van Kuijk (kukeltje)
- */
-public class ScriptTaskTest extends JbpmTestCase {
-
- static BpmnParser bpmnParser = new BpmnParser();
-
- public List<Problem> parse(String resource) {
-
- List<Problem> problems = bpmnParser.createParse().setResource(resource).execute().getProblems();
-
- return problems;
- }
-
- public void testNormal() {
-
- List<Problem> problems = parse("org/jbpm/bpmn/scriptTask.bpmn.xml");
-
- if (!problems.isEmpty()) {
- fail("No problems should have occured. Problems: " + problems);
- }
- }
-
- public void testNormalExecute() {
-
- String deploymentId = repositoryService.createDeployment().addResourceFromClasspath("org/jbpm/bpmn/scriptTask.bpmn.xml").deploy();
-
- try {
- Map variables = new HashMap();
- String[] values = {"st", "nd", "rd", "th", "th"};
- variables.put("test", values);
-
- ProcessInstance pi = executionService.startProcessInstanceByKey("ScriptTask", variables );
- String pid = pi.getId();
-
- // process instance should be ended
- pi = executionService.findProcessInstanceById(pid);
- assertNull(pi);
-
- }
- finally {
- repositoryService.deleteDeploymentCascade(deploymentId);
- }
- }
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/bpmn/scriptTask.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/bpmn/scriptTask.bpmn.xml 2009-12-17 21:30:45 UTC (rev 5983)
+++ jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/bpmn/scriptTask.bpmn.xml 2009-12-17 23:23:31 UTC (rev 5984)
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions id="ExclusiveGatewayNormal"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://schema.omg.org/spec/BPMN/2.0 ../../../../../../../bpmn/src/main/resources/BPMN20.xsd"
- xmlns:bpmn="http://schema.omg.org/spec/BPMN/2.0" typeLanguage="http://www.w3.org/2001/XMLSchema"
- expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://sample.bpmn.camunda.com/">
-
-
-
- <bpmn:process id="ScriptTask" name="ScriptTask">
- <!-- Start-Event -->
- <bpmn:startEvent id="Start" />
-
- <bpmn:sequenceFlow id="flow1" sourceRef="Start"
- targetRef="scriptTask" name="Start->ScriptTask" />
-
- <bpmn:scriptTask id="scriptTask" name="Script Task"
- scriptLanguage="bsh" >
- <bpmn:script><![CDATA[
-for(int i=0;i<5;i++){
- System.out.println((i+1) + test[i] + " universe");
-}]]>
-</bpmn:script>
- </bpmn:scriptTask>
- <bpmn:sequenceFlow id="flow2" sourceRef="scriptTask"
- targetRef="End" />
-
- <!-- End Events -->
- <bpmn:endEvent id="End" name="End" />
- </bpmn:process>
-</bpmn:definitions>
16 years, 4 months
JBoss JBPM SVN: r5983 - jbpm4/trunk/modules/devguide/src/main/docbook/en/modules.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-12-17 16:30:45 -0500 (Thu, 17 Dec 2009)
New Revision: 5983
Modified:
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml
Log:
JBPM-2664: documented manual task
Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml 2009-12-17 21:30:10 UTC (rev 5982)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml 2009-12-17 21:30:45 UTC (rev 5983)
@@ -599,7 +599,7 @@
</para>
<para>
- The purpose of the manual task is more documentation-wise, as it has no meaning for
+ The purpose of the manual task is more documentation/modeling-wise, as it has no meaning for
execution on a process engine. As such, the process engine will simply pass through
a manual task when it encounters one.
</para>
16 years, 4 months
JBoss JBPM SVN: r5982 - in jbpm4/trunk/modules: devguide/src/main/docbook/en/modules and 1 other directories.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-12-17 16:30:10 -0500 (Thu, 17 Dec 2009)
New Revision: 5982
Added:
jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.manual.task.png
Modified:
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/service/service_task_java.bpmn.xml
Log:
JBPM-2664: documented manual task
Added: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.manual.task.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.manual.task.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml 2009-12-17 20:49:49 UTC (rev 5981)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml 2009-12-17 21:30:10 UTC (rev 5982)
@@ -582,6 +582,29 @@
</para>
</section>
+
+ <section id="manualTask">
+
+ <title>Task: Manual task</title>
+
+ <para>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/bpmn2.manual.task.png"/></imageobject></mediaobject>
+ A manual task is a task that is performed by an external actor, but without the aid of
+ a BPM system or a service that is invoked. In the real world, examples are plenty:
+ the installation of telephone system, sending of a letter using regular mail, calling
+ a customer by phone, etc.
+ <programlisting>
+<manualTask id="myManualTask" name="Call customer" />
+ </programlisting>
+ </para>
+
+ <para>
+ The purpose of the manual task is more documentation-wise, as it has no meaning for
+ execution on a process engine. As such, the process engine will simply pass through
+ a manual task when it encounters one.
+ </para>
+
+ </section>
</section> <!-- End of basic constructs section -->
Modified: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/service/service_task_java.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/service/service_task_java.bpmn.xml 2009-12-17 20:49:49 UTC (rev 5981)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/service/service_task_java.bpmn.xml 2009-12-17 21:30:10 UTC (rev 5982)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions id="ServiceTaskJava"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://schema.omg.org/spec/BPMN/2.0 ../../../../../../../bpmn/src/main/resources/BPMN20.xsd"
+ xsi:schemaLocation="http://schema.omg.org/spec/BPMN/2.0 ../../../../../../../../../../bpmn/src/main/resources/BPMN20.xsd"
xmlns:bpmn="http://schema.omg.org/spec/BPMN/2.0" typeLanguage="http://www.w3.org/2001/XMLSchema"
expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://sample.bpmn.camunda.com/"
xmlns:jbpm="http://jbpm.org/4.0/bpmn2">
16 years, 4 months
JBoss JBPM SVN: r5981 - in jbpm4/trunk/modules: devguide/src/main/docbook/en/images and 9 other directories.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-12-17 15:49:49 -0500 (Thu, 17 Dec 2009)
New Revision: 5981
Added:
jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.service.task.png
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/task/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/task/service/
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/task/service/JavaService.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/task/service/ServiceTaskTest.java
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/service/
jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/service/service_task_java.bpmn.xml
Removed:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/JavaServiceTask.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/ServiceTaskTest.java
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/bpmn/ServiceTaskJava.bpmn.xml
Modified:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceTaskBinding.java
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml
Log:
JBPM-2663: revised and documented Java Service Task
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceTaskBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceTaskBinding.java 2009-12-17 19:45:24 UTC (rev 5980)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ServiceTaskBinding.java 2009-12-17 20:49:49 UTC (rev 5981)
@@ -53,6 +53,9 @@
//Element operationElement = dom.getElementById(operationRef);
Element operationElement = bpmnProcessDefinition.getOperations().get(operationRef);
+ if (operationElement == null) {
+ parse.addProblem("No operation found for operationRef " + operationRef, operationElement);
+ }
Element interfaceElement = (Element)operationElement.getParentNode();
javaActivity.setMethodName(operationElement.getAttribute("name"));
Added: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.service.task.png
===================================================================
(Binary files differ)
Property changes on: jbpm4/trunk/modules/devguide/src/main/docbook/en/images/bpmn2.service.task.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml 2009-12-17 19:45:24 UTC (rev 5980)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch03-Bpmn2.xml 2009-12-17 20:49:49 UTC (rev 5981)
@@ -467,7 +467,122 @@
</para>
</section>
+
+ <section id="task">
+
+ <title>Tasks</title>
+
+ <para>
+ A BPMN task is a so-called 'atomic' activity, meaning that it cannot be broken into
+ more detailed constructs. A task represents work that needs to be done by an external
+ entity, such as a human actor or an automated service.
+ </para>
+
+ <para>
+ It's important to note that the BPMN semantics of a 'task' differ from the JPDL semantics.
+ In JPDL, the concept 'task' is always used in the context of a human actor doing some
+ type of work. When the process engine encounters a task in JPDL, it will create a task in some human
+ actor's task list and it will behave as a wait state. In BPMN 2.0 however, there are several
+ task types, some indicating a wait state (eg. the <emphasis role="bold">User Task</emphasis>
+ and some indicating an automatic activity (eg. the <emphasis role="bold">Service Task</emphasis>.
+ So take good care not to confuse the meaning of the task concept when switching languages.
+ </para>
+
+ <para>
+ Tasks are depicted by a rounded rectangle, typically containing a text inside. The type
+ of the task (user task, service task, script task, etc.) is shown as a little icon on the left top
+ corner of the rectangle. Depending on the task type, the engine will execute different
+ functionality.
+ </para>
+
+ </section>
+
+ <section id="serviceTask">
+
+ <title>Task: Java Service Task</title>
+
+ <para>
+ A <emphasis role="bold">Service Task</emphasis> is an automatic activity that calls some
+ sort of service, such as a web service, Java service, etc. Currently, only Java service
+ invocations are supported by the jBPM engine, but Web service invocations are planned
+ for a future release.
+ <mediaobject><imageobject><imagedata align="center" fileref="images/bpmn2.service.task.png"/></imageobject></mediaobject>
+ </para>
+
+ <para>
+ Defining a service task requires quite a few lines of XML (the BPEL influence is certainly
+ visible). Of course, in the near future, we expect that tooling will simplify this area
+ a lot. A service task is defined as follows:
+ <programlisting>
+<serviceTask id="MyServiceTask" name="My service task" implementation="Other" operationRef="myOperation" />
+ </programlisting>
+ The service task has a required <emphasis role="bold">id</emphasis> and an optional
+ <emphasis role="bold">name</emphasis>. The <emphasis role="bold">implementation</emphasis>
+ attribute is used to indicate what the type of the invoked service is. Possible values
+ are WebService, Other or Unspecified. Since we've only implemented the Java invocation,
+ only the <emphasis role="bold">Other</emphasis> choice will do something useful for the moment.
+ </para>
+
+ <para>
+ The service task will invoke a certain operation that is referenced by the
+ <emphasis role="bold">operationRef</emphasis> attribute using the id of an
+ <emphasis role="bold">operation</emphasis>. Such an operation is part of an
+ <emphasis role="bold">interface</emphasis> as shown below. Every operations has
+ at least one <emphasis role="bold">input message</emphasis> and at most one
+ <emphasis role="bold">output message</emphasis>.
+ <programlisting>
+<interface id="myInterface"
+ name="org.jbpm.MyJavaServicek">
+ <operation id="myOperation2" name="myMethod">
+ <inMessageRef>inputMessage</inMessageRef>
+ <outMessageRef>outputMessage</outMessageRef>
+ </bpmn:operation>
+</interface>
+ </programlisting>
+ For a Java service, the <emphasis role="bold">name of the interface</emphasis> is used
+ to specificy the fully qualified classname of the Java class. The <emphasis role="bold">
+ name of the operation</emphasis> is then used to specify the name of the method
+ that must be called. The input/output message that represent the parameters/return value of
+ the Java method are defined as follows:
+ <programlisting>
+<message id="inputMessag" name="input message" structureRef="myItemDefinition1" />
+ </programlisting>
+ Several elements in BPMN are so-called 'item-aware', including this message construct.
+ This means that they are involved in storing or reading items during process execution.
+ The data structure to hold these elements is specified using a reference to an
+ <emphasis role="bold">ItemDefinition</emphasis>. In this context, the message specifies
+ its data structure by referencing an Itemdefinition in the
+ <emphasis role="bold">structureRef</emphasis> attribute.
+ <programlisting>
+
+ <itemDefinition id="myItemDefinition1" >
+ <jbpm:arg>
+ <jbpm:object expr="#{var1}" />
+ </jbpm:arg>
+ </itemDefinition>
+ <itemDefinition id="myItemDefinition2">
+ <jbpm:var name="returnVar" />
+ </itemDefinition>
+
+ </programlisting>
+ Do note that this is not standard BPMN 2.0 as by the specification (hence the 'jbpm' prefix).
+ In fact, according to the specification, the ItemDefinition shouldn't contain more
+ than a data structure definition. The actual mapping between input paramaters, with a ceratin
+ data structure, is done in the <emphasis role="bold">ioSpecification</emphasis> section
+ of the serviceTask. However, the current jBPM BPMN 2.0 implementation hasn't implemented
+ that construct yet. So, this means that the current usage as described above, will probably
+ change in the near future.
+ </para>
+
+ <para>
+ <emphasis role="bold">Important note: Interfaces, ItemDefinitions and messages are
+ defined outside the <process>.</emphasis>. See the example <emphasis role="bold">
+ ServiceTaskTest</emphasis> for a concrete process and unit test.
+ </para>
+
+ </section>
+
</section> <!-- End of basic constructs section -->
</chapter>
Copied: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/task/service/JavaService.java (from rev 5958, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/JavaServiceTask.java)
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/task/service/JavaService.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/task/service/JavaService.java 2009-12-17 20:49:49 UTC (rev 5981)
@@ -0,0 +1,9 @@
+package org.jbpm.examples.bpmn.task.service;
+
+public class JavaService {
+
+ String myMethod(String arg1) {
+ return "myMethod with arg1: "+ arg1;
+ }
+
+}
Copied: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/task/service/ServiceTaskTest.java (from rev 5958, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/ServiceTaskTest.java)
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/task/service/ServiceTaskTest.java (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/bpmn/task/service/ServiceTaskTest.java 2009-12-17 20:49:49 UTC (rev 5981)
@@ -0,0 +1,67 @@
+/*
+ * 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.bpmn.task.service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.api.NewDeployment;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.TaskQuery;
+import org.jbpm.api.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Bernd Ruecker (bernd.ruecker(a)camunda.com)
+ * @author Joram Barrez
+ */
+public class ServiceTaskTest extends JbpmTestCase {
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ NewDeployment deployment = repositoryService.createDeployment();
+ deployment.addResourceFromClasspath("org/jbpm/examples/bpmn/task/service/service_task_java.bpmn.xml");
+ registerDeployment(deployment.deploy());
+ }
+
+ public void testJavaServiceTaskCall() {
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("var1", "value");
+
+ ProcessInstance pi = executionService.startProcessInstanceByKey(
+ "ServiceTaskJavaProcess", variables);
+
+ assertNotNull(pi.getId());
+ assertEquals("myMethod with arg1: value", executionService.getVariable(
+ pi.getId(), "returnVar"));
+
+ TaskQuery taskQuery = taskService.createTaskQuery();
+ List<Task> allTasks = taskQuery.list();
+ assertEquals(1, allTasks.size());
+
+ taskService.completeTask(allTasks.get(0).getId());
+ assertProcessInstanceEnded(pi);
+ }
+
+}
Copied: jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/service/service_task_java.bpmn.xml (from rev 5970, jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/bpmn/ServiceTaskJava.bpmn.xml)
===================================================================
--- jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/service/service_task_java.bpmn.xml (rev 0)
+++ jbpm4/trunk/modules/examples/src/test/resources/org/jbpm/examples/bpmn/task/service/service_task_java.bpmn.xml 2009-12-17 20:49:49 UTC (rev 5981)
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bpmn:definitions id="ServiceTaskJava"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://schema.omg.org/spec/BPMN/2.0 ../../../../../../../bpmn/src/main/resources/BPMN20.xsd"
+ xmlns:bpmn="http://schema.omg.org/spec/BPMN/2.0" typeLanguage="http://www.w3.org/2001/XMLSchema"
+ expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://sample.bpmn.camunda.com/"
+ xmlns:jbpm="http://jbpm.org/4.0/bpmn2">
+
+ <bpmn:itemDefinition id="itemDefinition1" >
+ <jbpm:arg>
+ <jbpm:object expr="#{var1}" />
+ </jbpm:arg>
+ </bpmn:itemDefinition>
+
+ <bpmn:itemDefinition id="itemDefinition2">
+ <jbpm:var name="returnVar" />
+ </bpmn:itemDefinition>
+
+ <bpmn:message id="inputMessage" name="input message"
+ structureRef="itemDefinition1"></bpmn:message>
+
+ <bpmn:message id="outputMessage" name="output message"
+ structureRef="itemDefinition2">
+ </bpmn:message>
+
+ <bpmn:interface id="myInterface" name="org.jbpm.examples.bpmn.task.service.JavaService">
+ <bpmn:operation id="myOperation" name="myMethod">
+ <bpmn:inMessageRef>inputMessage</bpmn:inMessageRef>
+ <bpmn:outMessageRef>outputMessage</bpmn:outMessageRef>
+ </bpmn:operation>
+ </bpmn:interface>
+
+ <bpmn:process id="ServiceTaskJavaProcess" name="Simple process with java service task">
+
+ <bpmn:startEvent id="Start" />
+
+ <bpmn:sequenceFlow id="flow1" name="fromStartToServiceTask"
+ sourceRef="Start" targetRef="ServiceTask" />
+
+ <bpmn:serviceTask id="ServiceTask" name="service task"
+ implementation="Other" operationRef="myOperation">
+ </bpmn:serviceTask>
+
+ <bpmn:sequenceFlow id="flow2" name="fromServiceTaskToUT1"
+ sourceRef="ServiceTask" targetRef="UT1" />
+
+ <bpmn:userTask id="UT1" name="bla" implementation="other" />
+
+ <bpmn:sequenceFlow id="flow3" name="fromUT1toEnd"
+ sourceRef="UT1" targetRef="End" />
+
+ <bpmn:endEvent id="End" name="End" />
+
+ </bpmn:process>
+</bpmn:definitions>
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/JavaServiceTask.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/JavaServiceTask.java 2009-12-17 19:45:24 UTC (rev 5980)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/JavaServiceTask.java 2009-12-17 20:49:49 UTC (rev 5981)
@@ -1,9 +0,0 @@
-package org.jbpm.bpmn;
-
-public class JavaServiceTask {
-
- String myMethod(String arg1) {
- return "myMethod with arg1: "+ arg1;
- }
-
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/ServiceTaskTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/ServiceTaskTest.java 2009-12-17 19:45:24 UTC (rev 5980)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/bpmn/ServiceTaskTest.java 2009-12-17 20:49:49 UTC (rev 5981)
@@ -1,68 +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.bpmn;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.jbpm.api.ProcessInstance;
-import org.jbpm.api.TaskQuery;
-import org.jbpm.api.task.Task;
-import org.jbpm.test.JbpmTestCase;
-
-/**
- * @author Bernd Ruecker (bernd.ruecker(a)camunda.com)
- */
-public class ServiceTaskTest extends JbpmTestCase {
-
- public void testNormalJavaServiceTaskCall() {
- String deploymentId = repositoryService.createDeployment().addResourceFromClasspath("org/jbpm/bpmn/ServiceTaskJava.bpmn.xml").deploy();
-
- try {
-
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("var1", "value");
-
- ProcessInstance pi = executionService.startProcessInstanceByKey("ServiceTaskJavaProcess", variables);
-
- assertNotNull(pi.getId());
- assertEquals("myMethod with arg1: value",executionService.getVariable(pi.getId(), "returnVar"));
-
- TaskQuery taskQuery = taskService.createTaskQuery();
- List<Task> allTasks = taskQuery.list();
- assertEquals(1, allTasks.size());
-
- taskService.completeTask(allTasks.get(0).getId());
-
- // process instance is ended
- pi = executionService.findProcessInstanceById(pi.getId());
- // One way or another I would also expect this to work... pi is gone from
- // database immediately when ended. Only in History DB
- // assertEquals(true, pi.isEnded());
- assertNull(pi);
- } finally {
- repositoryService.deleteDeploymentCascade(deploymentId);
- }
- }
-
-}
Deleted: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/bpmn/ServiceTaskJava.bpmn.xml
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/bpmn/ServiceTaskJava.bpmn.xml 2009-12-17 19:45:24 UTC (rev 5980)
+++ jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/bpmn/ServiceTaskJava.bpmn.xml 2009-12-17 20:49:49 UTC (rev 5981)
@@ -1,56 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<bpmn:definitions id="ServiceTaskJava"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://schema.omg.org/spec/BPMN/2.0 ../../../../../../../bpmn/src/main/resources/BPMN20.xsd"
- xmlns:bpmn="http://schema.omg.org/spec/BPMN/2.0" typeLanguage="http://www.w3.org/2001/XMLSchema"
- expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://sample.bpmn.camunda.com/"
- xmlns:jbpm="http://jbpm.org/4.0/bpmn2">
-
- <bpmn:itemDefinition id="itemDefinition1">
- <jbpm:arg>
- <jbpm:object expr="#{var1}" />
- </jbpm:arg>
- </bpmn:itemDefinition>
-
- <bpmn:itemDefinition id="itemDefinition2">
- <jbpm:var name="returnVar" />
- </bpmn:itemDefinition>
-
- <bpmn:message id="inputMessage" name="input message"
- structureRef="itemDefinition1"></bpmn:message>
-
- <bpmn:message id="outputMessage" name="output message"
- structureRef="itemDefinition2">
- </bpmn:message>
-
- <bpmn:interface id="interface21"
- name="org.jbpm.bpmn.JavaServiceTask">
- <bpmn:operation id="operation42" name="myMethod">
- <bpmn:inMessageRef>inputMessage</bpmn:inMessageRef>
- <bpmn:outMessageRef>outputMessage</bpmn:outMessageRef>
- </bpmn:operation>
- </bpmn:interface>
-
- <bpmn:process id="ServiceTaskJavaProcess" name="Simple process with java service task">
-
- <bpmn:startEvent id="Start" />
-
- <bpmn:sequenceFlow id="flow1" name="fromStartToServiceTask"
- sourceRef="Start" targetRef="ServiceTask" />
-
- <bpmn:serviceTask id="ServiceTask" name="service task"
- implementation="Other" operationRef="operation42">
- </bpmn:serviceTask>
-
- <bpmn:sequenceFlow id="flow2" name="fromServiceTaskToUT1"
- sourceRef="ServiceTask" targetRef="UT1" />
-
- <bpmn:userTask id="UT1" name="bla" implementation="other" />
-
- <bpmn:sequenceFlow id="flow3" name="fromUT1toEnd"
- sourceRef="UT1" targetRef="End" />
-
- <bpmn:endEvent id="End" name="End" />
-
- </bpmn:process>
-</bpmn:definitions>
16 years, 4 months
JBoss JBPM SVN: r5980 - in jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test: hibernatelongid and 1 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-12-17 14:45:24 -0500 (Thu, 17 Dec 2009)
New Revision: 5980
Modified:
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/jbpm.cfg.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatelongid/jbpm.cfg.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/jbpm.cfg.xml
Log:
fixing jbpm-cfg: updating configuration changes
Modified: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/jbpm.cfg.xml 2009-12-17 17:09:15 UTC (rev 5979)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/customtype/jbpm.cfg.xml 2009-12-17 19:45:24 UTC (rev 5980)
@@ -3,9 +3,9 @@
<jbpm-configuration>
<import resource="jbpm.businesscalendar.cfg.xml" />
- <import resource="jbpm.tx.hibernate.cfg.xml" />
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.identity.cfg.xml" />
+ <import resource="jbpm.default.scriptmanager.xml" />
<process-engine-context>
@@ -14,9 +14,29 @@
<hibernate-configuration>
<cfg resource="org/jbpm/test/customtype/jbpm.hibernate.cfg.xml" />
</hibernate-configuration>
+
+
+ <!--
+ Above are the customized parts. The rest is just duplication
+ of the default and hibernate tx config files
+ -->
+
+ <hibernate-session-factory />
-
+ <command-service name="txRequiredCommandService">
+ <skip-interceptor />
+ <retry-interceptor />
+ <environment-interceptor />
+ <standard-transaction-interceptor />
+ </command-service>
+
+ <command-service name="newTxRequiredCommandService">
+ <retry-interceptor />
+ <environment-interceptor policy="requiresNew" />
+ <standard-transaction-interceptor />
+ </command-service>
+
<repository-service />
<repository-cache />
<execution-service />
@@ -25,20 +45,14 @@
<identity-service />
<task-service />
- <hibernate-session-factory />
-
- <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator" init="eager">
+ <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator">
<field name="commandService"><ref object="newTxRequiredCommandService" /></field>
- <invoke method="initialize" />
</object>
<object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" />
- <script-manager default-expression-language="juel"
- default-script-language="juel">
- <script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
- </script-manager>
-
+ <types resource="jbpm.variable.types.xml" />
+
<address-resolver />
<mail-template name='task-notification'>
@@ -66,17 +80,24 @@
</process-engine-context>
<transaction-context>
+ <transaction />
+
+ <hibernate-session />
<repository-session />
<db-session />
-
<message-session />
<timer-session />
- <history-session />
+
+ <history-sessions>
+ <object class="org.jbpm.pvm.internal.history.HistorySessionImpl" />
+ </history-sessions>
+
<mail-session>
<mail-server>
<session-properties resource="jbpm.mail.properties" />
</mail-server>
</mail-session>
+
</transaction-context>
</jbpm-configuration>
Modified: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatelongid/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatelongid/jbpm.cfg.xml 2009-12-17 17:09:15 UTC (rev 5979)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/hibernatelongid/jbpm.cfg.xml 2009-12-17 19:45:24 UTC (rev 5980)
@@ -3,12 +3,38 @@
<jbpm-configuration>
<import resource="jbpm.businesscalendar.cfg.xml" />
- <import resource="jbpm.tx.hibernate.cfg.xml" />
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.identity.cfg.xml" />
+ <import resource="jbpm.default.scriptmanager.xml" />
<process-engine-context>
-
+
+ <hibernate-configuration>
+ <cfg resource="org/jbpm/test/hibernatelongid/jbpm.hibernate.cfg.xml" />
+ </hibernate-configuration>
+
+
+ <!--
+ Above are the customized parts. The rest is just duplication
+ of the default and hibernate tx config files
+ -->
+
+
+ <command-service name="txRequiredCommandService">
+ <skip-interceptor />
+ <retry-interceptor />
+ <environment-interceptor />
+ <standard-transaction-interceptor />
+ </command-service>
+
+ <command-service name="newTxRequiredCommandService">
+ <retry-interceptor />
+ <environment-interceptor policy="requiresNew" />
+ <standard-transaction-interceptor />
+ </command-service>
+
+ <hibernate-session-factory />
+
<repository-service />
<repository-cache />
<execution-service />
@@ -17,24 +43,12 @@
<identity-service />
<task-service />
- <hibernate-configuration>
- <cfg resource="org/jbpm/test/hibernatelongid/jbpm.hibernate.cfg.xml" />
- </hibernate-configuration>
-
- <hibernate-session-factory />
-
- <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator" init="eager">
+ <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator">
<field name="commandService"><ref object="newTxRequiredCommandService" /></field>
- <invoke method="initialize" />
</object>
<object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" />
- <script-manager default-expression-language="juel"
- default-script-language="juel">
- <script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
- </script-manager>
-
<types resource="jbpm.variable.types.xml" />
<address-resolver />
@@ -64,12 +78,18 @@
</process-engine-context>
<transaction-context>
+ <transaction />
+
+ <hibernate-session />
<repository-session />
<db-session />
-
<message-session />
<timer-session />
- <history-session />
+
+ <history-sessions>
+ <object class="org.jbpm.pvm.internal.history.HistorySessionImpl" />
+ </history-sessions>
+
<mail-session>
<mail-server>
<session-properties resource="jbpm.mail.properties" />
Modified: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/jbpm.cfg.xml 2009-12-17 17:09:15 UTC (rev 5979)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/idgenerator/jbpm.cfg.xml 2009-12-17 19:45:24 UTC (rev 5980)
@@ -3,12 +3,38 @@
<jbpm-configuration>
<import resource="jbpm.businesscalendar.cfg.xml" />
- <import resource="jbpm.tx.hibernate.cfg.xml" />
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.identity.cfg.xml" />
+ <import resource="jbpm.default.scriptmanager.xml" />
<process-engine-context>
-
+
+ <hibernate-configuration>
+ <cfg resource="org/jbpm/test/idgenerator/jbpm.hibernate.cfg.xml" />
+ </hibernate-configuration>
+
+
+ <!--
+ Above are the customized parts. The rest is just duplication
+ of the default and hibernate tx config files
+ -->
+
+
+ <command-service name="txRequiredCommandService">
+ <skip-interceptor />
+ <retry-interceptor />
+ <environment-interceptor />
+ <standard-transaction-interceptor />
+ </command-service>
+
+ <command-service name="newTxRequiredCommandService">
+ <retry-interceptor />
+ <environment-interceptor policy="requiresNew" />
+ <standard-transaction-interceptor />
+ </command-service>
+
+ <hibernate-session-factory />
+
<repository-service />
<repository-cache />
<execution-service />
@@ -17,37 +43,53 @@
<identity-service />
<task-service />
- <hibernate-configuration>
- <cfg resource="org/jbpm/test/idgenerator/jbpm.hibernate.cfg.xml" />
- </hibernate-configuration>
-
- <hibernate-session-factory />
-
- <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator" init="eager">
+ <object class="org.jbpm.pvm.internal.id.DatabaseDbidGenerator">
<field name="commandService"><ref object="newTxRequiredCommandService" /></field>
- <invoke method="initialize" />
</object>
<object class="org.jbpm.pvm.internal.id.DatabaseIdComposer" init="eager" />
- <script-manager default-expression-language="juel"
- default-script-language="juel">
- <script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
- </script-manager>
-
<types resource="jbpm.variable.types.xml" />
<address-resolver />
+
+ <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>
+
</process-engine-context>
<transaction-context>
+ <transaction />
+
+ <hibernate-session />
<repository-session />
<db-session />
-
<message-session />
<timer-session />
- <history-session />
+
+ <history-sessions>
+ <object class="org.jbpm.pvm.internal.history.HistorySessionImpl" />
+ </history-sessions>
+
<mail-session>
<mail-server>
<session-properties resource="jbpm.mail.properties" />
16 years, 4 months
JBoss JBPM SVN: r5979 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/history and 5 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-12-17 12:09:15 -0500 (Thu, 17 Dec 2009)
New Revision: 5979
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionsBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HistorySessionDescriptor.java
Removed:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionBinding.java
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ConfigurationParser.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistoryEvent.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionChain.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AbstractCollectionBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CollectionDescriptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.wire.bindings.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/historysessionchain/jbpm.cfg.xml
Log:
refactoring and fixing history session chaining
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ConfigurationParser.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ConfigurationParser.java 2009-12-17 11:24:30 UTC (rev 5978)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ConfigurationParser.java 2009-12-17 17:09:15 UTC (rev 5979)
@@ -86,6 +86,7 @@
Parse importParse = createParse()
.setResource(resource)
.contextStackPush(configuration)
+ .propagateContexMap(parse)
.execute();
parse.addProblems(importParse.getProblems());
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistoryEvent.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistoryEvent.java 2009-12-17 11:24:30 UTC (rev 5978)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistoryEvent.java 2009-12-17 17:09:15 UTC (rev 5979)
@@ -22,8 +22,6 @@
package org.jbpm.pvm.internal.history;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.model.ExecutionImpl;
@@ -59,23 +57,10 @@
if (environment!=null) {
HistorySession historySession = environment.get(HistorySession.class);
- HistorySessionChain historySessionChain = environment.get(HistorySessionChain.class);
-
- // Merge default history session (if defined) and the history session chain (if defined)
- List<HistorySession> historySessions = new ArrayList<HistorySession>();
- if (historySessionChain != null) {
- historySessions.addAll(historySessionChain.getHistorySessionDelegates());
- }
- if (historySession != null) {
- historySessions.add(historySession);
- }
-
- // Delegate history event to all defined history sessions
- for (HistorySession hs : historySessions) {
+ if (historySession!=null) {
historyEvent.setExecution(execution);
- hs.process(historyEvent);
+ historySession.process(historyEvent);
}
-
}
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionChain.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionChain.java 2009-12-17 11:24:30 UTC (rev 5978)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/history/HistorySessionChain.java 2009-12-17 17:09:15 UTC (rev 5979)
@@ -32,20 +32,15 @@
*/
public class HistorySessionChain implements HistorySession {
- protected List<HistorySession> delegates = new ArrayList<HistorySession>();
+ protected List<HistorySession> historySessions = new ArrayList<HistorySession>();
+ public HistorySessionChain(List<HistorySession> historySessions) {
+ this.historySessions = historySessions;
+ }
+
public void process(HistoryEvent historyEvent) {
- for (HistorySession delegate: delegates) {
- delegate.process(historyEvent);
+ for (HistorySession historySession: historySessions) {
+ historySession.process(historyEvent);
}
}
-
- public void addLogSession(HistorySession historySession) {
- delegates.add(historySession);
- }
-
- public List<HistorySession> getHistorySessionDelegates() {
- return delegates;
- }
-
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AbstractCollectionBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AbstractCollectionBinding.java 2009-12-17 11:24:30 UTC (rev 5978)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/AbstractCollectionBinding.java 2009-12-17 17:09:15 UTC (rev 5979)
@@ -3,8 +3,6 @@
import java.util.ArrayList;
import java.util.List;
-import org.jbpm.api.JbpmException;
-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.descriptor.CollectionDescriptor;
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionBinding.java 2009-12-17 11:24:30 UTC (rev 5978)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionBinding.java 2009-12-17 17:09:15 UTC (rev 5979)
@@ -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.wire.binding;
-
-import org.jbpm.pvm.internal.history.HistorySessionImpl;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-import org.w3c.dom.Element;
-
-
-/**
- * @author Tom Baeyens
- */
-public class HistorySessionBinding extends WireDescriptorBinding {
-
- public HistorySessionBinding() {
- super("history-session");
- }
-
- public Object parse(Element element, Parse parse, Parser parser) {
- return new ObjectDescriptor(HistorySessionImpl.class);
- }
-
-}
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionsBinding.java (from rev 5978, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionBinding.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionsBinding.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/HistorySessionsBinding.java 2009-12-17 17:09:15 UTC (rev 5979)
@@ -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.wire.descriptor.CollectionDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.HistorySessionDescriptor;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistorySessionsBinding extends WireDescriptorBinding {
+
+ private static final String KEY_HISTORY_SESSIONS_DESCRIPTOR = "historySessionsDescriptor";
+ private static final ListBinding LIST_BINDING = new ListBinding();
+
+ public HistorySessionsBinding() {
+ super("history-sessions");
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+ HistorySessionDescriptor historySessionsDescriptor = (HistorySessionDescriptor) parse.contextMapGet(KEY_HISTORY_SESSIONS_DESCRIPTOR);
+ if (historySessionsDescriptor==null) {
+ historySessionsDescriptor = new HistorySessionDescriptor();
+ parse.contextMapPut(KEY_HISTORY_SESSIONS_DESCRIPTOR, historySessionsDescriptor);
+ }
+
+ CollectionDescriptor listDescriptor = (CollectionDescriptor) LIST_BINDING.parse(element, parse, parser);
+ historySessionsDescriptor.add(listDescriptor);
+
+ return historySessionsDescriptor;
+ }
+
+}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CollectionDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CollectionDescriptor.java 2009-12-17 11:24:30 UTC (rev 5978)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/CollectionDescriptor.java 2009-12-17 17:09:15 UTC (rev 5979)
@@ -1,5 +1,6 @@
package org.jbpm.pvm.internal.wire.descriptor;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -80,6 +81,15 @@
}
}
+ public void addValueDescriptors(List<Descriptor> otherValueDescriptors) {
+ if (valueDescriptors==null) {
+ valueDescriptors = new ArrayList<Descriptor>();
+ }
+ if (otherValueDescriptors!=null) {
+ valueDescriptors.addAll(otherValueDescriptors);
+ }
+ }
+
public String getClassName() {
return className;
}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HistorySessionDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HistorySessionDescriptor.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HistorySessionDescriptor.java 2009-12-17 17:09:15 UTC (rev 5979)
@@ -0,0 +1,56 @@
+/*
+ * 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.descriptor;
+
+import java.util.List;
+
+import org.jbpm.pvm.internal.history.HistorySession;
+import org.jbpm.pvm.internal.history.HistorySessionChain;
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.WireDefinition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class HistorySessionDescriptor extends AbstractDescriptor {
+
+ private static final long serialVersionUID = 1L;
+
+ CollectionDescriptor listDescriptor = new ListDescriptor();
+
+ public Object construct(WireContext wireContext) {
+ List<HistorySession> historySessions = (List<HistorySession>) WireContext.create(listDescriptor);
+ if (historySessions.size()==1) {
+ return historySessions.get(0);
+ }
+ return new HistorySessionChain(historySessions);
+ }
+
+ public void add(CollectionDescriptor otherListDescriptor) {
+ this.listDescriptor.addValueDescriptors(otherListDescriptor.getValueDescriptors());
+ }
+
+ public Class<?> getType(WireDefinition wireDefinition) {
+ return HistorySession.class;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/HistorySessionDescriptor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java 2009-12-17 11:24:30 UTC (rev 5978)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java 2009-12-17 17:09:15 UTC (rev 5979)
@@ -215,7 +215,19 @@
}
return this;
}
+
+ public Parse propagateContexMap(Parse parse) {
+ if (parse.contextMap==null) {
+ parse.contextMap = new HashMap<String, Object>();
+ }
+ if (this.contextMap!=null) {
+ parse.contextMap.putAll(this.contextMap);
+ }
+ this.contextMap = parse.contextMap;
+ return this;
+ }
+
// contex stack /////////////////////////////////////////////////////////////
/** push a contextual object on the stack of this parse. */
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml 2009-12-17 11:24:30 UTC (rev 5978)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.default.cfg.xml 2009-12-17 17:09:15 UTC (rev 5979)
@@ -54,12 +54,17 @@
<message-session />
<timer-session />
- <history-session />
+
+ <history-sessions>
+ <object class="org.jbpm.pvm.internal.history.HistorySessionImpl" />
+ </history-sessions>
+
<mail-session>
<mail-server>
<session-properties resource="jbpm.mail.properties" />
</mail-server>
</mail-session>
+
</transaction-context>
</jbpm-configuration>
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.wire.bindings.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.wire.bindings.xml 2009-12-17 11:24:30 UTC (rev 5978)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.wire.bindings.xml 2009-12-17 17:09:15 UTC (rev 5979)
@@ -49,8 +49,7 @@
<binding class="org.jbpm.pvm.internal.wire.binding.DbSessionBinding" />
<binding class="org.jbpm.pvm.internal.wire.binding.MessageSessionBinding" />
<binding class="org.jbpm.pvm.internal.wire.binding.TimerSessionBinding" />
- <binding class="org.jbpm.pvm.internal.wire.binding.HistorySessionBinding" />
- <binding class="org.jbpm.pvm.internal.wire.binding.HistorySessionChainBinding" />
+ <binding class="org.jbpm.pvm.internal.wire.binding.HistorySessionsBinding" />
<binding class="org.jbpm.pvm.internal.wire.binding.IdentitySessionBinding" />
<binding class="org.jbpm.pvm.internal.wire.binding.JbossIdmIdentitySessionFactoryBinding" />
<binding class="org.jbpm.pvm.internal.wire.binding.JbossIdmIdentitySessionBinding" />
Modified: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/historysessionchain/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/historysessionchain/jbpm.cfg.xml 2009-12-17 11:24:30 UTC (rev 5978)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/historysessionchain/jbpm.cfg.xml 2009-12-17 17:09:15 UTC (rev 5979)
@@ -10,10 +10,10 @@
<import resource="jbpm.identity.cfg.xml" />
<transaction-context>
- <history-session-chain>
+ <history-sessions>
<object class="org.jbpm.test.historysessionchain.DummyProcessStartListener" />
<object class="org.jbpm.test.historysessionchain.DummyProcessEndListener" />
- </history-session-chain>
+ </history-sessions>
</transaction-context>
</jbpm-configuration>
16 years, 4 months
JBoss JBPM SVN: r5978 - in jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring: transactionmanager and 1 other directory.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-12-17 06:24:30 -0500 (Thu, 17 Dec 2009)
New Revision: 5978
Modified:
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/applicationContext.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/applicationContext.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/jbpm.cfg.xml
Log:
Fixing test-cfg for Spring
Modified: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/applicationContext.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/applicationContext.xml 2009-12-17 11:06:19 UTC (rev 5977)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/applicationContext.xml 2009-12-17 11:24:30 UTC (rev 5978)
@@ -14,11 +14,11 @@
<bean id="myEventListener" class="org.jbpm.test.spring.expression.eventlistener.MyEventListener" />
- <bean id="jbpmConfiguration" class="org.jbpm.pvm.internal.cfg.SpringConfiguration">
- <property name="jbpmCfgLocation" value="org/jbpm/test/spring/expression/eventlistener/jbpm.cfg.xml" />
+ <bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper">
+ <property name="jbpmCfg" value="org/jbpm/test/spring/expression/eventlistener/jbpm.cfg.xml" />
</bean>
- <bean id="processEngine" factory-bean="jbpmConfiguration" factory-method="buildProcessEngine" />
+ <bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine" />
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:org/jbpm/test/spring/transactionmanager/jbpm.hibernate.cfg.xml" />
Modified: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/applicationContext.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/applicationContext.xml 2009-12-17 11:06:19 UTC (rev 5977)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/applicationContext.xml 2009-12-17 11:24:30 UTC (rev 5978)
@@ -11,11 +11,11 @@
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="jbpmConfiguration" class="org.jbpm.pvm.internal.cfg.SpringConfiguration">
- <property name="jbpmCfgLocation" value="org/jbpm/test/spring/transactionmanager/jbpm.cfg.xml" />
+ <bean id="springHelper" class="org.jbpm.pvm.internal.processengine.SpringHelper">
+ <property name="jbpmCfg" value="org/jbpm/test/spring/transactionmanager/jbpm.cfg.xml" />
</bean>
- <bean id="processEngine" factory-bean="jbpmConfiguration" factory-method="buildProcessEngine" />
+ <bean id="processEngine" factory-bean="springHelper" factory-method="createProcessEngine" />
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:org/jbpm/test/spring/transactionmanager/jbpm.hibernate.cfg.xml" />
Modified: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/jbpm.cfg.xml 2009-12-17 11:06:19 UTC (rev 5977)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/jbpm.cfg.xml 2009-12-17 11:24:30 UTC (rev 5978)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
-<jbpm-configuration>
+<jbpm-configuration spring="enabled">
<import resource="jbpm.default.cfg.xml" />
<import resource="jbpm.jpdl.cfg.xml" />
@@ -15,7 +15,7 @@
<command-service name="newTxRequiredCommandService">
<retry-interceptor />
<environment-interceptor policy="requiresNew" />
- <spring-transaction-interceptor transaction-manager="someOtherTransactionManager"/>
+ <spring-transaction-interceptor transaction-manager="someOtherTransactionManager" policy="requiresNew" />
</command-service>
<command-service name="txRequiredCommandService">
@@ -26,9 +26,9 @@
</process-engine-context>
- <transaction-context>
- <transaction />
- <hibernate-session />
- </transaction-context>
+ <transaction-context>
+ <transaction type="spring" />
+ <hibernate-session current="true" />
+ </transaction-context>
</jbpm-configuration>
16 years, 4 months
JBoss JBPM SVN: r5977 - in jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal: tx and 3 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-12-17 06:06:19 -0500 (Thu, 17 Dec 2009)
New Revision: 5977
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/JtaRetryInterceptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/JtaStatusHelper.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/JtaTransaction.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/JtaTransactionInterceptor.java
Removed:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/FlushDeserializedObject.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JtaTransactionInterceptorBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RetryInterceptorBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TransactionBinding.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JbossIdmIdentitySessionDescriptor.java
Log:
JBPM-2631 spring transactions. clean up
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java 2009-12-17 10:44:53 UTC (rev 5976)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/session/DbSession.java 2009-12-17 11:06:19 UTC (rev 5977)
@@ -38,8 +38,8 @@
import org.jbpm.pvm.internal.query.ProcessInstanceQueryImpl;
import org.jbpm.pvm.internal.query.TaskQueryImpl;
import org.jbpm.pvm.internal.task.TaskImpl;
+import org.jbpm.pvm.internal.tx.JtaTransaction;
import org.jbpm.pvm.internal.tx.StandardTransaction;
-import org.jbpm.pvm.internal.tx.jta.JtaTransaction;
import org.jbpm.pvm.internal.type.Variable;
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/FlushDeserializedObject.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/FlushDeserializedObject.java 2009-12-17 10:44:53 UTC (rev 5976)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/FlushDeserializedObject.java 2009-12-17 11:06:19 UTC (rev 5977)
@@ -1,80 +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.tx;
-
-import java.io.Serializable;
-import java.util.Arrays;
-
-import javax.transaction.Synchronization;
-
-import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
-import org.jbpm.pvm.internal.type.Variable;
-import org.jbpm.pvm.internal.type.converter.SerializableToBytesConverter;
-import org.jbpm.pvm.internal.type.variable.BlobVariable;
-
-
-/**
- * @author Tom Baeyens
- */
-public class FlushDeserializedObject implements Serializable, Synchronization {
-
- private static final long serialVersionUID = 1L;
-
- private static final SerializableToBytesConverter serializableToBytesConverter = new SerializableToBytesConverter();
-
- protected Object[] deserializedObjectData;
-
- public FlushDeserializedObject(Object object, ScopeInstanceImpl scopeInstance, Variable variable) {
- deserializedObjectData = new Object[] { object, scopeInstance, variable };
- }
-
- public void beforeCompletion() {
- flushDeserializedObject();
- }
-
- public void afterCompletion(int arg0) {
- }
-
- public void flushDeserializedObject() {
- Object deserializedObject = deserializedObjectData[0];
- ScopeInstanceImpl scopeInstance = (ScopeInstanceImpl) deserializedObjectData[1];
- BlobVariable blobVariable = (BlobVariable) deserializedObjectData[2];
-
- String variableName = blobVariable.getKey();
- Object currentValue = scopeInstance.getVariable(variableName);
-
- // first check if the deserialized object still is the value for that variable.
- // a different, new object (of any type) might have been set in the meantime in that key-value-pair
- if ( (currentValue!=null)
- && (currentValue==deserializedObject)
- ) {
- // next, we check if the serialized object was actually changed or not
- byte[] newBytes = (byte[]) serializableToBytesConverter.convert(currentValue, null, null);
- byte[] persistedBytes = blobVariable.getLob().extractBytes();
- // if it is changed
- if (!Arrays.equals(persistedBytes, newBytes)) {
- // then do an automatic update
- blobVariable.setValue(deserializedObject, scopeInstance);
- }
- }
- }
-}
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/JtaRetryInterceptor.java (from rev 5974, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaRetryInterceptor.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/JtaRetryInterceptor.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/JtaRetryInterceptor.java 2009-12-17 11:06:19 UTC (rev 5977)
@@ -0,0 +1,58 @@
+/*
+ * 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 javax.transaction.Status;
+import javax.transaction.UserTransaction;
+
+import org.jbpm.api.cmd.Command;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.svc.RetryInterceptor;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JtaRetryInterceptor extends RetryInterceptor {
+
+ private static Log log = Log.getLog(JtaRetryInterceptor.class.getName());
+
+ public <T> T execute(Command<T> command) {
+ JtaTransaction jtaTransaction = EnvironmentImpl.getFromCurrent(JtaTransaction.class);
+ UserTransaction userTransaction = jtaTransaction.lookupJeeUserTransaction();
+ int status = JtaTransaction.getUserTransactionStatus(userTransaction);
+ if (status == Status.STATUS_NO_TRANSACTION) {
+ return executeWithRetry(command);
+ }
+ log.trace("transaction in progress. skipping retry interceptor");
+ return executeWithoutRetry(command);
+ }
+
+ public <T> T executeWithRetry(Command<T> command) {
+ return super.execute(command);
+ }
+
+ public <T> T executeWithoutRetry(Command<T> command) {
+ return next.execute(command);
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/JtaRetryInterceptor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/JtaStatusHelper.java (from rev 5974, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaStatusHelper.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/JtaStatusHelper.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/JtaStatusHelper.java 2009-12-17 11:06:19 UTC (rev 5977)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.tx;
+
+import javax.transaction.Status;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public abstract class JtaStatusHelper {
+
+ public static String toString(int txStatus) {
+ if (txStatus==Status.STATUS_ACTIVE) {
+ return "STATUS_ACTIVE";
+ } else if (txStatus==Status.STATUS_COMMITTED) {
+ return "STATUS_COMMITTED";
+ } else if (txStatus==Status.STATUS_COMMITTING) {
+ return "STATUS_COMMITTING";
+ } else if (txStatus==Status.STATUS_MARKED_ROLLBACK) {
+ return "STATUS_MARKED_ROLLBACK";
+ } else if (txStatus==Status.STATUS_NO_TRANSACTION) {
+ return "STATUS_NO_TRANSACTION";
+ } else if (txStatus==Status.STATUS_PREPARED) {
+ return "STATUS_PREPARED";
+ } else if (txStatus==Status.STATUS_PREPARING) {
+ return "STATUS_PREPARING";
+ } else if (txStatus==Status.STATUS_ROLLEDBACK) {
+ return "STATUS_ROLLEDBACK";
+ } else if (txStatus==Status.STATUS_ROLLING_BACK) {
+ return "STATUS_ROLLING_BACK";
+ } else if (txStatus==Status.STATUS_UNKNOWN) {
+ return "STATUS_UNKNOWN";
+ } else {
+ return "unknown";
+ }
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/JtaStatusHelper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/JtaTransaction.java (from rev 5974, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaTransaction.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/JtaTransaction.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/JtaTransaction.java 2009-12-17 11:06:19 UTC (rev 5977)
@@ -0,0 +1,152 @@
+/*
+ * 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 javax.naming.InitialContext;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+
+import org.jbpm.api.JbpmException;
+import org.jbpm.internal.log.Log;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JtaTransaction extends AbstractTransaction implements Transaction {
+
+ private static Log log = Log.getLog(JtaTransaction.class.getName());
+
+ public static final String JNDINAME_USERTRANSACTION_JBOSS_GLOBAL = "UserTransaction";
+ public static final String JNDINAME_TRANSACTIONMANAGER_JBOSS_GLOBAL = "java:/TransactionManager";
+
+ protected String userTransactionJndiName = JNDINAME_USERTRANSACTION_JBOSS_GLOBAL;
+ protected String transactionManagerJndiName = JNDINAME_TRANSACTIONMANAGER_JBOSS_GLOBAL;
+
+ public boolean isRollbackOnly() {
+ try {
+ return lookupJeeUserTransaction().getStatus()==Status.STATUS_MARKED_ROLLBACK;
+ } catch (SystemException e) {
+ throw new JbpmException("couldn't get status of user transaction: "+e.getMessage(), e);
+ }
+ }
+
+ public void setRollbackOnly() {
+ try {
+ lookupJeeUserTransaction().setRollbackOnly();
+ } catch (Exception e) {
+ throw new JbpmException("couldn't set user transaction to rollback only: "+e.getMessage(), e);
+ }
+ }
+
+ public void registerSynchronization(Synchronization synchronization) {
+ try {
+ lookupJeeTransaction().registerSynchronization(synchronization);
+ } catch (Exception e) {
+ throw new JbpmException("couldn't register synchronization: "+e.getMessage(), e);
+ }
+ }
+
+ public void begin() {
+ try {
+ lookupJeeUserTransaction().begin();
+ } catch (Exception e) {
+ throw new JbpmException("couldn't begin transaction: "+e.getMessage(), e);
+ }
+ }
+
+ public void rollback() {
+ try {
+ lookupJeeUserTransaction().rollback();
+ } catch (Exception e) {
+ throw new JbpmException("couldn't rollback: "+e.getMessage(), e);
+ }
+ }
+
+ public void commit() {
+ try {
+ flushDeserializedObjects();
+
+ lookupJeeUserTransaction().commit();
+ } catch (Exception e) {
+ throw new JbpmException("couldn't commit: "+e.getMessage(), e);
+ }
+ }
+
+ public javax.transaction.Transaction suspend() {
+ try {
+ return lookupJeeTransactionManager().suspend();
+ } catch (Exception e) {
+ throw new JbpmException("couldn't suspend: "+e.getMessage(), e);
+ }
+ }
+
+ public void resume(javax.transaction.Transaction transaction) {
+ try {
+ lookupJeeTransactionManager().resume(transaction);
+ } catch (Exception e) {
+ throw new JbpmException("couldn't resume: "+e.getMessage(), e);
+ }
+ }
+
+ // lookups //////////////////////////////////////////////////////////////////
+
+ public UserTransaction lookupJeeUserTransaction() {
+ return (UserTransaction) lookupFromJndi(userTransactionJndiName);
+ }
+
+ public javax.transaction.Transaction lookupJeeTransaction() {
+ try {
+ TransactionManager transactionManager = lookupJeeTransactionManager();
+ return transactionManager.getTransaction();
+ } catch (Exception e) {
+ throw new JbpmException("couldn't get transaction from transaction manager "+transactionManagerJndiName+": "+e.getMessage(), e);
+ }
+ }
+
+ public TransactionManager lookupJeeTransactionManager() {
+ return (TransactionManager) lookupFromJndi(transactionManagerJndiName);
+ }
+
+ public static Object lookupFromJndi(String jndiName) {
+ try {
+ InitialContext initialContext = new InitialContext();
+ return initialContext.lookup(jndiName);
+ } catch (Exception e) {
+ throw new JbpmException("couldn't lookup '"+jndiName+"' from jndi: "+e.getMessage()+": "+e.getMessage(), e);
+ }
+ }
+
+ public static int getUserTransactionStatus(UserTransaction userTransaction) {
+ int status = -1;
+ try {
+ status = userTransaction.getStatus();
+ } catch (SystemException e) {
+ throw new JbpmException("couldn't get transaction status: "+e.getMessage(), e);
+ }
+ log.trace("jta transaction status: "+JtaStatusHelper.toString(status));
+ return status;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/JtaTransaction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/JtaTransactionInterceptor.java (from rev 5974, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/jta/JtaTransactionInterceptor.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/JtaTransactionInterceptor.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/JtaTransactionInterceptor.java 2009-12-17 11:06:19 UTC (rev 5977)
@@ -0,0 +1,108 @@
+/*
+ * 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 javax.transaction.Status;
+import javax.transaction.Transaction;
+import javax.transaction.UserTransaction;
+
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.cmd.Command;
+import org.jbpm.internal.log.Log;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.jbpm.pvm.internal.svc.Interceptor;
+import org.jbpm.pvm.internal.svc.Policy;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class JtaTransactionInterceptor extends Interceptor {
+
+ private static Log log = Log.getLog(JtaTransactionInterceptor.class.getName());
+
+ protected Policy policy = Policy.REQUIRES;
+
+ public <T> T execute(Command<T> command) {
+ JtaTransaction jtaTransaction = EnvironmentImpl.getFromCurrent(JtaTransaction.class);
+
+ UserTransaction userTransaction = jtaTransaction.lookupJeeUserTransaction();
+
+ int status = JtaTransaction.getUserTransactionStatus(userTransaction);
+
+ if ( (status == Status.STATUS_ACTIVE)
+ && (! (policy==Policy.REQUIRES_NEW))
+ ) {
+ return executeInExistingTx(command);
+ }
+
+ if ( (status != Status.STATUS_NO_TRANSACTION)
+ && (status != Status.STATUS_COMMITTED)
+ && (status != Status.STATUS_ROLLEDBACK)
+ && (policy != Policy.REQUIRES_NEW)
+ ) {
+ throw new JbpmException("invalid transaction state: "+JtaStatusHelper.toString(status));
+ }
+
+ return executeInNewTx(command, jtaTransaction, status);
+ }
+
+ protected <T> T executeInExistingTx(Command<T> command) {
+ return next.execute(command);
+ }
+
+ protected <T> T executeInNewTx(Command<T> command, JtaTransaction jtaTransaction, int status) {
+ Transaction suspendedTransaction = null;
+ if ( (status == Status.STATUS_ACTIVE)
+ || (status == Status.STATUS_COMMITTED)
+ || (status == Status.STATUS_ROLLEDBACK)
+ ) {
+ suspendedTransaction = jtaTransaction.suspend();
+ }
+
+ T returnValue = null;
+
+ try {
+ jtaTransaction.begin();
+
+ returnValue = next.execute(command);
+
+ jtaTransaction.commit();
+
+ } catch (RuntimeException e) {
+ jtaTransaction.rollback();
+ throw e;
+
+ } finally {
+
+ if (suspendedTransaction!=null) {
+ jtaTransaction.resume(suspendedTransaction);
+ }
+ }
+
+ return returnValue;
+ }
+
+ public void setPolicy(Policy policy) {
+ this.policy = policy;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/JtaTransactionInterceptor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java 2009-12-17 10:44:53 UTC (rev 5976)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java 2009-12-17 11:06:19 UTC (rev 5977)
@@ -32,7 +32,6 @@
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
import org.jbpm.pvm.internal.tx.DeserializedObject;
-import org.jbpm.pvm.internal.tx.FlushDeserializedObject;
import org.jbpm.pvm.internal.tx.Transaction;
import org.jbpm.pvm.internal.type.Converter;
import org.jbpm.pvm.internal.type.Variable;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JtaTransactionInterceptorBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JtaTransactionInterceptorBinding.java 2009-12-17 10:44:53 UTC (rev 5976)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/JtaTransactionInterceptorBinding.java 2009-12-17 11:06:19 UTC (rev 5977)
@@ -22,7 +22,7 @@
package org.jbpm.pvm.internal.wire.binding;
import org.jbpm.pvm.internal.svc.Policy;
-import org.jbpm.pvm.internal.tx.jta.JtaTransactionInterceptor;
+import org.jbpm.pvm.internal.tx.JtaTransactionInterceptor;
import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RetryInterceptorBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RetryInterceptorBinding.java 2009-12-17 10:44:53 UTC (rev 5976)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/RetryInterceptorBinding.java 2009-12-17 11:06:19 UTC (rev 5977)
@@ -22,7 +22,7 @@
package org.jbpm.pvm.internal.wire.binding;
import org.jbpm.pvm.internal.svc.RetryInterceptor;
-import org.jbpm.pvm.internal.tx.jta.JtaRetryInterceptor;
+import org.jbpm.pvm.internal.tx.JtaRetryInterceptor;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.descriptor.ProvidedObjectDescriptor;
import org.jbpm.pvm.internal.xml.Parse;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TransactionBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TransactionBinding.java 2009-12-17 10:44:53 UTC (rev 5976)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/TransactionBinding.java 2009-12-17 11:06:19 UTC (rev 5977)
@@ -21,10 +21,10 @@
*/
package org.jbpm.pvm.internal.wire.binding;
+import org.jbpm.pvm.internal.tx.JtaTransaction;
import org.jbpm.pvm.internal.tx.SpringTransaction;
import org.jbpm.pvm.internal.tx.StandardTransaction;
import org.jbpm.pvm.internal.tx.Transaction;
-import org.jbpm.pvm.internal.tx.jta.JtaTransaction;
import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JbossIdmIdentitySessionDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JbossIdmIdentitySessionDescriptor.java 2009-12-17 10:44:53 UTC (rev 5976)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/JbossIdmIdentitySessionDescriptor.java 2009-12-17 11:06:19 UTC (rev 5977)
@@ -28,8 +28,8 @@
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.identity.impl.IdentitySessionResource;
import org.jbpm.pvm.internal.identity.impl.JBossIdmIdentitySessionImpl;
+import org.jbpm.pvm.internal.tx.JtaTransaction;
import org.jbpm.pvm.internal.tx.StandardTransaction;
-import org.jbpm.pvm.internal.tx.jta.JtaTransaction;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.WireDefinition;
16 years, 4 months
JBoss JBPM SVN: r5976 - in jbpm4/trunk/modules: distro/src/main/files/install/src/cfg/hibernate/spring and 4 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-12-17 05:44:53 -0500 (Thu, 17 Dec 2009)
New Revision: 5976
Added:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringCommandCallback.java
Modified:
jbpm4/trunk/modules/distro/src/main/files/install/build.xml
jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/hsqldb.inmem.hibernate.cfg.xml
jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/spring/applicationContext.xml
jbpm4/trunk/modules/pvm/pom.xml
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionFactory.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionInterceptor.java
jbpm4/trunk/modules/test-db/pom.xml
Log:
JBPM-2631 spring transactions. finally there. phew.
Modified: jbpm4/trunk/modules/distro/src/main/files/install/build.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/build.xml 2009-12-17 09:17:28 UTC (rev 5975)
+++ jbpm4/trunk/modules/distro/src/main/files/install/build.xml 2009-12-17 10:44:53 UTC (rev 5976)
@@ -200,7 +200,9 @@
</target>
<target name="internal.copy.spring.applicationContext" if="is.spring.environment">
- <copy todir="${cfg.dest.dir}" overwrite="true" file="${install.src.dir}/cfg/spring/applicationContext.xml" />
+ <copy todir="${cfg.dest.dir}" overwrite="true" file="${install.src.dir}/cfg/spring/applicationContext.xml">
+ <filterset filtersfile="${jdbc.properties.dir}/${database}.properties" />
+ </copy>
</target>
<!-- ### CREATE USER WEBAPP ########################################## -->
Modified: jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/hsqldb.inmem.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/hsqldb.inmem.hibernate.cfg.xml 2009-12-17 09:17:28 UTC (rev 5975)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/hibernate/spring/hsqldb.inmem.hibernate.cfg.xml 2009-12-17 10:44:53 UTC (rev 5976)
@@ -9,6 +9,7 @@
<property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
<property name="current_session_context_class">thread</property>
+ <!-- property name="hibernate.transaction.factory_class">org.jbpm.pvm.internal.tx.SpringTransactionFactory</property -->
<!-- property name="hibernate.transaction.factory_class">org.springframework.orm.hibernate3.SpringTransactionFactory</property -->
<property name="hibernate.format_sql">true</property>
Modified: jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/spring/applicationContext.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/spring/applicationContext.xml 2009-12-17 09:17:28 UTC (rev 5975)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/spring/applicationContext.xml 2009-12-17 10:44:53 UTC (rev 5976)
@@ -26,10 +26,10 @@
</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="" />
+ <property name="driverClassName" value="@jdbc.driver@" />
+ <property name="url" value="@jdbc.url@" />
+ <property name="username" value="@jdbc.username@" />
+ <property name="password" value="@jdbc.password@" />
</bean>
</beans>
\ No newline at end of file
Modified: jbpm4/trunk/modules/pvm/pom.xml
===================================================================
--- jbpm4/trunk/modules/pvm/pom.xml 2009-12-17 09:17:28 UTC (rev 5975)
+++ jbpm4/trunk/modules/pvm/pom.xml 2009-12-17 10:44:53 UTC (rev 5976)
@@ -187,6 +187,7 @@
<configuration>
<excludes>
<exclude>**/*TestCase.java</exclude>
+ <exclude>org/jbpm/examples/bpmn/gateway/exclusive/ExclusiveGateway*</exclude>
</excludes>
</configuration>
</plugin>
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringCommandCallback.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringCommandCallback.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringCommandCallback.java 2009-12-17 10:44:53 UTC (rev 5976)
@@ -0,0 +1,54 @@
+/*
+ * 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.jbpm.api.cmd.Command;
+import org.jbpm.pvm.internal.cmd.CommandService;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
+import org.springframework.transaction.TransactionStatus;
+import org.springframework.transaction.support.TransactionCallback;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SpringCommandCallback implements TransactionCallback {
+
+ CommandService next;
+ Command<Object> command;
+
+ public SpringCommandCallback(CommandService next, Command command) {
+ this.next = next;
+ this.command = command;
+ }
+
+ public Object doInTransaction(TransactionStatus status) {
+ Object returnValue = next.execute(command);
+
+ EnvironmentImpl
+ .getFromCurrent(SpringTransaction.class)
+ .flushDeserializedObjects();
+
+ return returnValue;
+ }
+
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringCommandCallback.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionFactory.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionFactory.java 2009-12-17 09:17:28 UTC (rev 5975)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionFactory.java 2009-12-17 10:44:53 UTC (rev 5976)
@@ -67,9 +67,14 @@
public boolean isTransactionInProgress(
JDBCContext jdbcContext, Context transactionContext, Transaction transaction) {
+
+ for (StackTraceElement stackTraceElement: new Exception().getStackTrace()) {
+ if (stackTraceElement.getClassName().equals(SpringTransactionInterceptor.class.getName())) {
+ return true;
+ }
+ }
- return (transaction != null && transaction.isActive()) ||
- TransactionSynchronizationManager.isActualTransactionActive();
+ return (transaction != null && transaction.isActive());
}
}
Modified: 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 2009-12-17 09:17:28 UTC (rev 5975)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionInterceptor.java 2009-12-17 10:44:53 UTC (rev 5976)
@@ -31,6 +31,7 @@
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.AbstractPlatformTransactionManager;
import org.springframework.transaction.support.DefaultTransactionDefinition;
+import org.springframework.transaction.support.TransactionTemplate;
/**
* calls setRollbackOnly on the transaction in the environment in case an
@@ -43,35 +44,36 @@
@SuppressWarnings("unused")
private static final Log log = Log.getLog(SpringTransactionInterceptor.class.getName());
- protected int springPropagationBehaviour = -1;
+ protected int springPropagationBehaviour = TransactionDefinition.PROPAGATION_REQUIRED;
private String transactionManagerName;
@SuppressWarnings("unchecked")
public <T> T execute(Command<T> command) {
- T returnValue = null;
+ AbstractPlatformTransactionManager platformTransactionManager = (AbstractPlatformTransactionManager) resolveTransactionManager();
+ TransactionTemplate template = new TransactionTemplate(platformTransactionManager);
+ template.setPropagationBehavior(springPropagationBehaviour);
+ return (T) template.execute(new SpringCommandCallback(next, command));
- AbstractPlatformTransactionManager platformTransactionManager = (AbstractPlatformTransactionManager) resolveTransactionManager();
- DefaultTransactionDefinition transactionDefinition = new DefaultTransactionDefinition(springPropagationBehaviour);
- TransactionStatus transactionStatus = platformTransactionManager.getTransaction(transactionDefinition);
- boolean completedSuccessfully = false;
- try {
- returnValue = next.execute(command);
-
- EnvironmentImpl
- .getFromCurrent(SpringTransaction.class)
- .flushDeserializedObjects();
-
- completedSuccessfully = true;
-
- } finally {
- if (completedSuccessfully) {
- platformTransactionManager.commit(transactionStatus);
- } else {
- platformTransactionManager.rollback(transactionStatus);
- }
- }
-
- return returnValue;
+// TransactionStatus transactionStatus = platformTransactionManager.getTransaction(transactionDefinition);
+// boolean completedSuccessfully = false;
+// try {
+// returnValue = next.execute(command);
+//
+// EnvironmentImpl
+// .getFromCurrent(SpringTransaction.class)
+// .flushDeserializedObjects();
+//
+// completedSuccessfully = true;
+//
+// } finally {
+// if (completedSuccessfully) {
+// platformTransactionManager.commit(transactionStatus);
+// } else {
+// platformTransactionManager.rollback(transactionStatus);
+// }
+// }
+//
+// return returnValue;
}
/**
Modified: jbpm4/trunk/modules/test-db/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-db/pom.xml 2009-12-17 09:17:28 UTC (rev 5975)
+++ jbpm4/trunk/modules/test-db/pom.xml 2009-12-17 10:44:53 UTC (rev 5976)
@@ -169,6 +169,7 @@
<tasks>
<ant antfile="../distro/src/main/files/install/build.xml" target="create.cfg">
<property name="tx" value="spring.testsuite" />
+ <property name="hibernate.connection.type" value="spring" />
<property name="database" value="hsqldb.inmem" />
<property name="mail.cfg" value="testsuite" />
<property name="cfg.dest.dir" value="target/test-classes" />
@@ -181,6 +182,17 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <failIfNoTests>false</failIfNoTests>
+ <trimStackTrace>false</trimStackTrace>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <excludes>
+ <exclude>org/jbpm/test/reporting/SQLStmtTest.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
</plugins>
</build>
</profile>
16 years, 4 months