JBoss JBPM SVN: r5954 - jbpm4/trunk/modules/devguide/src/main/docbook/en/modules.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-12-11 09:58:09 -0500 (Fri, 11 Dec 2009)
New Revision: 5954
Modified:
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch16-SpringIntegration.xml
Log:
Changed Spring documentation to reflect current capabilities
Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch16-SpringIntegration.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch16-SpringIntegration.xml 2009-12-11 14:03:18 UTC (rev 5953)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch16-SpringIntegration.xml 2009-12-11 14:58:09 UTC (rev 5954)
@@ -34,13 +34,23 @@
<section id="spring_configuration">
<title>Configuration</title>
+ <para>
+ The easiest way to integrate Spring with jBPM is to import the <emphasis role="bold">jbpm.tx.spring.cfg.xml</emphasis>
+ in your jbpm.cfg.xml file:
+ <programlisting>
+<import resource="jbpm.tx.spring.cfg.xml" />
+ </programlisting>
+ This configuration use the single transaction manager which is defined in the Spring configuration.
+ Start from the content of this file if you need to tweak the jBPM-Spring integration
+ configuration.
+ </para>
<para>
- Replace the standard-transaction-interceptor with the
- spring-transaction-interceptor. The hibernate session needs the attribute current=”true”.
- Also, the <transaction/> must be removed from the transaction-context if you want the
- transactions to be handled by Spring only.
- This forces jBPM to search for the current session,
- which will be provided by Spring.
+ If you start from an existing configuration, replace the standard-transaction-interceptor with the
+ spring-transaction-interceptor. The hibernate session needs the attribute current=”true”,
+ depending if you are using the 'current Session' strategy in Spring.
+ Also, the <transaction/> must be removed from the transaction-context if you want the
+ transactions to be handled by Spring only.
+ This forces jBPM to search for the current session, which will then be provided by Spring.
<programlisting>
<process-engine-context>
<command-service>
@@ -57,8 +67,18 @@
</para>
<para>
+ The spring-transaction-interceptor will look by default for a PlatformTransactionManager
+ implementation by doing a search by type on the defined beans. In the case of multiple
+ transaction managers, it is possible to specifically define the name of the transaction manager
+ that must be used by the interceptor:
+ <programlisting>
+<spring-transaction-interceptor transaction-manager="<emphasis role="bold">myTransactionManager</emphasis>" />
+ </programlisting>
+ </para>
+
+ <para>
The Spring integration provides a special context, which is added to
- the set of context where the jBPM engine will look for beans.
+ the set of contexts where the jBPM engine will look for beans.
Using this SpringContext, it is now possible to retrieve beans from the
Spring Application Context. For the Spring context to be known, a
SpringConfiguration must be created. This class extends the JbpmConfiguration
@@ -72,9 +92,15 @@
</para>
<para>
+ Using this configuration, a ProcessEngine can be created:
+ <programlisting>
+<bean id="processEngine" factory-bean="jbpmConfiguration" factory-method="buildProcessEngine" />
+ </programlisting>
+ </para>
+
+ <para>
The jBPM services can also be defined in the Spring applicationContext, as following:
<programlisting>
-<bean id="processEngine" factory-bean="jbpmConfiguration" factory-method="buildProcessEngine" />
<bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
<bean id="executionService" factory-bean="processEngine" factory-method="getExecutionService" />
</programlisting>
16 years, 4 months
JBoss JBPM SVN: r5953 - in jbpm4/trunk/modules: test-cfg/src/test/java/org/jbpm/test/spring and 5 other directories.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-12-11 09:03:18 -0500 (Fri, 11 Dec 2009)
New Revision: 5953
Added:
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/expression/
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/expression/eventlistener/
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/expression/eventlistener/MyEventListener.java
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/expression/eventlistener/ResolveEventListenerTest.java
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/
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/jbpm.cfg.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/jbpm.hibernate.cfg.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/log4j.properties
Modified:
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/AbstractTransactionalSpringJbpmTestCase.java
Log:
JBPM-2529: Resolving eventListeners as a Spring bean doesn't work
Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/AbstractTransactionalSpringJbpmTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/AbstractTransactionalSpringJbpmTestCase.java 2009-12-11 12:41:00 UTC (rev 5952)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/AbstractTransactionalSpringJbpmTestCase.java 2009-12-11 14:03:18 UTC (rev 5953)
@@ -72,6 +72,17 @@
taskService = processEngine.getTaskService();
identityService = processEngine.getIdentityService();
}
+
+ /**
+ * By default, the applicationContext.xml file in the same package as the test class
+ * is used to initialize the Spring container.
+ *
+ * Override this method if you don't need this default behaviour.
+ */
+ @Override
+ protected String getConfigPath() {
+ return "applicationContext.xml";
+ }
/**
* Default configuration name. Overwrite this if the jbpm configuration is
Added: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/expression/eventlistener/MyEventListener.java
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/expression/eventlistener/MyEventListener.java (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/expression/eventlistener/MyEventListener.java 2009-12-11 14:03:18 UTC (rev 5953)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.spring.expression.eventlistener;
+
+import org.jbpm.api.listener.EventListener;
+import org.jbpm.api.listener.EventListenerExecution;
+
+/**
+ *
+ * @author Joram Barrez
+ */
+public class MyEventListener implements EventListener {
+
+ private static final long serialVersionUID = 1L;
+
+ private static final String VARIABLE = "testVar";
+
+ public void notify(EventListenerExecution execution) throws Exception {
+ Integer var = (Integer) execution.getVariable(VARIABLE);
+ var = var + 1;
+ execution.setVariable(VARIABLE, var);
+ }
+
+}
Added: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/expression/eventlistener/ResolveEventListenerTest.java
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/expression/eventlistener/ResolveEventListenerTest.java (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/expression/eventlistener/ResolveEventListenerTest.java 2009-12-11 14:03:18 UTC (rev 5953)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.spring.expression.eventlistener;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.test.AbstractTransactionalSpringJbpmTestCase;
+
+/**
+ * Tests if event listeners can be resolved when they are defined as Spring beans.
+ *
+ * Test originally created for JBPM-2529
+ *
+ * @author Joram Barrez
+ */
+public class ResolveEventListenerTest extends AbstractTransactionalSpringJbpmTestCase {
+
+ private final String TEST_PROCESS =
+ "<?xml version='1.0' encoding='UTF-8'?>" +
+ "<process name='testProcess'>" +
+ " <start name='start'>" +
+ " <transition name='to a' to='a' />" +
+ " </start>" +
+ " <state name='a'>" +
+ " <on event='start'>" +
+ " <event-listener expr='${myEventListener}' />" +
+ " </on>" +
+ " <transition name='to end' to='theEnd' />" +
+ " </state>" +
+ " <end name='theEnd' />" +
+ "</process>";
+
+ public void testResolveEventListener() {
+
+ deployJpdlXmlString(TEST_PROCESS);
+
+ // We start a process and insert a variable with value 1234
+ Map<String, Object> vars = new HashMap<String, Object>();
+ final String var = "testVar";
+ final Integer varValue = new Integer(1234);
+ vars.put(var, varValue);
+
+ ProcessInstance pi = executionService.startProcessInstanceByKey("testProcess", vars);
+ assertTrue(pi.isActive("a"));
+
+ // The event listener should've added 1 to the variable value
+ Integer value = (Integer) executionService.getVariable(pi.getId(), var);
+ assertEquals(new Integer(varValue + 1), value);
+ }
+
+}
Added: 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 (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/applicationContext.xml 2009-12-11 14:03:18 UTC (rev 5953)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
+ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
+
+
+ <bean id="myEventListener" class="org.jbpm.test.spring.expression.eventlistener.MyEventListener" />
+
+ <bean id="jbpmConfiguration" class="org.jbpm.pvm.internal.cfg.SpringConfiguration">
+ <constructor-arg value="org/jbpm/test/spring/expression/eventlistener/jbpm.cfg.xml" />
+ </bean>
+
+ <bean id="processEngine" factory-bean="jbpmConfiguration" factory-method="buildProcessEngine" />
+
+ <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
+ <property name="configLocation" value="classpath:org/jbpm/test/spring/transactionmanager/jbpm.hibernate.cfg.xml" />
+ <!-- A best practice should be to keep split the config into multiple files
+ <property name="configLocations" value="hibernate.cfg.xml, hibernate.jbpm.cfg.xml" />
+ -->
+ <property name="dataSource" ref="dataSource" />
+ </bean>
+
+ <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
+ <property name="sessionFactory" ref="sessionFactory" />
+ <property name="dataSource" ref="dataSource" />
+ </bean>
+
+ <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
+ <property name="url" value="jdbc:hsqldb:mem:." />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </bean>
+
+</beans>
\ No newline at end of file
Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/jbpm.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/jbpm.cfg.xml 2009-12-11 14:03:18 UTC (rev 5953)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+ <import resource="jbpm.default.cfg.xml" />
+ <import resource="jbpm.jpdl.cfg.xml" />
+ <import resource="jbpm.bpmn.cfg.xml" />
+ <import resource="jbpm.identity.cfg.xml" />
+ <import resource="jbpm.businesscalendar.cfg.xml" />
+ <import resource="jbpm.console.cfg.xml" />
+
+ <!-- Spring configuration -->
+ <import resource="jbpm.tx.spring.cfg.xml" />
+
+</jbpm-configuration>
Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/jbpm.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/jbpm.hibernate.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/jbpm.hibernate.cfg.xml 2009-12-11 14:03:18 UTC (rev 5953)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory>
+
+ <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+ <property name="hibernate.format_sql">true</property>
+
+ <property name="hibernate.hbm2ddl.auto">create-drop</property>
+
+ <mapping resource="jbpm.repository.hbm.xml" />
+ <mapping resource="jbpm.execution.hbm.xml" />
+ <mapping resource="jbpm.history.hbm.xml" />
+ <mapping resource="jbpm.task.hbm.xml" />
+ <mapping resource="jbpm.identity.hbm.xml" />
+
+ </session-factory>
+</hibernate-configuration>
Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/log4j.properties
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/log4j.properties (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/expression/eventlistener/log4j.properties 2009-12-11 14:03:18 UTC (rev 5953)
@@ -0,0 +1,4 @@
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+log4j.rootLogger=info, stdout
\ No newline at end of file
16 years, 4 months
JBoss JBPM SVN: r5952 - jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/transactionmanager.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-12-11 07:41:00 -0500 (Fri, 11 Dec 2009)
New Revision: 5952
Modified:
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/transactionmanager/ResolveTransactionManagerTest.java
Log:
Removed unused import
Modified: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/transactionmanager/ResolveTransactionManagerTest.java
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/transactionmanager/ResolveTransactionManagerTest.java 2009-12-11 12:38:22 UTC (rev 5951)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/transactionmanager/ResolveTransactionManagerTest.java 2009-12-11 12:41:00 UTC (rev 5952)
@@ -6,7 +6,6 @@
import org.jbpm.api.RepositoryService;
import org.jbpm.test.AbstractTransactionalSpringJbpmTestCase;
import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
-import org.springframework.transaction.PlatformTransactionManager;
/**
* Note: cannot use {@link AbstractTransactionalSpringJbpmTestCase}, since this autowires
16 years, 4 months
JBoss JBPM SVN: r5951 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/env and 10 other directories.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-12-11 07:38:22 -0500 (Fri, 11 Dec 2009)
New Revision: 5951
Added:
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/transactionmanager/
jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/transactionmanager/ResolveTransactionManagerTest.java
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/
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
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/jbpm.hibernate.cfg.xml
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/log4j.properties
jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/process.jpdl.xml
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/SpringConfiguration.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/SpringContext.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionInterceptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SpringTransactionInterceptorBinding.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.spring.cfg.xml
jbpm4/trunk/modules/test-cfg/pom.xml
Log:
JBPM-2558: resolve Spring transaction manager by name
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/SpringConfiguration.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/SpringConfiguration.java 2009-12-11 10:55:27 UTC (rev 5950)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/SpringConfiguration.java 2009-12-11 12:38:22 UTC (rev 5951)
@@ -50,8 +50,6 @@
private ApplicationContext applicationContext;
- private String jbpmConfigurationLocation;
-
/**
* Instantiates a new spring configuration.
*/
@@ -121,7 +119,6 @@
/**
* {@inheritDoc)
-
*/
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/SpringContext.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/SpringContext.java 2009-12-11 10:55:27 UTC (rev 5950)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/env/SpringContext.java 2009-12-11 12:38:22 UTC (rev 5951)
@@ -25,6 +25,7 @@
import java.util.HashSet;
import java.util.Set;
+import org.jbpm.internal.log.Log;
import org.springframework.context.ApplicationContext;
/**
@@ -32,6 +33,8 @@
*
*/
public class SpringContext implements Context {
+
+ private static final Log LOG = Log.getLog(SpringContext.class.getName());
private ApplicationContext applicationContext;
@@ -54,9 +57,13 @@
@SuppressWarnings("unchecked")
public <T> T get(Class<T> type) {
String[] names = applicationContext.getBeanNamesForType(type);
- if (names.length == 1) {
- return (T) applicationContext.getBean(names[0]);
+ if (names.length > 1 && LOG.isWarnEnabled()) {
+ LOG.warn("Multiple Spring beans found for type " + type + " returning the first one found");
}
+
+ if (names.length >= 1) {
+ return (T) applicationContext.getBean(names[0]);
+ }
return null;
}
@@ -84,7 +91,7 @@
* @see org.jbpm.api.env.Context#keys()
*/
public Set<String> keys() {
- Set set = new HashSet<String>(Arrays.asList(applicationContext.getBeanDefinitionNames()));
+ Set<String> set = new HashSet<String>(Arrays.asList(applicationContext.getBeanDefinitionNames()));
return set;
}
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-11 10:55:27 UTC (rev 5950)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/SpringTransactionInterceptor.java 2009-12-11 12:38:22 UTC (rev 5951)
@@ -41,10 +41,13 @@
*/
public class SpringTransactionInterceptor extends Interceptor {
+ @SuppressWarnings("unused")
private static final Log log = Log.getLog(SpringTransactionInterceptor.class.getName());
private boolean useCurrent;
+ private String transactionManagerName;
+
@SuppressWarnings("unchecked")
public <T> T execute(Command<T> command) {
EnvironmentImpl environment = EnvironmentImpl.getCurrent();
@@ -53,8 +56,7 @@
}
StandardTransaction standardTransaction = environment.get(StandardTransaction.class);
-
- PlatformTransactionManager platformTransactionManager = environment.get(PlatformTransactionManager.class);
+ PlatformTransactionManager platformTransactionManager = resolveTransactionManager(environment);
if (platformTransactionManager == null) {
throw new JbpmException("No platformTransaction manager defined.");
}
@@ -64,22 +66,22 @@
}
try {
-
+
TransactionTemplate template = new TransactionTemplate(platformTransactionManager);
if (useCurrent) {
- template.setPropagationBehavior(TransactionDefinition.PROPAGATION_MANDATORY);
+ template.setPropagationBehavior(TransactionDefinition.PROPAGATION_MANDATORY);
} else {
- template.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
+ template.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
}
TransactionCallback transactionCallback = new CommandTransactionCallback<T>(command, next, platformTransactionManager);
T t = (T) template.execute(transactionCallback);
Session session = environment.get(Session.class);
-
+
if (session.isOpen()) {
- session.flush();
+ session.flush();
}
return t;
} catch (RuntimeException e) {
@@ -95,7 +97,31 @@
}
}
+ /**
+ * Resolves the transaction manager from the environment.
+ * @param environment
+ * @return the transaction manager
+ */
+ private PlatformTransactionManager resolveTransactionManager(EnvironmentImpl environment) {
+ PlatformTransactionManager platformTransactionManager;
+
+ if (transactionManagerName != null && transactionManagerName.length() > 0) {
+ platformTransactionManager = (PlatformTransactionManager) environment.get(transactionManagerName);
+
+ if (platformTransactionManager == null) {
+ throw new JbpmException("No platformTransaction manager defined for name '" + platformTransactionManager + "'");
+ }
+ } else {
+ platformTransactionManager = environment.get(PlatformTransactionManager.class);
+ }
+ return platformTransactionManager;
+ }
+
public void setUseCurrent(Boolean useCurrent) {
this.useCurrent = useCurrent;
}
+
+ public void setTransactionManagerName(String transactionManagerName) {
+ this.transactionManagerName = transactionManagerName;
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SpringTransactionInterceptorBinding.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SpringTransactionInterceptorBinding.java 2009-12-11 10:55:27 UTC (rev 5950)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/SpringTransactionInterceptorBinding.java 2009-12-11 12:38:22 UTC (rev 5951)
@@ -50,6 +50,11 @@
springTransactionInterceptor.setUseCurrent(useCurrent);
}
+ String transactionManagerName = XmlUtil.attribute(element, "transaction-manager");
+ if (transactionManagerName!=null) {
+ springTransactionInterceptor.setTransactionManagerName(transactionManagerName);
+ }
+
return new ProvidedObjectDescriptor(springTransactionInterceptor);
}
}
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.spring.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.spring.cfg.xml 2009-12-11 10:55:27 UTC (rev 5950)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.spring.cfg.xml 2009-12-11 12:38:22 UTC (rev 5951)
@@ -7,7 +7,7 @@
<command-service name="newTxRequiredCommandService">
<retry-interceptor />
<environment-interceptor policy="requiresNew" />
- <standard-transaction-interceptor />
+ <spring-transaction-interceptor />
</command-service>
<!-- Default command service has a Spring transaction interceptor-->
Modified: jbpm4/trunk/modules/test-cfg/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/pom.xml 2009-12-11 10:55:27 UTC (rev 5950)
+++ jbpm4/trunk/modules/test-cfg/pom.xml 2009-12-11 12:38:22 UTC (rev 5951)
@@ -45,6 +45,11 @@
</dependency>
<dependency>
<groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-bpmn</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
<artifactId>jbpm-test-base</artifactId>
<scope>test</scope>
</dependency>
@@ -53,6 +58,11 @@
<artifactId>spring</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-mock</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Added: jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/transactionmanager/ResolveTransactionManagerTest.java
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/transactionmanager/ResolveTransactionManagerTest.java (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/java/org/jbpm/test/spring/transactionmanager/ResolveTransactionManagerTest.java 2009-12-11 12:38:22 UTC (rev 5951)
@@ -0,0 +1,66 @@
+package org.jbpm.test.spring.transactionmanager;
+
+import org.jbpm.api.ExecutionService;
+import org.jbpm.api.ProcessEngine;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.RepositoryService;
+import org.jbpm.test.AbstractTransactionalSpringJbpmTestCase;
+import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
+import org.springframework.transaction.PlatformTransactionManager;
+
+/**
+ * Note: cannot use {@link AbstractTransactionalSpringJbpmTestCase}, since this autowires
+ * by name and expects a 'transactionManager' bean to be defined, which is exactly what we don't
+ * want here.
+ *
+ * Test case created because of JBPM-2558: when using multiple transaction managers in Spring,
+ * it is required to be able to declare which transaction manager should be used.
+ *
+ * @author Joram Barrez
+ */
+public class ResolveTransactionManagerTest extends AbstractDependencyInjectionSpringContextTests {
+
+ protected ProcessEngine processEngine;
+
+ private ExecutionService executionService;
+
+ private RepositoryService repositoryService;
+
+
+ public ResolveTransactionManagerTest() {
+ setPopulateProtectedVariables(true);
+ }
+
+ @Override
+ protected void onSetUp() throws Exception {
+ super.onSetUp();
+ this.executionService = processEngine.getExecutionService();
+ this.repositoryService = processEngine.getRepositoryService();
+ }
+
+ @Override
+ protected String getConfigPath() {
+ return "applicationContext.xml";
+ }
+
+ public void testGetTransactionManagerByName() {
+ assertNotNull(processEngine.get("someOtherTransactionManager"));
+ assertNotNull(processEngine.get("transactionManager"));
+ }
+
+ // Execute a simple process to verify the correct working of the transactionManager
+ public void testExecuteSimpleProcess() {
+
+ String deployId = repositoryService.createDeployment()
+ .addResourceFromClasspath("org/jbpm/test/spring/transactionmanager/process.jpdl.xml")
+ .deploy();
+
+ ProcessInstance pi = executionService.startProcessInstanceByKey("simpleProcess");
+ pi = executionService.signalExecutionById(pi.findActiveExecutionIn("a").getId());
+ pi = executionService.signalExecutionById(pi.findActiveExecutionIn("b").getId());
+ assertTrue(executionService.findProcessInstanceById(pi.getId()) == null);
+
+ repositoryService.deleteDeploymentCascade(deployId);
+ }
+
+}
Added: 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 (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/applicationContext.xml 2009-12-11 12:38:22 UTC (rev 5951)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
+ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
+
+ <bean id="jbpmConfiguration" class="org.jbpm.pvm.internal.cfg.SpringConfiguration">
+ <constructor-arg value="org/jbpm/test/spring/transactionmanager/jbpm.cfg.xml" />
+ </bean>
+
+ <bean id="processEngine" factory-bean="jbpmConfiguration" factory-method="buildProcessEngine" />
+
+ <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
+ <property name="configLocation" value="classpath:org/jbpm/test/spring/transactionmanager/jbpm.hibernate.cfg.xml" />
+ <!-- A best practice should be to keep split the config into multiple files
+ <property name="configLocations" value="hibernate.cfg.xml, hibernate.jbpm.cfg.xml" />
+ -->
+ <property name="dataSource" ref="dataSource" />
+ </bean>
+
+ <bean id="someOtherTransactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
+ <property name="sessionFactory" ref="sessionFactory" />
+ <property name="dataSource" ref="dataSource" />
+ </bean>
+
+ <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
+ <property name="sessionFactory" ref="sessionFactory" />
+ <property name="dataSource" ref="dataSource" />
+ </bean>
+
+ <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
+ <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
+ <property name="url" value="jdbc:hsqldb:mem:." />
+ <property name="username" value="sa" />
+ <property name="password" value="" />
+ </bean>
+
+</beans>
\ No newline at end of file
Added: 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 (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/jbpm.cfg.xml 2009-12-11 12:38:22 UTC (rev 5951)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration>
+
+ <import resource="jbpm.default.cfg.xml" />
+ <import resource="jbpm.jpdl.cfg.xml" />
+ <import resource="jbpm.bpmn.cfg.xml" />
+ <import resource="jbpm.identity.cfg.xml" />
+ <import resource="jbpm.businesscalendar.cfg.xml" />
+ <import resource="jbpm.console.cfg.xml" />
+
+ <!-- Spring specific configuration -->
+ <process-engine-context>
+
+ <command-service name="newTxRequiredCommandService">
+ <retry-interceptor />
+ <environment-interceptor policy="requiresNew" />
+ <spring-transaction-interceptor transaction-manager="someOtherTransactionManager"/>
+ </command-service>
+
+ <command-service name="txRequiredCommandService">
+ <retry-interceptor />
+ <environment-interceptor />
+ <spring-transaction-interceptor transaction-manager="someOtherTransactionManager"/>
+ </command-service>
+
+ </process-engine-context>
+
+ <transaction-context>
+ <transaction />
+ <hibernate-session />
+ </transaction-context>
+
+</jbpm-configuration>
Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/jbpm.hibernate.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/jbpm.hibernate.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/jbpm.hibernate.cfg.xml 2009-12-11 12:38:22 UTC (rev 5951)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory>
+
+ <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+ <property name="hibernate.format_sql">true</property>
+
+ <property name="hibernate.hbm2ddl.auto">create-drop</property>
+
+ <mapping resource="jbpm.repository.hbm.xml" />
+ <mapping resource="jbpm.execution.hbm.xml" />
+ <mapping resource="jbpm.history.hbm.xml" />
+ <mapping resource="jbpm.task.hbm.xml" />
+ <mapping resource="jbpm.identity.hbm.xml" />
+
+ </session-factory>
+</hibernate-configuration>
Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/log4j.properties
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/log4j.properties (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/log4j.properties 2009-12-11 12:38:22 UTC (rev 5951)
@@ -0,0 +1,4 @@
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
+log4j.rootLogger=info, stdout
\ No newline at end of file
Added: jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/process.jpdl.xml (rev 0)
+++ jbpm4/trunk/modules/test-cfg/src/test/resources/org/jbpm/test/spring/transactionmanager/process.jpdl.xml 2009-12-11 12:38:22 UTC (rev 5951)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<process name='simpleProcess'>
+ <start>
+ <transition to='a' />
+ </start>
+ <state name='a'>
+ <transition to='b' />
+ </state>
+ <state name='b'>
+ <transition to='c' />
+ </state>
+ <end name='c' />
+</process>
\ No newline at end of file
16 years, 4 months
JBoss JBPM SVN: r5950 - in jbpm4/trunk/modules: devguide/src/main/docbook/en/modules and 1 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-12-11 05:55:27 -0500 (Fri, 11 Dec 2009)
New Revision: 5950
Removed:
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rules/process.png
Modified:
jbpm4/trunk/modules/api/src/main/resources/jpdl-4.3.xsd
jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml
jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rules/process.jpdl.xml
Log:
JBPM-2006 rules activity docs and xsd
Modified: jbpm4/trunk/modules/api/src/main/resources/jpdl-4.3.xsd
===================================================================
--- jbpm4/trunk/modules/api/src/main/resources/jpdl-4.3.xsd 2009-12-11 09:57:40 UTC (rev 5949)
+++ jbpm4/trunk/modules/api/src/main/resources/jpdl-4.3.xsd 2009-12-11 10:55:27 UTC (rev 5950)
@@ -203,7 +203,6 @@
</extension>
</complexContent>
</complexType>
- <!-- TODO add conditions -->
</element>
</sequence>
<attributeGroup ref="tns:activityAttributes" />
@@ -479,7 +478,7 @@
</complexType>
</element>
- <!-- ~~~ group ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+ <!-- ~~~ GROUP ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<element name="group">
<annotation><documentation>Scope enclosing a number of activities.
</documentation></annotation>
@@ -496,6 +495,69 @@
<attributeGroup ref="tns:activityAttributes" />
</complexType>
</element>
+
+ <!-- ~~~ RULES DECISION ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+ <element name="rules-decision">
+ <annotation><documentation>Selects one outgoing transition based on evaluation of rules.
+ </documentation></annotation>
+ <complexType>
+ <sequence>
+ <element name="description" minOccurs="0" type="string" />
+ <element ref="tns:transition" minOccurs="0" maxOccurs="unbounded" />
+ <element ref="tns:on" minOccurs="0" maxOccurs="unbounded">
+ <annotation><documentation>Events on which listeners can be registered.</documentation></annotation>
+ </element>
+ </sequence>
+ <attributeGroup ref="tns:activityAttributes" />
+ </complexType>
+ </element>
+
+ <!-- ~~~ RULES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
+ <element name="rules">
+ <annotation><documentation>Evaluates rules after feeding in some facts in a stateful knowledge session.
+ </documentation></annotation>
+ <complexType>
+ <sequence>
+ <element name="description" minOccurs="0" type="string" />
+ <element name="fact" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <attribute name="var" type="string" />
+ <attribute name="expr" type="string" />
+ </complexType>
+ </element>
+ <element name="transition" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <complexContent>
+ <extension base="tns:transitionType">
+ <sequence>
+ <element name="condition" minOccurs="0" maxOccurs="unbounded">
+ <complexType>
+ <sequence>
+ <element name="handler" minOccurs="0" type="tns:wireObjectType" />
+ </sequence>
+ <attribute name="expr" type="string">
+ <annotation><documentation>The script text that will be evaluated.
+ </documentation></annotation>
+ </attribute>
+ <attribute name="lang" type="string">
+ <annotation><documentation>Identification of the scripting language
+ to use.</documentation></annotation>
+ </attribute>
+ </complexType>
+ </element>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+ </element>
+ <element ref="tns:on" minOccurs="0" maxOccurs="unbounded">
+ <annotation><documentation>Events on which listeners can be registered.</documentation></annotation>
+ </element>
+ </sequence>
+ <attributeGroup ref="tns:activityAttributes" />
+ </complexType>
+ </element>
+
</choice>
</group>
Modified: jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml
===================================================================
--- jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml 2009-12-11 09:57:40 UTC (rev 5949)
+++ jbpm4/trunk/modules/devguide/src/main/docbook/en/modules/ch02-Incubation.xml 2009-12-11 10:55:27 UTC (rev 5950)
@@ -645,6 +645,10 @@
</para>
<para>Let's look at the next example how that works in practice. We'll start
with the <literal>RulesDecision</literal> process</para>
+ <figure id="process.rules.decision">
+ <title>The rules decision example process</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.rules.decision.png"/></imageobject></mediaobject>
+ </figure>
<programlisting><process name="RulesDecision">
<start>
@@ -719,7 +723,134 @@
<literal>13 Tempranillo</literal>s will go to
activity <literal>analyseManually</literal> </para>
</section>
+
+ <!-- ### RULES ####################################################### -->
+ <section id="rules">
+ <title><literal>rules</literal> activity</title>
+ <para>A <literal>rules</literal> is an automatic activity that will
+ create a stateful knowledge session, feed a number of facts in it and
+ fire all rules. The idea is that the rules will update or create
+ process variables that will be used later in the process. Facts
+ can be specified as sub elements of the rules activity.
+ </para>
+ <table><title><literal>rules</literal> elements:</title>
+ <tgroup cols="3" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Element</entry>
+ <entry>Multiplicity</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><literal>fact</literal></entry>
+ <entry>0..*</entry>
+ <entry>A fact that will be fed into the stateful rule session.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table><title><literal>fact</literal> attributes:</title>
+ <tgroup cols="5" rowsep="1" colsep="1">
+ <thead>
+ <row>
+ <entry>Attribute</entry>
+ <entry>Type</entry>
+ <entry>Default</entry>
+ <entry>Required?</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>var</entry>
+ <entry>variable name</entry>
+ <entry></entry>
+ <entry>either <literal>var</literal> or <literal>expr</literal> is required</entry>
+ <entry>the variable name for which the value should be inserted as a fact.
+ </entry>
+ </row>
+ <row>
+ <entry>expr</entry>
+ <entry>expression</entry>
+ <entry></entry>
+ <entry>either <literal>var</literal> or <literal>expr</literal> is required</entry>
+ <entry>the expression for which the resulting value should be inserted as a fact.
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <para>If a rules activity has one outgoing transition, then that one is
+ taken automatically. But multiple outgoing transitions can be specified
+ with conditions on them, just like with the <literal>decision</literal> activity
+ when using the conditions.
+ </para>
+ <para>For example:</para>
+ <figure id="process.rules">
+ <title>The rules example process</title>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.rules.png"/></imageobject></mediaobject>
+ </figure>
+ <programlisting><process name="Rules">
+
+ <start>
+ <transition to="evaluateStatus"/>
+ </start>
+
+ <emphasis role="bold"><rules name="evaluateStatus">
+ <fact var="room" />
+ <transition to="checkForFires"/>
+ </rules></emphasis>
+
+ <decision name="checkForFires">
+ <transition to="getFireExtinguisher">
+ <condition expr="#{room.onFire}" />
+ </transition>
+ <transition to="goToPub"/>
+ </decision>
+
+ <state name="getFireExtinguisher"/>
+ <state name="goToPub"/>
+
+</process></programlisting>
+ <para>The process first checks with rules if the room is on fire.
+ The Room class looks like this:</para>
+ <programlisting>public class Room implements Serializable {
+
+ int temperature = 21;
+ boolean smoke = false;
+ boolean isOnFire = false;
+ public Room(int temperature, boolean smoke) {
+ this.temperature = temperature;
+ this.smoke = smoke;
+ }
+
+ ...getters and setters...
+}</programlisting>
+ <para>Following rules are deployed in the same business archive:</para>
+ <programlisting>rule "CheckRoomOnFire"
+ when
+ room : org.jbpm.examples.rules.Room( temperature > 30, smoke == true )
+ then
+ room.setOnFire( true );
+end</programlisting>
+ <para>So when a new <literal>Rules</literal> process instance is started
+ like this:</para>
+ <programlisting>Map<String, Object> variables = new HashMap<String, Object>();
+variables.put("room", new Room(350, true));
+
+ProcessInstance processInstance =
+ executionService.startProcessInstanceByKey("Rules", variables);</programlisting>
+ <para>Then the process will end up in the activity <literal>getFireExtinguisher</literal>
+ </para>
+ <para>And when the process is started with a Room(21, false), it will end up in the
+ activity <literal>goToPub</literal>
+ </para>
+ </section>
+
<section>
<title>Creating identity groups</title>
<para>The identity service methods to create groups are based on
Modified: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rules/process.jpdl.xml
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rules/process.jpdl.xml 2009-12-11 09:57:40 UTC (rev 5949)
+++ jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rules/process.jpdl.xml 2009-12-11 10:55:27 UTC (rev 5950)
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
-<process name="Rules" xmlns="http://jbpm.org/4/jpdl">
+<process name="Rules" xmlns="http://jbpm.org/4.3/jpdl">
<start g="49,93,80,40">
<transition to="evaluateStatus"/>
</start>
<rules name="evaluateStatus">
- <fact var="room" />
- <transition to="checkForFires"/>
+ <fact var="room" />
+ <transition to="checkForFires" />
</rules>
<decision g="215,93,80,40" name="checkForFires">
Deleted: jbpm4/trunk/modules/test-db/src/test/resources/org/jbpm/examples/rules/process.png
===================================================================
(Binary files differ)
16 years, 4 months
JBoss JBPM SVN: r5949 - 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-11 04:57:40 -0500 (Fri, 11 Dec 2009)
New Revision: 5949
Added:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/SerializedVariableUpdateTest.java
Removed:
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/SerializedVariableUpdate.java
Modified:
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/serializablevariable/UpdateSerializedVariables.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/DeserializedObjects.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch07-Variables.xml
Log:
JBPM-2684 automatic saving of updates to serializable variables
Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/serializablevariable/UpdateSerializedVariables.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/serializablevariable/UpdateSerializedVariables.java 2009-12-11 09:29:37 UTC (rev 5948)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/serializablevariable/UpdateSerializedVariables.java 2009-12-11 09:57:40 UTC (rev 5949)
@@ -21,13 +21,11 @@
*/
package org.jbpm.examples.serializablevariable;
-import java.util.List;
import java.util.Set;
import org.jbpm.api.activity.ActivityBehaviour;
import org.jbpm.api.activity.ActivityExecution;
-
/**
* @author Tom Baeyens
*/
@@ -42,5 +40,4 @@
messages.add("was");
messages.add("updated");
}
-
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/DeserializedObjects.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/DeserializedObjects.java 2009-12-11 09:29:37 UTC (rev 5948)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/tx/DeserializedObjects.java 2009-12-11 09:57:40 UTC (rev 5949)
@@ -23,10 +23,13 @@
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
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;
/**
@@ -35,6 +38,8 @@
public class DeserializedObjects implements Serializable {
private static final long serialVersionUID = 1L;
+
+ private static final SerializableToBytesConverter serializableToBytesConverter = new SerializableToBytesConverter();
protected List<Object[]> deserializedObjects = new ArrayList<Object[]>();
@@ -50,15 +55,24 @@
for (Object[] triple: copy) {
Object deserializedObject = triple[0];
ScopeInstanceImpl scopeInstance = (ScopeInstanceImpl) triple[1];
- Variable variable = (Variable) triple[2];
+ BlobVariable blobVariable = (BlobVariable) triple[2];
+
+ String variableName = blobVariable.getKey();
+ Object currentValue = scopeInstance.getVariable(variableName);
- String variableName = variable.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)
) {
- variable.setValue(deserializedObject, scopeInstance);
+ // 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);
+ }
}
}
}
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-11 09:29:37 UTC (rev 5948)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/type/converter/SerializableToBytesConverter.java 2009-12-11 09:57:40 UTC (rev 5949)
@@ -32,7 +32,6 @@
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.env.Transaction;
import org.jbpm.pvm.internal.model.ScopeInstanceImpl;
-import org.jbpm.pvm.internal.session.DbSession;
import org.jbpm.pvm.internal.type.Converter;
import org.jbpm.pvm.internal.type.Variable;
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/SerializedVariableUpdate.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/SerializedVariableUpdate.java 2009-12-11 09:29:37 UTC (rev 5948)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/SerializedVariableUpdate.java 2009-12-11 09:57:40 UTC (rev 5949)
@@ -1,97 +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.test.variables;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.jbpm.api.ProcessInstance;
-import org.jbpm.api.activity.ActivityBehaviour;
-import org.jbpm.api.activity.ActivityExecution;
-import org.jbpm.test.JbpmTestCase;
-import org.jbpm.test.activity.custom.CustomConfigurationsTest.MyCustomAutomatic;
-
-
-/**
- * @author Tom Baeyens
- */
-public class SerializedVariableUpdate extends JbpmTestCase {
-
- public static class UpdateAndReplace implements ActivityBehaviour {
-
- private static final long serialVersionUID = 1L;
-
- public void execute(ActivityExecution execution) throws Exception {
- Set<String> messages = (Set<String>) execution.getVariable("messages");
- messages.clear();
- messages.add("i");
- messages.add("was");
- messages.add("updated");
-
- Set<String> newMessagesObject = new HashSet<String>();
- newMessagesObject.add("completely");
- newMessagesObject.add("new");
- newMessagesObject.add("object");
- execution.setVariable("messages", newMessagesObject);
- }
-
- }
-
- public void testSerializableVariableUpdate() {
- deployJpdlXmlString(
- "<process name='SerializedVariableUpdate'>" +
- " <start>" +
- " <transition to='wait before' />" +
- " </start>" +
- " <state name='wait before'>" +
- " <transition to='update' />" +
- " </state>" +
- " <custom name='update' class='"+UpdateAndReplace.class.getName()+"'>" +
- " <transition to='wait after' />" +
- " </custom>" +
- " <state name='wait after'/>" +
- "</process>"
- );
-
- Set<String> messages = new HashSet<String>();
- messages.add("serialize");
- messages.add("me");
-
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("messages", messages);
-
- ProcessInstance processInstance = executionService.startProcessInstanceByKey("SerializedVariableUpdate", variables);
- String pid = processInstance.getId();
- executionService.signalExecutionById(pid);
-
- Set<String> expectedMessages = new HashSet<String>();
- expectedMessages.add("completely");
- expectedMessages.add("new");
- expectedMessages.add("object");
-
- messages = (Set<String>) executionService.getVariable(pid, "messages");
- assertEquals(expectedMessages, messages);
- }
-
-}
Copied: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/SerializedVariableUpdateTest.java (from rev 5944, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/SerializedVariableUpdate.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/SerializedVariableUpdateTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/SerializedVariableUpdateTest.java 2009-12-11 09:57:40 UTC (rev 5949)
@@ -0,0 +1,144 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.variables;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.activity.ActivityBehaviour;
+import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class SerializedVariableUpdateTest extends JbpmTestCase {
+
+ public static class UpdateAndReplace implements ActivityBehaviour {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ActivityExecution execution) throws Exception {
+ Set<String> messages = (Set<String>) execution.getVariable("messages");
+ messages.clear();
+ messages.add("i");
+ messages.add("was");
+ messages.add("updated");
+
+ Set<String> newMessagesObject = new HashSet<String>();
+ newMessagesObject.add("completely");
+ newMessagesObject.add("new");
+ newMessagesObject.add("object");
+ execution.setVariable("messages", newMessagesObject);
+ }
+
+ }
+
+ public void testSerializableVariableUpdate() {
+ deployJpdlXmlString(
+ "<process name='SerializedVariableUpdate'>" +
+ " <start>" +
+ " <transition to='wait before' />" +
+ " </start>" +
+ " <state name='wait before'>" +
+ " <transition to='update' />" +
+ " </state>" +
+ " <custom name='update' class='"+UpdateAndReplace.class.getName()+"'>" +
+ " <transition to='wait after' />" +
+ " </custom>" +
+ " <state name='wait after'/>" +
+ "</process>"
+ );
+
+ Set<String> messages = new HashSet<String>();
+ messages.add("serialize");
+ messages.add("me");
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("messages", messages);
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("SerializedVariableUpdate", variables);
+ String pid = processInstance.getId();
+ executionService.signalExecutionById(pid);
+
+ Set<String> expectedMessages = new HashSet<String>();
+ expectedMessages.add("completely");
+ expectedMessages.add("new");
+ expectedMessages.add("object");
+
+ messages = (Set<String>) executionService.getVariable(pid, "messages");
+ assertEquals(expectedMessages, messages);
+ }
+
+
+ public static class ReadOnly implements ActivityBehaviour {
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ActivityExecution execution) throws Exception {
+ execution.getVariable("messages");
+ execution.getVariable("messages");
+ }
+ }
+
+ public void testReadOnly() {
+ deployJpdlXmlString(
+ "<process name='SerializedVariableUpdate'>" +
+ " <start>" +
+ " <transition to='wait before' />" +
+ " </start>" +
+ " <state name='wait before'>" +
+ " <transition to='update' />" +
+ " </state>" +
+ " <custom name='update' class='"+ReadOnly.class.getName()+"'>" +
+ " <transition to='wait after' />" +
+ " </custom>" +
+ " <state name='wait after'/>" +
+ "</process>"
+ );
+
+ Set<String> messages = new HashSet<String>();
+ messages.add("serialize");
+ messages.add("me");
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("messages", messages);
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("SerializedVariableUpdate", variables);
+ String pid = processInstance.getId();
+ executionService.signalExecutionById(pid);
+
+ Set<String> expectedMessages = new HashSet<String>();
+ expectedMessages.add("serialize");
+ expectedMessages.add("me");
+
+ messages = (Set<String>) executionService.getVariable(pid, "messages");
+ assertEquals(expectedMessages, messages);
+
+ // TODO find some way to assert that NO variable update is issued to the history service
+ // for now, i just did that check once manually in the debugger :-) 11/12/2009
+ }
+
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/variables/SerializedVariableUpdateTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch07-Variables.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch07-Variables.xml 2009-12-11 09:29:37 UTC (rev 5948)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch07-Variables.xml 2009-12-11 09:57:40 UTC (rev 5949)
@@ -79,5 +79,39 @@
the variable is stored.
</para>
</section>
+
+ <section>
+ <title>Updating serialized process variables</title>
+ <para>(Since jBPM 4.3)</para>
+ <para>In <literal>custom</literal>s, <literal>event-handler</literal>s and other
+ user code, you can retrieve process variables. In case a process variable
+ is stored as a serialized object, you can just make updates to your deserialized
+ objects without the need for an explicit save. jBPM will manage deserialized process
+ variables and update them automatically if you change. For example (@see examples package
+ org.jbpm.examples.serializedobject), look at this piece of user code inside a <literal>custom</literal>'s activity behaviour:
+ </para>
+ <programlisting>public class UpdateSerializedVariables implements ActivityBehaviour {
+
+ public void execute(ActivityExecution execution) {
+ Set<String> messages = (Set<String>) execution.getVariable("messages");
+ messages.clear();
+ messages.add("i");
+ messages.add("was");
+ messages.add("updated");
+ }
+}</programlisting>
+ <para>When the transaction commits in which this usercode was called, the
+ updated messages set will be updated in the database automatically.
+ </para>
+ <para>When reading process variables that are stored in serialized format from the DB
+ jBPM will monitor that deserialized object. Right before the commit of the transaction,
+ jBPM will serialize and update the variable automatically if that is necessary. jBPM
+ will ignore updates to the deserialized object if another object was set as the value
+ in that scope (which even can be of another type). jBPM will also skip updating of the
+ variable if the deserialized object has not been changed. The check to see if the
+ object has changed is based on comparing the byte arrays from serializing the object
+ again and comparing that with the byte array that was originally loaded from the db.
+ </para>
+ </section>
</chapter>
16 years, 4 months
JBoss JBPM SVN: r5948 - jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-12-11 04:29:37 -0500 (Fri, 11 Dec 2009)
New Revision: 5948
Modified:
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ProcessEngineImpl.java
Log:
JBPM-2657: Instead of going to wireContext, the services are retrieved through the get(Class) method. This way, Spring users can enhance the services and declare them in their applicationContext.xml
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ProcessEngineImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ProcessEngineImpl.java 2009-12-11 09:10:40 UTC (rev 5947)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/ProcessEngineImpl.java 2009-12-11 09:29:37 UTC (rev 5948)
@@ -228,22 +228,22 @@
}
public ExecutionService getExecutionService() {
- return processEngineWireContext.get(ExecutionService.class);
+ return get(ExecutionService.class);
}
public HistoryService getHistoryService() {
- return processEngineWireContext.get(HistoryService.class);
+ return get(HistoryService.class);
}
public ManagementService getManagementService() {
- return processEngineWireContext.get(ManagementService.class);
+ return get(ManagementService.class);
}
public TaskService getTaskService() {
- return processEngineWireContext.get(TaskService.class);
+ return get(TaskService.class);
}
public IdentityService getIdentityService() {
- return processEngineWireContext.get(IdentityService.class);
+ return get(IdentityService.class);
}
public RepositoryService getRepositoryService() {
- return processEngineWireContext.get(RepositoryService.class);
+ return get(RepositoryService.class);
}
public EnvironmentImpl openEnvironment() {
16 years, 4 months
JBoss JBPM SVN: r5947 - jbpm4/trunk/modules/test-db.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-12-11 04:10:40 -0500 (Fri, 11 Dec 2009)
New Revision: 5947
Modified:
jbpm4/trunk/modules/test-db/pom.xml
Log:
Initial commit for JBPM-2631: hudson job for spring. Added profile to test-db to execute tests with Spring.
Modified: jbpm4/trunk/modules/test-db/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-db/pom.xml 2009-12-11 09:08:28 UTC (rev 5946)
+++ jbpm4/trunk/modules/test-db/pom.xml 2009-12-11 09:10:40 UTC (rev 5947)
@@ -99,10 +99,12 @@
</executions>
</plugin>
- <!-- <exclude>org/jbpm/bpmn/flownodes/ExclusiveGatewayTest.java</exclude>
- <exclude>org/jbpm/bpmn/flownodes/ScriptTaskTest.java</exclude>
- <exclude>org/jbpm/bpmn/flownodes/UserTaskTest.java</exclude>
- -->
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkMode>never</forkMode> <!-- Without this setting, mvn 2.1.0 doesn't copy command line properties sometimes -->
+ </configuration>
+ </plugin>
</plugins>
</build>
@@ -155,6 +157,55 @@
</plugins>
</build>
</profile>
+
+ <!-- Note: Spring profile cannot be used together with 'database'
+ property currently (see http://jira.codehaus.org/browse/MNG-3328) -->
+ <profile>
+ <id>run.spring.testsuite</id>
+ <activation>
+ <property>
+ <name>jbpm.test.cfg.type</name>
+ <value>spring-test</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>spring-test-cfg-customization</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <echo message="config ${config}" />
+ <mkdir dir="target/jdbc.properties" />
+ <copy todir="target/jdbc.properties" overwrite="true">
+ <fileset dir="../../qa/jdbc" />
+ </copy>
+ <copy todir="target/jdbc.properties" overwrite="true" failonerror="false">
+ <fileset dir="${user.home}/.jbpm4/jdbc" />
+ </copy>
+ <ant antfile="../distro/src/main/files/install/build.xml" target="create.cfg">
+ <property name="tx" value="spring.testsuite" />
+ <property name="mail.cfg" value="testsuite" />
+ <property name="database" value="hsqldb" /> <!-- Spring config is tested against hsqldb only -->
+ <property name="cfg.dest.dir" value="target/test-classes" />
+ <property name="install.src.dir" value="../distro/src/main/files/install/src" />
+ <property name="jdbc.properties.dir" value="target/jdbc.properties" />
+ <property name="logging" value="none" />
+ </ant>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
</profiles>
16 years, 4 months
JBoss JBPM SVN: r5946 - in jbpm4/trunk/modules: pvm/src/main/java/org/jbpm/pvm/internal/cfg and 1 other directories.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-12-11 04:08:28 -0500 (Fri, 11 Dec 2009)
New Revision: 5946
Modified:
jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/jbpm/spring.testsuite.jbpm.cfg.xml
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/SpringConfiguration.java
jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.spring.cfg.xml
Log:
JBPM-2645: can't instantiate process engine when using Spring
Modified: jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/jbpm/spring.testsuite.jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/jbpm/spring.testsuite.jbpm.cfg.xml 2009-12-11 09:04:40 UTC (rev 5945)
+++ jbpm4/trunk/modules/distro/src/main/files/install/src/cfg/jbpm/spring.testsuite.jbpm.cfg.xml 2009-12-11 09:08:28 UTC (rev 5946)
@@ -9,6 +9,5 @@
<import resource="jbpm.identity.cfg.xml" />
<import resource="jbpm.businesscalendar.cfg.xml" />
<import resource="jbpm.console.cfg.xml" />
- <import resource="jbpm.mail.templates.examples.xml" />
</jbpm-configuration>
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/SpringConfiguration.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/SpringConfiguration.java 2009-12-11 09:04:40 UTC (rev 5945)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/cfg/SpringConfiguration.java 2009-12-11 09:08:28 UTC (rev 5946)
@@ -22,18 +22,13 @@
package org.jbpm.pvm.internal.cfg;
import java.io.IOException;
-import java.util.List;
import org.jbpm.api.ProcessEngine;
import org.jbpm.internal.log.Log;
-import org.jbpm.pvm.internal.env.Context;
+import org.jbpm.pvm.internal.env.EnvironmentFactory;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
-import org.jbpm.pvm.internal.env.EnvironmentFactory;
import org.jbpm.pvm.internal.env.PvmEnvironment;
import org.jbpm.pvm.internal.env.SpringContext;
-import org.jbpm.pvm.internal.env.UserProvidedEnvironmentObject;
-import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.wire.WireDefinition;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -76,6 +71,14 @@
public ProcessEngine buildProcessEngine() {
if (applicationContext == null) {
applicationContext = new ClassPathXmlApplicationContext(System.getProperty("jbpm.test.cfg.applicationContext"));
+
+ // If the property hasn't been set, fall back to the default applicationContext
+ if (applicationContext == null) {
+ if (log.isInfoEnabled()) {
+ log.info("Looking for applicationContext.xml on classpath ...");
+ }
+ applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
+ }
}
return super.buildProcessEngine();
Modified: jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.spring.cfg.xml
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.spring.cfg.xml 2009-12-11 09:04:40 UTC (rev 5945)
+++ jbpm4/trunk/modules/pvm/src/main/resources/jbpm.tx.spring.cfg.xml 2009-12-11 09:08:28 UTC (rev 5946)
@@ -3,11 +3,20 @@
<jbpm-configuration>
<process-engine-context>
- <command-service>
+
+ <command-service name="newTxRequiredCommandService">
<retry-interceptor />
+ <environment-interceptor policy="requiresNew" />
+ <standard-transaction-interceptor />
+ </command-service>
+
+ <!-- Default command service has a Spring transaction interceptor-->
+ <command-service name="txRequiredCommandService">
+ <retry-interceptor />
<environment-interceptor />
<spring-transaction-interceptor />
</command-service>
+
</process-engine-context>
<transaction-context>
16 years, 4 months
JBoss JBPM SVN: r5945 - jbpm4/trunk/modules/distro/src/main/files/install.
by do-not-reply@jboss.org
Author: jbarrez
Date: 2009-12-11 04:04:40 -0500 (Fri, 11 Dec 2009)
New Revision: 5945
Modified:
jbpm4/trunk/modules/distro/src/main/files/install/build.xml
Log:
Added generation of applicationContext to the create.cfg target when executed with tx=spring/spring.testsuite
Modified: jbpm4/trunk/modules/distro/src/main/files/install/build.xml
===================================================================
--- jbpm4/trunk/modules/distro/src/main/files/install/build.xml 2009-12-11 05:54:52 UTC (rev 5944)
+++ jbpm4/trunk/modules/distro/src/main/files/install/build.xml 2009-12-11 09:04:40 UTC (rev 5945)
@@ -186,7 +186,21 @@
<filter token="mail.smtp.host" value="${mail.smtp.host}" />
</filterset>
</copy>
+
+ <!-- If the target environment uses Spring, also copy the applicationContext.xml file-->
+ <condition property="is.spring.environment">
+ <or>
+ <equals arg1="${tx}" arg2="spring" />
+ <equals arg1="${tx}" arg2="spring.testsuite" />
+ </or>
+ </condition>
+ <antcall target="internal.copy.spring.applicationContext" />
+
</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" />
+ </target>
<!-- ### CREATE USER WEBAPP ########################################## -->
<target name="create.user.webapp"
16 years, 4 months