JBoss JBPM SVN: r3394 - in jbpm3/trunk/modules/core/src: test/java/org/jbpm/context/exe and 1 other directory.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2008-12-15 17:18:00 -0500 (Mon, 15 Dec 2008)
New Revision: 3394
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomSessionFactoryFactory.java
Log:
fully reverted HibernateHelper, changed the only invocation to HibernateHelper that enabled configuration caching
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java 2008-12-15 21:35:11 UTC (rev 3393)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java 2008-12-15 22:18:00 UTC (rev 3394)
@@ -42,24 +42,24 @@
// prevent instantiation
}
- /** maps SessionFactory's to Configurations. */
- /** by default, configuration lookup will be enabled */
+ /** maps SessionFactory's to Configurations.
+ * by default, configuration lookup will be enabled */
static Map configurations = new HashMap();
public static void clearConfigurationsCache() {
- configurations = new HashMap();
+ configurations.clear();
}
public static SessionFactory createSessionFactory() {
- return createSessionFactory(null, null, false);
+ return createSessionFactory(null, null, true);
}
public static SessionFactory createSessionFactory(String cfgXmlResource) {
- return createSessionFactory(cfgXmlResource, null, false);
+ return createSessionFactory(cfgXmlResource, null, true);
}
public static SessionFactory createSessionFactory(String cfgXmlResource, String propertiesResource) {
- return createSessionFactory(cfgXmlResource, propertiesResource, false);
+ return createSessionFactory(cfgXmlResource, propertiesResource, true);
}
public static SessionFactory createSessionFactory(String cfgXmlResource,
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomSessionFactoryFactory.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomSessionFactoryFactory.java 2008-12-15 21:35:11 UTC (rev 3393)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/context/exe/CustomSessionFactoryFactory.java 2008-12-15 22:18:00 UTC (rev 3394)
@@ -34,6 +34,6 @@
Configuration configuration = HibernateHelper.createConfiguration(null, null);
Class clazz = ClassLoaderUtil.loadClass(extraClassMapping);
configuration.addClass(clazz);
- return HibernateHelper.createSessionFactory(configuration, true);
+ return HibernateHelper.createSessionFactory(configuration, false);
}
}
17 years, 4 months
JBoss JBPM SVN: r3393 - jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/hibernate.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2008-12-15 16:35:11 -0500 (Mon, 15 Dec 2008)
New Revision: 3393
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java
Log:
reverted incompatible changes to HibernateHelper
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java 2008-12-15 16:00:47 UTC (rev 3392)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java 2008-12-15 21:35:11 UTC (rev 3393)
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
@@ -32,6 +33,7 @@
import org.apache.commons.logging.LogFactory;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
+import org.hibernate.tool.hbm2ddl.SchemaExport;
import org.jbpm.util.ClassLoaderUtil;
public class HibernateHelper {
@@ -40,47 +42,58 @@
// prevent instantiation
}
+ /** maps SessionFactory's to Configurations. */
+ /** by default, configuration lookup will be enabled */
+ static Map configurations = new HashMap();
+
+ public static void clearConfigurationsCache() {
+ configurations = new HashMap();
+ }
+
public static SessionFactory createSessionFactory() {
- return createSessionFactory(null, null, true);
+ return createSessionFactory(null, null, false);
}
public static SessionFactory createSessionFactory(String cfgXmlResource) {
- return createSessionFactory(cfgXmlResource, null, true);
+ return createSessionFactory(cfgXmlResource, null, false);
}
public static SessionFactory createSessionFactory(String cfgXmlResource, String propertiesResource) {
- return createSessionFactory(cfgXmlResource, propertiesResource, true);
+ return createSessionFactory(cfgXmlResource, propertiesResource, false);
}
- public static SessionFactory createSessionFactory(String cfgXmlResource, String propertiesResource, boolean isConfigLookupEnabled) {
+ public static SessionFactory createSessionFactory(String cfgXmlResource,
+ String propertiesResource, boolean isConfigLookupEnabled) {
Configuration configuration = createConfiguration(cfgXmlResource, propertiesResource);
return createSessionFactory(configuration, isConfigLookupEnabled);
}
- public static SessionFactory createSessionFactory(Configuration configuration, boolean isConfigLookupEnabled) {
- return configuration.buildSessionFactory();
+ public static SessionFactory createSessionFactory(Configuration configuration,
+ boolean isConfigLookupEnabled) {
+ SessionFactory sessionFactory = configuration.buildSessionFactory();
+ if (isConfigLookupEnabled) {
+ configurations.put(sessionFactory, configuration);
+ }
+ return sessionFactory;
}
public static Configuration createConfiguration(String cfgXmlResource, String propertiesResource) {
Configuration configuration = new Configuration();
-
- // if a special hibernate configuration xml file is specified,
- if (cfgXmlResource != null)
- {
+
+ // if a special hibernate configuration xml file is specified,
+ if (cfgXmlResource != null) {
// use the configured file name
URL cfgURL = Thread.currentThread().getContextClassLoader().getResource(cfgXmlResource);
log.debug("creating hibernate configuration resource '" + cfgURL + "'");
configuration.configure(cfgXmlResource);
- }
- else
- {
+ } else {
log.debug("using default hibernate configuration resource (hibernate.cfg.xml)");
configuration.configure();
}
-
+
// if the properties are specified in a separate file
- if (propertiesResource!=null) {
- log.debug("using hibernate properties from resource '"+propertiesResource+"'");
+ if (propertiesResource != null) {
+ log.debug("using hibernate properties from resource '" + propertiesResource + "'");
// load the properties
Properties properties = loadPropertiesFromResource(propertiesResource);
if (!properties.isEmpty()) {
@@ -92,16 +105,33 @@
return configuration;
}
+ public static Configuration getConfiguration(SessionFactory sessionFactory) {
+ return (Configuration) configurations.get(sessionFactory);
+ }
+
+ public static SchemaExport createSchemaExport(SessionFactory sessionFactory) {
+ return new SchemaExport(getConfiguration(sessionFactory));
+ }
+
+ public static boolean createSchemaExportScript(SessionFactory sessionFactory) {
+ boolean script = false;
+ String showSql = getConfiguration(sessionFactory).getProperty("hibernate.show_sql");
+ if ("true".equalsIgnoreCase(showSql)) {
+ script = true;
+ }
+ return script;
+ }
+
public static void clearHibernateCache(SessionFactory sessionFactory) {
sessionFactory.evictQueries();
-
+
Map classMetadata = sessionFactory.getAllClassMetadata();
Iterator iter = classMetadata.keySet().iterator();
while (iter.hasNext()) {
String entityName = (String) iter.next();
sessionFactory.evictEntity(entityName);
}
-
+
Map collectionMetadata = sessionFactory.getAllCollectionMetadata();
iter = collectionMetadata.keySet().iterator();
while (iter.hasNext()) {
@@ -117,7 +147,7 @@
try {
properties.load(inputStream);
} catch (IOException e) {
- log.warn("couldn't load hibernate properties from resource '"+resource+"'", e);
+ log.warn("couldn't load hibernate properties from resource '" + resource + "'", e);
}
} else {
log.warn("hibernate properties resource '" + resource + "' not found");
17 years, 4 months
JBoss JBPM SVN: r3392 - jbpm3/trunk/modules/core/src/main/java/org/jbpm/command.
by do-not-reply@jboss.org
Author: camunda
Date: 2008-12-15 11:00:47 -0500 (Mon, 15 Dec 2008)
New Revision: 3392
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/AbstractCancelCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/CancelProcessInstanceCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/CancelTokenCommand.java
Log:
JBPM-1904/JBPM-1905
- Added cancel indicator variable to CancelTokenCommand as well
- Added correct toString to AbstractCancelCommand
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/AbstractCancelCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/AbstractCancelCommand.java 2008-12-15 13:45:46 UTC (rev 3391)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/AbstractCancelCommand.java 2008-12-15 16:00:47 UTC (rev 3392)
@@ -1,6 +1,5 @@
package org.jbpm.command;
-import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@@ -12,11 +11,18 @@
import org.jbpm.graph.exe.Token;
import org.jbpm.taskmgmt.exe.TaskInstance;
-public class AbstractCancelCommand implements Serializable
+public abstract class AbstractCancelCommand extends AbstractBaseCommand
{
private static final long serialVersionUID = 1L;
+ /**
+ * Name of a standardized process variable which is written during cancellation
+ * in order to indicate that this process has been 'canceled' and not just ended.
+ * Value of the variable is the timestamp of cancellation.
+ */
+ public static String CANCELLATION_INDICATOR_VARIABLE_NAME = "canceled";
+
protected transient JbpmContext jbpmContext = null;
protected static final Log log = LogFactory.getLog(AbstractCancelCommand.class);
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/CancelProcessInstanceCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/CancelProcessInstanceCommand.java 2008-12-15 13:45:46 UTC (rev 3391)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/CancelProcessInstanceCommand.java 2008-12-15 16:00:47 UTC (rev 3392)
@@ -5,19 +5,20 @@
import org.jbpm.JbpmContext;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
+import org.jbpm.util.Clock;
/**
- * Cancel the given {@link ProcessInstance} with all {@link Token}s.
+ * Cancel the given {@link ProcessInstance} with all {@link Token}s.
*
* <b>Maybe running sub process instances are currently not canceled.</b>
*
* @author Bernd Ruecker (bernd.ruecker(a)camunda.com)
*/
-public class CancelProcessInstanceCommand extends AbstractCancelCommand implements Command
+public class CancelProcessInstanceCommand extends AbstractCancelCommand
{
private static final long serialVersionUID = 7145293049356621597L;
-
+
private long processInstanceId;
public CancelProcessInstanceCommand()
@@ -45,7 +46,7 @@
// Record a standardized variable that we can use to determine that this
// process has been 'canceled' and not just ended.
- pi.getContextInstance().createVariable("canceled", new Date());
+ pi.getContextInstance().createVariable(CANCELLATION_INDICATOR_VARIABLE_NAME, Clock.getCurrentTime());
try
{
@@ -91,6 +92,12 @@
this.processInstanceId = processId;
}
+ @Override
+ public String getAdditionalToStringInformation()
+ {
+ return "processInstanceId=" + processInstanceId;
+ }
+
// methods for fluent programming
public CancelProcessInstanceCommand processInstanceId(long processInstanceId)
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/CancelTokenCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/CancelTokenCommand.java 2008-12-15 13:45:46 UTC (rev 3391)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/CancelTokenCommand.java 2008-12-15 16:00:47 UTC (rev 3392)
@@ -2,13 +2,14 @@
import org.jbpm.JbpmContext;
import org.jbpm.graph.exe.Token;
+import org.jbpm.util.Clock;
/**
* Cancel a {@link Token}
*
* @author Bernd Ruecker (bernd.ruecker(a)camunda.com)
*/
-public class CancelTokenCommand extends AbstractCancelCommand implements Command
+public class CancelTokenCommand extends AbstractCancelCommand
{
private static final long serialVersionUID = 7145293049356621597L;
@@ -27,7 +28,13 @@
public Object execute(JbpmContext jbpmContext) throws Exception
{
this.jbpmContext = jbpmContext;
- cancelToken(jbpmContext.getGraphSession().loadToken(tokenId));
+ Token token = jbpmContext.getGraphSession().loadToken(tokenId);
+
+ // create a token local process variable to indicate this token was canceled
+ token.getProcessInstance().getContextInstance().createVariable(
+ CANCELLATION_INDICATOR_VARIABLE_NAME, Clock.getCurrentTime(), token);
+
+ cancelToken(token);
this.jbpmContext = null;
return null;
}
@@ -41,6 +48,12 @@
{
this.tokenId = tokenId;
}
+
+ @Override
+ public String getAdditionalToStringInformation()
+ {
+ return "tokenId=" + tokenId;
+ }
// methods for fluent programming
17 years, 4 months
JBoss JBPM SVN: r3391 - projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-12-15 08:45:46 -0500 (Mon, 15 Dec 2008)
New Revision: 3391
Modified:
projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server/ProcessManagementTest.java
Log:
Added signaling test
Modified: projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server/ProcessManagementTest.java
===================================================================
--- projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server/ProcessManagementTest.java 2008-12-15 12:21:18 UTC (rev 3390)
+++ projects/gwt-console/trunk/server/src/test/java/org/jboss/bpm/console/server/ProcessManagementTest.java 2008-12-15 13:45:46 UTC (rev 3391)
@@ -33,93 +33,96 @@
*/
public class ProcessManagementTest extends BaseTC
{
- /*
- * Checks the following requirements:<br>
- * <ul>
- * <li> Process deployment
- * <li> Create instance
- * <li> Suspend instance
- * <li> End an instance
- * </ul>
- */
- public void testProcessDefinitionList() throws Exception
- {
- String response = HTTP.get(SERVER_URL + "/process/definitions", DEFAULT_CREDENTIALS);
+ /*
+ * Checks the following requirements:<br>
+ * <ul>
+ * <li> Process deployment
+ * <li> Create instance
+ * <li> Suspend instance
+ * <li> End an instance
+ * </ul>
+ */
+ public void testProcessDefinitionList() throws Exception
+ {
+ String response = HTTP.get(SERVER_URL + "/process/definitions", DEFAULT_CREDENTIALS);
- ProcessDefinitionRefWrapper dto = unmarshallProcessDefinitionList(response);
+ ProcessDefinitionRefWrapper dto = unmarshallProcessDefinitionList(response);
- ProcessDefinitionRef match = null;
- for (ProcessDefinitionRef def : dto.getDefinitions())
- {
- if (def.equals(testDeploymentRef))
- match = def;
- }
+ ProcessDefinitionRef match = null;
+ for (ProcessDefinitionRef def : dto.getDefinitions())
+ {
+ if (def.equals(testDeploymentRef))
+ match = def;
+ }
- assertNotNull(match);
+ assertNotNull(match);
- }
+ }
- /*
- * Test instance creation, suspend, resume and deletion.
- */
- public void testInstanceOperations() throws Exception
- {
- ProcessInstanceRef newInstanceRef = createNewProcessInstance();
+ /*
+ * Test instance creation, suspend, resume and deletion.
+ */
+ public void testInstanceOperations() throws Exception
+ {
+ ProcessInstanceRef newInstanceRef = createNewProcessInstance();
- // ------- Suspend it
+ // ------- Suspend it
- newInstanceRef.setState(ProcessInstanceRef.STATE.SUSPENDED);
- HTTP.post(SERVER_URL + "/process/instances/" + newInstanceRef.getInstanceId() + "/state/" + newInstanceRef.getState(), EMPTY, DEFAULT_CREDENTIALS);
+ newInstanceRef.setState(ProcessInstanceRef.STATE.SUSPENDED);
+ HTTP.post(SERVER_URL + "/process/instances/" + newInstanceRef.getInstanceId() + "/state/" + newInstanceRef.getState(), EMPTY, DEFAULT_CREDENTIALS);
- // ------- Verify
+ // ------- Verify
- ProcessInstanceRefWrapper instanceList = getInstanceList(testDeploymentRef);
- assertFalse(instanceList.getInstances().isEmpty());
- assertTrue(instanceList.getTotalCount() == 1);
+ ProcessInstanceRefWrapper instanceList = getInstanceList(testDeploymentRef);
+ assertFalse(instanceList.getInstances().isEmpty());
+ assertTrue(instanceList.getTotalCount() == 1);
- ProcessInstanceRef match = null;
- for (ProcessInstanceRef ref : instanceList.getInstances())
+ ProcessInstanceRef match = null;
+ for (ProcessInstanceRef ref : instanceList.getInstances())
+ {
+ if (ref.equals(newInstanceRef))
{
- if (ref.equals(newInstanceRef))
- {
- match = ref;
- break;
- }
+ match = ref;
+ break;
}
+ }
- assertNotNull(match);
- assertEquals(ProcessInstanceRef.STATE.SUSPENDED, match.getState());
+ assertNotNull(match);
+ assertEquals(ProcessInstanceRef.STATE.SUSPENDED, match.getState());
- // end and verify
- newInstanceRef.setState(ProcessInstanceRef.STATE.ENDED);
- HTTP.post(SERVER_URL + "/process/instances/" + newInstanceRef.getInstanceId() + "/state/" + newInstanceRef.getState(), EMPTY, DEFAULT_CREDENTIALS);
+ // end and verify
+ newInstanceRef.setState(ProcessInstanceRef.STATE.ENDED);
+ HTTP.post(SERVER_URL + "/process/instances/" + newInstanceRef.getInstanceId() + "/state/" + newInstanceRef.getState(), EMPTY, DEFAULT_CREDENTIALS);
- // refresh instance list
- instanceList = getInstanceList(testDeploymentRef);
- assertTrue(instanceList.getInstances().isEmpty());
+ // refresh instance list
+ instanceList = getInstanceList(testDeploymentRef);
+ assertTrue(instanceList.getInstances().isEmpty());
- }
+ }
- public void testSignaling() throws Exception
- {
- /*
- // signal it to move to task node
- String url = "/jbpm3/tokens/"+newInstanceRef.getRootToken().getId()+"/transition/default";
- HTTP.post(
- SERVER_URL + url, EMPTY, DEFAULT_CREDENTIALS
- );
+ public void testSignaling() throws Exception
+ {
+ ProcessInstanceRef newInstanceRef = createNewProcessInstance();
- // refresh instance ref
- newInstanceRef = getInstance(testDeploymentRef, newInstanceId);
- assertNotNull(newInstanceRef);
+ // signal it to move to task node which in our case is the ned node
+ // which means after that the process shouldn't exist anymore
+ String url = "/jbpm3/tokens/"+newInstanceRef.getRootToken().getId()+"/transition/default";
+ HTTP.post(
+ SERVER_URL + url, EMPTY, DEFAULT_CREDENTIALS
+ );
- // same token?
- assertTrue(previousTokenId == newInstanceRef.getRootToken().getId());
+ ProcessInstanceRefWrapper instanceList = getInstanceList(testDeploymentRef);
+ boolean exists = false;
+ for(ProcessInstanceRef iref : instanceList.getInstances())
+ {
+ if(iref.equals(newInstanceRef))
+ {
+ exists = true;
+ break;
+ }
+ }
- // did it really move?
- assertFalse( previousNodeName.equals( newInstanceRef.getRootToken().getCurrentNodeName()));
-
- */
+ assertFalse(exists);
- }
+ }
}
17 years, 4 months
JBoss JBPM SVN: r3390 - projects/gwt-console/trunk/server/src/main/webapp/WEB-INF.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-12-15 07:21:18 -0500 (Mon, 15 Dec 2008)
New Revision: 3390
Modified:
projects/gwt-console/trunk/server/src/main/webapp/WEB-INF/jboss-web.xml
Log:
re-eanble scoped classloading for now
Modified: projects/gwt-console/trunk/server/src/main/webapp/WEB-INF/jboss-web.xml
===================================================================
--- projects/gwt-console/trunk/server/src/main/webapp/WEB-INF/jboss-web.xml 2008-12-15 12:12:37 UTC (rev 3389)
+++ projects/gwt-console/trunk/server/src/main/webapp/WEB-INF/jboss-web.xml 2008-12-15 12:21:18 UTC (rev 3390)
@@ -6,11 +6,11 @@
<jboss-web>
- <!--class-loading>
+ <class-loading>
<loader-repository>
org.bpm.console.server:gwt-consoler-server.war
</loader-repository>
- </class-loading-->
+ </class-loading>
<security-domain>java:/jaas/jbpm-console</security-domain>
17 years, 4 months
JBoss JBPM SVN: r3389 - projects/report-server/trunk.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-12-15 07:12:37 -0500 (Mon, 15 Dec 2008)
New Revision: 3389
Modified:
projects/report-server/trunk/pom.xml
Log:
Strip down reasteasy dependencies to avoid clash with server API's
Modified: projects/report-server/trunk/pom.xml
===================================================================
--- projects/report-server/trunk/pom.xml 2008-12-15 12:08:19 UTC (rev 3388)
+++ projects/report-server/trunk/pom.xml 2008-12-15 12:12:37 UTC (rev 3389)
@@ -1,72 +1,106 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <name>JBoss jBPM3 - Report (BIRT integration)</name>
- <groupId>org.jbpm</groupId>
- <artifactId>report-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <packaging>pom</packaging>
+ <modelVersion>4.0.0</modelVersion>
+ <name>JBoss jBPM3 - Report (BIRT integration)</name>
+ <groupId>org.jbpm</groupId>
+ <artifactId>report-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
- <!-- Parent -->
- <parent>
- <groupId>org.jbpm</groupId>
- <artifactId>jbpm-parent</artifactId>
- <version>1.0.0.GA</version>
- </parent>
+ <!-- Parent -->
+ <parent>
+ <groupId>org.jbpm</groupId>
+ <artifactId>jbpm-parent</artifactId>
+ <version>1.0.0.GA</version>
+ </parent>
- <properties>
- <commons.logging.version>1.1.1</commons.logging.version>
- <junit.version>3.8.1</junit.version>
- <resteasy.version>1.0-beta-8</resteasy.version>
- </properties>
+ <properties>
+ <commons.logging.version>1.1.1</commons.logging.version>
+ <junit.version>3.8.1</junit.version>
+ <resteasy.version>1.0-beta-8</resteasy.version>
+ </properties>
- <modules>
- <module>core</module>
- <module>server</module>
- </modules>
+ <modules>
+ <module>core</module>
+ <module>server</module>
+ </modules>
- <dependencyManagement>
- <dependencies>
- <!-- Other -->
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>${commons.logging.version}</version>
- </dependency>
+ <dependencyManagement>
+ <dependencies>
+ <!-- Other -->
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>${commons.logging.version}</version>
+ </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit.version}</version>
- <scope>test</scope>
- </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
- <dependency>
- <groupId>org.jboss.resteasy</groupId>
- <artifactId>resteasy-jaxrs</artifactId>
- <version>${resteasy.version}</version>
- </dependency>
+ <dependency>
+ <groupId>org.jboss.resteasy</groupId>
+ <artifactId>resteasy-jaxrs</artifactId>
+ <version>${resteasy.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>tjws</groupId>
+ <artifactId>webserver</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.xml.stream</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
- </dependencies>
- </dependencyManagement>
+ </dependencies>
+ </dependencyManagement>
- <!-- Repositories -->
- <repositories>
- <repository>
- <id>repository.jboss.org</id>
- <url>http://repository.jboss.org/maven2</url>
- </repository>
- <repository>
- <id>snapshots.jboss.org</id>
- <name>JBoss Snapshot Repository</name>
- <url>http://snapshots.jboss.org/maven2</url>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- </repository>
- </repositories>
+ <!-- Repositories -->
+ <repositories>
+ <repository>
+ <id>repository.jboss.org</id>
+ <url>http://repository.jboss.org/maven2</url>
+ </repository>
+ <repository>
+ <id>snapshots.jboss.org</id>
+ <name>JBoss Snapshot Repository</name>
+ <url>http://snapshots.jboss.org/maven2</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
</project>
17 years, 4 months
JBoss JBPM SVN: r3388 - in projects/gwt-console/trunk/server: src/main/webapp/WEB-INF and 1 other directory.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-12-15 07:08:19 -0500 (Mon, 15 Dec 2008)
New Revision: 3388
Modified:
projects/gwt-console/trunk/server/pom.xml
projects/gwt-console/trunk/server/src/main/webapp/WEB-INF/jboss-web.xml
Log:
Strip down reasteasy dependencies to avoid clash with server API's
Modified: projects/gwt-console/trunk/server/pom.xml
===================================================================
--- projects/gwt-console/trunk/server/pom.xml 2008-12-15 10:48:39 UTC (rev 3387)
+++ projects/gwt-console/trunk/server/pom.xml 2008-12-15 12:08:19 UTC (rev 3388)
@@ -78,6 +78,40 @@
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>tjws</groupId>
+ <artifactId>webserver</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.xml.stream</groupId>
+ <artifactId>stax-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
Modified: projects/gwt-console/trunk/server/src/main/webapp/WEB-INF/jboss-web.xml
===================================================================
--- projects/gwt-console/trunk/server/src/main/webapp/WEB-INF/jboss-web.xml 2008-12-15 10:48:39 UTC (rev 3387)
+++ projects/gwt-console/trunk/server/src/main/webapp/WEB-INF/jboss-web.xml 2008-12-15 12:08:19 UTC (rev 3388)
@@ -6,11 +6,11 @@
<jboss-web>
- <class-loading>
- <loader-repository>
+ <!--class-loading>
+ <loader-repository>
org.bpm.console.server:gwt-consoler-server.war
</loader-repository>
- </class-loading>
+ </class-loading-->
<security-domain>java:/jaas/jbpm-console</security-domain>
17 years, 4 months
JBoss JBPM SVN: r3387 - in jbpm4/trunk/modules: test-base/src/main/java/org/jbpm/test and 8 other directories.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2008-12-15 05:48:39 -0500 (Mon, 15 Dec 2008)
New Revision: 3387
Added:
jbpm4/trunk/modules/test-load/src/test/java/org/
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/ExclusiveTestCommand.java
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/FailOnceTestCommand.java
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/FailingTestCommand.java
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/GenerateExceptionTestCommand.java
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorIsolationDbTest.java
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTest.java
jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/TestMessageCommand.java
jbpm4/trunk/modules/test-load/src/test/resources/
jbpm4/trunk/modules/test-load/src/test/resources/hibernate.properties
jbpm4/trunk/modules/test-load/src/test/resources/jbpm.cfg.xml
jbpm4/trunk/modules/test-load/src/test/resources/logging.properties
Removed:
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/ExclusiveTestCommand.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailOnceTestCommand.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailingTestCommand.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/GenerateExceptionTestCommand.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorIsolationDbTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java
jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/TestMessageCommand.java
Modified:
jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java
jbpm4/trunk/modules/test-load/pom.xml
Log:
set up test-load
Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/ExclusiveTestCommand.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/ExclusiveTestCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/ExclusiveTestCommand.java 2008-12-15 10:48:39 UTC (rev 3387)
@@ -1,98 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.jobexecutor;
-
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-
-import org.hibernate.Session;
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.log.Log;
-import org.jbpm.model.OpenExecution;
-import org.jbpm.pvm.internal.job.CommandMessage;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.wire.descriptor.LongDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.session.DbSession;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ExclusiveTestCommand implements Command<Object> {
-
- private static final long serialVersionUID = 1L;
- private static final Log log = Log.getLog(ExclusiveTestCommand.class.getName());
- static Random random = new Random();
-
- long executionId;
-
- public ExclusiveTestCommand() {
- }
-
- public static CommandMessage createMessage(OpenExecution execution) {
- CommandMessage commandMessage = new CommandMessage();
- commandMessage.setExecution((ExecutionImpl) execution);
- commandMessage.setExclusive(true);
-
- ObjectDescriptor commandDescriptor = new ObjectDescriptor(ExclusiveTestCommand.class);
- commandDescriptor.addInjection("executionId", new LongDescriptor(execution.getDbid()));
- commandMessage.setCommandDescriptor(commandDescriptor);
- return commandMessage;
- }
-
- public Object execute(Environment environment) throws Exception {
- Long threadId = Thread.currentThread().getId();
-
- Session session = environment.get(Session.class);
- ExecutionImpl execution = (ExecutionImpl) session.get(ExecutionImpl.class, executionId);
-
- String executionKey = execution.getKey();
-
- // exclusiveMessageIds maps execution keys to a set of thread ids.
- // the idea is that for each execution, all the exclusive jobs will
- // be executed by 1 thread sequentially.
-
- // in the end, each set should contain exactly 1 element
- Set<Long> groupMessages = JobExecutorTest.exclusiveThreadIds.get(executionKey);
- if (groupMessages==null) {
- groupMessages = new HashSet<Long>();
- JobExecutorTest.exclusiveThreadIds.put(executionKey, groupMessages);
- }
- groupMessages.add(threadId);
-
- // let's assume that an average jobImpl takes between 0 and 150 millis to complete.
- int workTime = random.nextInt(150);
- log.debug("executing exclusive message for "+execution+". this is going to take "+workTime+"ms");
- try {
- Thread.sleep(workTime);
- } catch (RuntimeException e) {
- log.debug("sleeping was interrupted");
- }
-
- return null;
- }
-
-}
Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailOnceTestCommand.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailOnceTestCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailOnceTestCommand.java 2008-12-15 10:48:39 UTC (rev 3387)
@@ -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.pvm.internal.jobexecutor;
-
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.log.Log;
-import org.jbpm.model.Comment;
-import org.jbpm.pvm.internal.job.CommandMessage;
-import org.jbpm.pvm.internal.job.MessageImpl;
-import org.jbpm.pvm.internal.model.CommentImpl;
-import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.session.DbSession;
-
-
-/**
- * @author Tom Baeyens
- */
-public class FailOnceTestCommand implements Command<Object> {
-
- private static final long serialVersionUID = 1L;
- private static final Log log = Log.getLog(FailOnceTestCommand.class.getName());
-
- int messageId;
-
- public FailOnceTestCommand() {
- }
-
- public static CommandMessage createMessage(int messageId) {
- CommandMessage commandMessage = new CommandMessage();
- ObjectDescriptor commandDescriptor = new ObjectDescriptor(FailOnceTestCommand.class);
- commandDescriptor.addInjection("messageId", new IntegerDescriptor(messageId));
- commandMessage.setCommandDescriptor(commandDescriptor);
- return commandMessage;
- }
-
- public Object execute(Environment environment) throws Exception {
- DbSession dbSession = environment.get(DbSession.class);
-
- // this message execution should be rolled back
- Comment comment = new CommentImpl(Integer.toString(messageId));
- dbSession.save(comment);
-
- if (!JobExecutorTest.failOnceMessageIds.contains(messageId)) {
- // registering the failed message in a non-transactional resource
- // so the messageId will still be added even after the transaction has rolled back
- log.debug("adding failonce message "+messageId);
- JobExecutorTest.failOnceMessageIds.add(messageId);
-
- throw new RuntimeException("failing once");
- }
-
- log.debug("message "+messageId+" now succeeds");
-
- return null;
- }
-
-}
Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailingTestCommand.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailingTestCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailingTestCommand.java 2008-12-15 10:48:39 UTC (rev 3387)
@@ -1,57 +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.jobexecutor;
-
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.model.Comment;
-import org.jbpm.pvm.internal.job.CommandMessage;
-import org.jbpm.pvm.internal.model.CommentImpl;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.session.DbSession;
-
-
-/**
- * @author Tom Baeyens
- */
-public class FailingTestCommand implements Command<Object> {
-
- private static final long serialVersionUID = 1L;
-
- public Object execute(Environment environment) throws Exception {
- DbSession dbSession = environment.get(DbSession.class);
-
- // this message execution should be rolled back
- Comment comment = new CommentImpl("failing update");
- dbSession.save(comment);
-
- throw new RuntimeException("ooops");
- }
-
- public static CommandMessage createMessage() {
- CommandMessage commandMessage = new CommandMessage();
- ObjectDescriptor commandDescriptor = new ObjectDescriptor(FailingTestCommand.class);
- commandMessage.setCommandDescriptor(commandDescriptor);
- return commandMessage;
- }
-
-}
Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/GenerateExceptionTestCommand.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/GenerateExceptionTestCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/GenerateExceptionTestCommand.java 2008-12-15 10:48:39 UTC (rev 3387)
@@ -1,66 +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.jobexecutor;
-
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.pvm.internal.job.CommandMessage;
-import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-
-
-/**
- * @author Tom Baeyens
- * @author Guillaume Porcher
- *
- * Simple command that will create an exception during execution.
- * The exception will generate a stacktrace with variable length
- * (controlled by the length parameter).
- *
- * This class is to test the persistence of exception stacktrace in jobs.
- */
-public class GenerateExceptionTestCommand implements Command<Object> {
-
- private static final long serialVersionUID = 1L;
-
- int length;
-
- public GenerateExceptionTestCommand() {
- }
-
- public static CommandMessage createMessage(int recursionInitialDepth) {
- CommandMessage commandMessage = new CommandMessage();
- ObjectDescriptor commandDescriptor = new ObjectDescriptor(GenerateExceptionTestCommand.class);
- commandDescriptor.addInjection("length", new IntegerDescriptor(recursionInitialDepth));
- commandMessage.setCommandDescriptor(commandDescriptor);
- return commandMessage;
- }
-
- public Object execute(Environment environment) throws Exception {
- StringBuilder stringBuilder = new StringBuilder();
- while (stringBuilder.length() < length) {
- stringBuilder.append("This is a test message. ");
- }
- throw new RuntimeException(stringBuilder.toString());
- }
-
-}
Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorIsolationDbTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorIsolationDbTest.java 2008-12-15 10:16:26 UTC (rev 3386)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorIsolationDbTest.java 2008-12-15 10:48:39 UTC (rev 3387)
@@ -1,86 +0,0 @@
-/**
- * Copyright (C) 2007 Bull S. A. S.
- * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
- * This library 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
- * version 2.1 of the License.
- * This library 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
- * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
- * Floor, Boston, MA 02110-1301, USA.
- **/
-package org.jbpm.pvm.internal.jobexecutor;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.job.Message;
-import org.jbpm.log.Log;
-import org.jbpm.pvm.internal.job.CommandMessage;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.session.MessageSession;
-import org.jbpm.session.PvmDbSession;
-import org.jbpm.test.OldDbTestCase;
-
-
-/**
- * This class contains job executor tests which requires to have a read commited isolation level.
- *
- * @author Guillaume Porcher
- *
- */
-public class JobExecutorIsolationDbTest extends OldDbTestCase {
-
- static int jobExecutorTimeoutMillis = 500;
- static int checkInterval = 400;
-
- public static class SimpleTestCommand implements Command<Object> {
- private static final Log log = Log.getLog(SimpleTestCommand.class.getName());
-
- public Object execute(Environment environment) throws Exception {
- log.debug("command executed !");
- return null;
- }
- }
-
- public void testInsertMessage() {
- System.out.println("FIXME: JBPM-1769 fix db isolation test");
- }
-
-
- /*
- * Basic test that only shows a simple situation in which we need to have a read commited isolation level.
- */
-
- // FIX rename test method back to testInsertMessage
- public void dontTestInsertMessage() throws InterruptedException {
- JobExecutorTest.processedMessageIds = new ArrayList<Integer>();
- JobExecutor jobExecutor = getEnvironmentFactory().get(JobExecutor.class);
- jobExecutor.setIdleInterval(jobExecutorTimeoutMillis);
- jobExecutor.start();
- try {
- commandService.execute(new Command<Object>() {
- public Object execute(Environment environment) throws Exception {
- MessageSession messageSession = environment.get(MessageSession.class);
- CommandMessage commandMessage = new CommandMessage(new ObjectDescriptor(SimpleTestCommand.class));
- messageSession.send(commandMessage);
- List<Message> messages = environment.get(PvmDbSession.class).findMessages(0, 10);
- assertNotNull(messages);
- assertEquals(1, messages.size());
- Thread.sleep(jobExecutorTimeoutMillis * 2);
- messages = environment.get(PvmDbSession.class).findMessages(0, 10);
- assertNotNull(messages);
- assertEquals("Job has been executed before the transaction is committed !!", 1, messages.size());
- return null;
- }
- });
- Thread.sleep(jobExecutorTimeoutMillis * 2);
- } finally {
- jobExecutor.stop(true);
- }
- }
-}
Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java 2008-12-15 10:16:26 UTC (rev 3386)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java 2008-12-15 10:48:39 UTC (rev 3387)
@@ -1,378 +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.jobexecutor;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-
-import junit.framework.Test;
-
-import org.hibernate.Session;
-import org.jbpm.ProcessService;
-import org.jbpm.activity.ActivityExecution;
-import org.jbpm.activity.ExternalActivity;
-import org.jbpm.client.ClientExecution;
-import org.jbpm.client.ClientProcessDefinition;
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.job.Job;
-import org.jbpm.log.Log;
-import org.jbpm.model.Comment;
-import org.jbpm.pvm.internal.job.CommandMessage;
-import org.jbpm.pvm.internal.job.JobImpl;
-import org.jbpm.pvm.internal.svc.DeploymentImpl;
-import org.jbpm.pvm.model.ProcessFactory;
-import org.jbpm.session.MessageSession;
-import org.jbpm.session.PvmDbSession;
-import org.jbpm.test.EnvironmentFactoryTestSetup;
-import org.jbpm.test.OldDbTestCase;
-
-/**
- * @author Tom Baeyens
- * @author Guillaume Porcher
- */
-public class JobExecutorTest extends OldDbTestCase {
-
- private static final Log log = Log.getLog(JobExecutorTest.class.getName());
-
- static List<Integer> processedMessageIds;
- static Map<String, Set<Long>> exclusiveThreadIds;
- static List<Integer> failOnceMessageIds;
-
- static int nbrOfTestMessages = 50;
- static int timeoutMillis = 10000;
- static int checkInterval = 400;
- static int nbrOfTestMessagesPerExecution = 7;
- static int nbrOfTestExecutions = 5;
-
- public static Test suite()
- {
- return new EnvironmentFactoryTestSetup(JobExecutorTest.class);
- }
-
- public void setUp() throws Exception {
- super.setUp();
- processedMessageIds = new ArrayList<Integer>();
- exclusiveThreadIds = new HashMap<String, Set<Long>>();
- failOnceMessageIds = new ArrayList<Integer>();
- }
-
- public void testSuccessfulMessageProcessing() {
- JobExecutor jobExecutor = getEnvironmentFactory().get(JobExecutor.class);
- jobExecutor.start();
- try {
- insertTestMessages();
- waitTillNoMoreMessages(jobExecutor);
-
- } finally {
- jobExecutor.stop(true);
- }
-
- for (int i=0; i<nbrOfTestMessages; i++) {
- assertTrue("message "+i+" is not processed: "+processedMessageIds, processedMessageIds.contains(i));
- }
- }
-
- public void testMessagesPresentUponJobExecutorStartUp() {
-
- insertTestMessages();
-
- JobExecutor jobExecutor = getEnvironmentFactory().get(JobExecutor.class);
- jobExecutor.start();
- try {
- waitTillNoMoreMessages(jobExecutor);
-
- } finally {
- jobExecutor.stop(true);
- }
-
- for (int i=0; i<nbrOfTestMessages; i++) {
- assertTrue("message "+i+" is not processed", processedMessageIds.contains(i));
- }
- }
-
- public void testExclusiveMessageProcessing() {
- insertExclusiveTestMessages();
-
- JobExecutor jobExecutor = getEnvironmentFactory().get(JobExecutor.class);
- jobExecutor.start();
- try {
-
- waitTillNoMoreMessages(jobExecutor);
-
- } finally {
- jobExecutor.stop(true);
- }
-
- commandService.execute(new Command<Object>() {
- public Object execute(Environment environment) throws Exception {
- // exclusiveMessageIds maps execution keys to a set of thread ids.
- // the idea is that for each execution, all the exclusive jobs will
- // be executed by 1 thread sequentially.
-
- for (int i=0; i<nbrOfTestExecutions; i++) {
- String executionKey = "execution-"+i;
- Set<Long> threadIds = exclusiveThreadIds.get(executionKey);
- assertNotNull("no thread id set for "+executionKey+" in: "+exclusiveThreadIds, threadIds);
- assertEquals("exclusive messages for "+executionKey+" have been executed by multiple threads: "+threadIds,
- 1,
- threadIds.size());
- }
- return null;
- }
- });
- }
-
- public void testFailOnceMessages() {
- failOnceMessageIds.clear();
-
- JobExecutor jobExecutor = getEnvironmentFactory().get(JobExecutor.class);
- jobExecutor.start();
- try {
- insertFailOnceTestMessages();
- waitTillNoMoreMessages(jobExecutor);
-
- } finally {
- jobExecutor.stop(true);
- }
-
- for (int i=0; i<nbrOfTestMessages; i++) {
- assertTrue("message "+i+" is not failed once: "+failOnceMessageIds, failOnceMessageIds.contains(i));
- }
- assertEquals(nbrOfTestMessages, failOnceMessageIds.size());
-
- commandService.execute(new Command<Object>() {
- public Object execute(Environment environment) throws Exception {
- Session session = environment.get(Session.class);
- List<Comment> comments = session.createQuery("from org.jbpm.pvm.internal.model.CommentImpl").list();
-
- for (Comment comment: comments) {
- Integer messageId = new Integer(comment.getMessage());
- assertTrue("message "+messageId+" committed twice", failOnceMessageIds.remove(messageId));
- }
-
- assertTrue("not all messages made a successful commit: "+failOnceMessageIds, failOnceMessageIds.isEmpty());
- return null;
- }
- });
- }
-
- public void testFailedMessageProcessing() {
- JobExecutor jobExecutor = getEnvironmentFactory().get(JobExecutor.class);
- jobExecutor.start();
- try {
- commandService.execute(new Command<Object>() {
- public Object execute(Environment environment) throws Exception {
- MessageSession messageSession = environment.get(MessageSession.class);
- CommandMessage commandMessage = FailingTestCommand.createMessage();
- messageSession.send(commandMessage);
- return null;
- }
- });
-
- waitTillNoMoreMessages(jobExecutor);
-
- } finally {
- jobExecutor.stop(true);
- }
-
- commandService.execute(new Command<Object>() {
- public Object execute(Environment environment) throws Exception {
- PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
- List<Job> deadJobs = pvmDbSession.findJobsWithException(0, 10);
- assertEquals("there should be one dead job", 1, deadJobs.size());
-
- Session session = environment.get(Session.class);
- List commands = session.createQuery("from org.jbpm.pvm.internal.model.CommentImpl").list();
- assertTrue("command insertion should have been rolled back", commands.isEmpty());
- return null;
- }
- });
- }
-
- public void testExceptionInJob() {
-
- JobExecutor jobExecutor = getEnvironmentFactory().get(JobExecutor.class);
- jobExecutor.start();
- try {
- commandService.execute(new Command<Object>() {
- // size of the error message to generate
- // (currently there is a limit of 4000 characters)
- int msgLength = 4100;
-
- public Object execute(Environment environment) throws Exception {
- MessageSession messageSession = environment.get(MessageSession.class);
- CommandMessage commandMessage = GenerateExceptionTestCommand.createMessage(msgLength);
- messageSession.send(commandMessage);
- return null;
- }
- });
-
- waitTillNoMoreMessages(jobExecutor);
-
- } finally {
- jobExecutor.stop(true);
- }
-
- commandService.execute(new Command<Object>() {
- public Object execute(Environment environment) throws Exception {
- PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
- List<Job> deadJobs = pvmDbSession.findJobsWithException(0, 10);
- assertEquals("there should be one dead jobImpl", 1, deadJobs.size());
- return null;
- }
- });
- }
- // helper methods ///////////////////////////////////////////////////////////
-
- public static class InsertMessageCmd implements Command<Object> {
- private static final long serialVersionUID = 1L;
- int i;
- public InsertMessageCmd(int i) {
- this.i = i;
- }
- public Object execute(Environment environment) throws Exception {
- MessageSession messageSession = environment.get(MessageSession.class);
- CommandMessage commandMessage = TestMessageCommand.createMessage(i);
- messageSession.send(commandMessage);
- return null;
- }
- }
-
- void insertTestMessages() {
- for (int i=0; i<nbrOfTestMessages; i++) {
- commandService.execute(new InsertMessageCmd(i));
- }
- }
-
- public static class WaitState implements ExternalActivity {
- private static final long serialVersionUID = 1L;
- public void execute(ActivityExecution execution) throws Exception {
- execution.waitForSignal();
- }
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
- execution.take(signalName);
- }
- }
-
- void insertExclusiveTestMessages() {
- commandService.execute(new Command<Object>() {
- public Object execute(Environment environment) throws Exception {
- ClientProcessDefinition processDefinition = ProcessFactory.build("excl")
- .node("initial").initial().behaviour(WaitState.class)
- .done();
- DeploymentImpl deploymentImpl = new DeploymentImpl(processDefinition);
- ProcessService processService = environment.get(ProcessService.class);
- processService.deploy(deploymentImpl);
-
- PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
- MessageSession messageSession = environment.get(MessageSession.class);
- for (int i=0; i<nbrOfTestExecutions; i++) {
- ClientExecution execution = processDefinition.startProcessInstance("execution-"+i);
- pvmDbSession.save(execution);
-
- for (int j=0; j<nbrOfTestMessagesPerExecution; j++) {
- CommandMessage exclusiveTestMessage = ExclusiveTestCommand.createMessage(execution);
- messageSession.send(exclusiveTestMessage);
- }
- }
- return null;
- }
- });
- }
-
-
- public static class InsertFailOnceTestMsgCmd implements Command<Object> {
- private static final long serialVersionUID = 1L;
- int i;
- public InsertFailOnceTestMsgCmd(int i) {
- this.i = i;
- }
- public Object execute(Environment environment) throws Exception {
- MessageSession messageSession = environment.get(MessageSession.class);
- CommandMessage commandMessage = FailOnceTestCommand.createMessage(i);
- messageSession.send(commandMessage);
- return null;
- }
- }
-
- void insertFailOnceTestMessages() {
- for (int i=0; i<nbrOfTestMessages; i++) {
- commandService.execute(new InsertFailOnceTestMsgCmd(i));
- }
- }
-
- private void waitTillNoMoreMessages(JobExecutor jobExecutor) {
-
- // install a timer that will interrupt if it takes too long
- // if that happens, it will lead to an interrupted exception and the test will fail
- TimerTask interruptTask = new TimerTask() {
- Thread testThread = Thread.currentThread();
- public void run() {
- log.debug("test "+getName()+" took too long. going to interrupt..."+testThread);
- testThread.interrupt();
- }
- };
- Timer timer = new Timer();
- timer.schedule(interruptTask, timeoutMillis);
-
- try {
- boolean jobsAvailable = true;
- while (jobsAvailable) {
- log.debug("going to sleep for "+checkInterval+" millis, waiting for the jobImpl executor to process more jobs");
- Thread.sleep(checkInterval);
- jobsAvailable = areJobsAvailable();
- }
-
- } catch (InterruptedException e) {
- fail("test execution exceeded treshold of "+timeoutMillis+" milliseconds");
- } finally {
- timer.cancel();
- }
- }
-
- boolean areJobsAvailable() {
- return commandService.execute(new Command<Boolean>() {
- public Boolean execute(Environment environment) throws Exception {
- JobDbSession jobDbSession = environment.get(JobDbSession.class);
-
- JobImpl<?> firstAcquirableJob = jobDbSession.findFirstAcquirableJob();
- if (firstAcquirableJob!=null) {
- log.debug("found more jobs to process");
- return true;
- }
- return false;
- }
-
-
- public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
- }
-
- public void execute(ActivityExecution execution) throws Exception {
- } });
- }
-}
Deleted: jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/TestMessageCommand.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/TestMessageCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
+++ jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/TestMessageCommand.java 2008-12-15 10:48:39 UTC (rev 3387)
@@ -1,75 +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.jobexecutor;
-
-import java.util.List;
-import java.util.Random;
-
-import org.jbpm.cmd.Command;
-import org.jbpm.env.Environment;
-import org.jbpm.log.Log;
-import org.jbpm.pvm.internal.job.CommandMessage;
-import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.session.DbSession;
-
-/**
- * @author Tom Baeyens
- */
-public class TestMessageCommand implements Command<Object> {
-
- private static final long serialVersionUID = 1L;
- private static final Log log = Log.getLog(TestMessageCommand.class.getName());
- static Random random = new Random();
-
- int messageId;
-
- public TestMessageCommand() {
- }
-
- public TestMessageCommand(int messageId) {
- this.messageId = messageId;
- }
-
- public Object execute(Environment environment) throws Exception {
- JobExecutorTest.processedMessageIds.add(messageId);
-
- // let's assume that an average jobImpl takes between 0 and 150 millis to complete.
- int workTime = random.nextInt(150);
- log.debug("executing test message "+messageId+". this is going to take "+workTime+"ms");
- try {
- Thread.sleep(workTime);
- } catch (RuntimeException e) {
- log.debug("sleeping was interrupted");
- }
-
- return null;
- }
-
- public static CommandMessage createMessage(int i) {
- CommandMessage commandMessage = new CommandMessage();
- ObjectDescriptor commandDescriptor = new ObjectDescriptor(TestMessageCommand.class);
- commandDescriptor.addInjection("messageId", new IntegerDescriptor(i));
- commandMessage.setCommandDescriptor(commandDescriptor);
- return commandMessage;
- }
-}
Modified: jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java
===================================================================
--- jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java 2008-12-15 10:16:26 UTC (rev 3386)
+++ jbpm4/trunk/modules/test-base/src/main/java/org/jbpm/test/DbTestCase.java 2008-12-15 10:48:39 UTC (rev 3387)
@@ -35,6 +35,7 @@
import org.jbpm.ProcessEngine;
import org.jbpm.ProcessService;
import org.jbpm.TaskService;
+import org.jbpm.client.ClientProcessDefinition;
import org.jbpm.task.Task;
/**
@@ -116,6 +117,16 @@
return addDeployedProcessDefinition(deployedProcessDefinitions);
}
+ protected ProcessDefinition addDeployedProcessDefinition(ProcessDefinition deployedProcessDefinition) {
+ if (processDefinitions==null) {
+ processDefinitions = new ArrayList<ProcessDefinition>();
+ }
+
+ processDefinitions.add(deployedProcessDefinition);
+
+ return deployedProcessDefinition;
+ }
+
protected ProcessDefinition addDeployedProcessDefinition(List<ProcessDefinition> deployedProcessDefinitions) {
if (processDefinitions==null) {
processDefinitions = new ArrayList<ProcessDefinition>();
Modified: jbpm4/trunk/modules/test-load/pom.xml
===================================================================
--- jbpm4/trunk/modules/test-load/pom.xml 2008-12-15 10:16:26 UTC (rev 3386)
+++ jbpm4/trunk/modules/test-load/pom.xml 2008-12-15 10:48:39 UTC (rev 3387)
@@ -32,14 +32,28 @@
<artifactId>jbpm-api</artifactId>
<version>${version}</version>
</dependency>
+
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-test-base</artifactId>
+ <version>${version}</version>
</dependency>
+
<dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-jpdl</artifactId>
+ <version>${version}</version>
</dependency>
+
+
+ <!-- TODO remove PVM dependency for compilation (keep it for test)-->
+ <dependency>
+ <groupId>org.jbpm.jbpm4</groupId>
+ <artifactId>jbpm-pvm</artifactId>
+ <version>${version}</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<!-- Plugins -->
@@ -50,48 +64,6 @@
<!-- Profiles -->
<profiles>
-
- <!--
- Name: no-impl
- Descr: The default implementation profile
- -->
- <profile>
- <id>no-impl</id>
- <activation>
- <property>
- <name>!impl</name>
- </property>
- </activation>
- <dependencies>
- <dependency>
- <groupId>org.jbpm.jbpm4</groupId>
- <artifactId>jbpm-pvm</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- </profile>
-
- <!--
- Name: impl-ri
- Descr: The RI implementation profile
- -->
- <profile>
- <id>impl-ri</id>
- <activation>
- <property>
- <name>impl</name>
- <value>ri</value>
- </property>
- </activation>
- <dependencies>
- <dependency>
- <groupId>org.jbpm.spec</groupId>
- <artifactId>jbpm-spec-ri</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- </profile>
-
</profiles>
</project>
\ No newline at end of file
Copied: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/ExclusiveTestCommand.java (from rev 3382, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/ExclusiveTestCommand.java)
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/ExclusiveTestCommand.java (rev 0)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/ExclusiveTestCommand.java 2008-12-15 10:48:39 UTC (rev 3387)
@@ -0,0 +1,96 @@
+/*
+ * 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.load;
+
+import java.util.HashSet;
+import java.util.Random;
+import java.util.Set;
+
+import org.hibernate.Session;
+import org.jbpm.Execution;
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.log.Log;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.wire.descriptor.LongDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExclusiveTestCommand implements Command<Object> {
+
+ private static final long serialVersionUID = 1L;
+ private static final Log log = Log.getLog(ExclusiveTestCommand.class.getName());
+ static Random random = new Random();
+
+ long executionId;
+
+ public ExclusiveTestCommand() {
+ }
+
+ public static CommandMessage createMessage(Execution execution) {
+ CommandMessage commandMessage = new CommandMessage();
+ commandMessage.setExecution((ExecutionImpl) execution);
+ commandMessage.setExclusive(true);
+
+ ObjectDescriptor commandDescriptor = new ObjectDescriptor(ExclusiveTestCommand.class);
+ commandDescriptor.addInjection("executionId", new LongDescriptor(execution.getDbid()));
+ commandMessage.setCommandDescriptor(commandDescriptor);
+ return commandMessage;
+ }
+
+ public Object execute(Environment environment) throws Exception {
+ Long threadId = Thread.currentThread().getId();
+
+ Session session = environment.get(Session.class);
+ ExecutionImpl execution = (ExecutionImpl) session.get(ExecutionImpl.class, executionId);
+
+ String executionKey = execution.getKey();
+
+ // exclusiveMessageIds maps execution keys to a set of thread ids.
+ // the idea is that for each execution, all the exclusive jobs will
+ // be executed by 1 thread sequentially.
+
+ // in the end, each set should contain exactly 1 element
+ Set<Long> groupMessages = JobExecutorTest.exclusiveThreadIds.get(executionKey);
+ if (groupMessages==null) {
+ groupMessages = new HashSet<Long>();
+ JobExecutorTest.exclusiveThreadIds.put(executionKey, groupMessages);
+ }
+ groupMessages.add(threadId);
+
+ // let's assume that an average jobImpl takes between 0 and 150 millis to complete.
+ int workTime = random.nextInt(150);
+ log.debug("executing exclusive message for "+execution+". this is going to take "+workTime+"ms");
+ try {
+ Thread.sleep(workTime);
+ } catch (RuntimeException e) {
+ log.debug("sleeping was interrupted");
+ }
+
+ return null;
+ }
+
+}
Copied: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/FailOnceTestCommand.java (from rev 3382, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailOnceTestCommand.java)
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/FailOnceTestCommand.java (rev 0)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/FailOnceTestCommand.java 2008-12-15 10:48:39 UTC (rev 3387)
@@ -0,0 +1,78 @@
+/*
+ * 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.load;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.log.Log;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.job.MessageImpl;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FailOnceTestCommand implements Command<Object> {
+
+ private static final long serialVersionUID = 1L;
+ private static final Log log = Log.getLog(FailOnceTestCommand.class.getName());
+
+ int messageId;
+
+ public FailOnceTestCommand() {
+ }
+
+ public static CommandMessage createMessage(int messageId) {
+ CommandMessage commandMessage = new CommandMessage();
+ ObjectDescriptor commandDescriptor = new ObjectDescriptor(FailOnceTestCommand.class);
+ commandDescriptor.addInjection("messageId", new IntegerDescriptor(messageId));
+ commandMessage.setCommandDescriptor(commandDescriptor);
+ return commandMessage;
+ }
+
+ public Object execute(Environment environment) throws Exception {
+ DbSession dbSession = environment.get(DbSession.class);
+
+ // this message execution should be rolled back
+ Comment comment = new CommentImpl(Integer.toString(messageId));
+ dbSession.save(comment);
+
+ if (!JobExecutorTest.failOnceMessageIds.contains(messageId)) {
+ // registering the failed message in a non-transactional resource
+ // so the messageId will still be added even after the transaction has rolled back
+ log.debug("adding failonce message "+messageId);
+ JobExecutorTest.failOnceMessageIds.add(messageId);
+
+ throw new RuntimeException("failing once");
+ }
+
+ log.debug("message "+messageId+" now succeeds");
+
+ return null;
+ }
+
+}
Copied: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/FailingTestCommand.java (from rev 3382, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/FailingTestCommand.java)
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/FailingTestCommand.java (rev 0)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/FailingTestCommand.java 2008-12-15 10:48:39 UTC (rev 3387)
@@ -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.test.load;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.session.DbSession;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class FailingTestCommand implements Command<Object> {
+
+ private static final long serialVersionUID = 1L;
+
+ public Object execute(Environment environment) throws Exception {
+ DbSession dbSession = environment.get(DbSession.class);
+
+ // this message execution should be rolled back
+ Comment comment = new CommentImpl("failing update");
+ dbSession.save(comment);
+
+ throw new RuntimeException("ooops");
+ }
+
+ public static CommandMessage createMessage() {
+ CommandMessage commandMessage = new CommandMessage();
+ ObjectDescriptor commandDescriptor = new ObjectDescriptor(FailingTestCommand.class);
+ commandMessage.setCommandDescriptor(commandDescriptor);
+ return commandMessage;
+ }
+
+}
Copied: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/GenerateExceptionTestCommand.java (from rev 3382, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/GenerateExceptionTestCommand.java)
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/GenerateExceptionTestCommand.java (rev 0)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/GenerateExceptionTestCommand.java 2008-12-15 10:48:39 UTC (rev 3387)
@@ -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.test.load;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher
+ *
+ * Simple command that will create an exception during execution.
+ * The exception will generate a stacktrace with variable length
+ * (controlled by the length parameter).
+ *
+ * This class is to test the persistence of exception stacktrace in jobs.
+ */
+public class GenerateExceptionTestCommand implements Command<Object> {
+
+ private static final long serialVersionUID = 1L;
+
+ int length;
+
+ public GenerateExceptionTestCommand() {
+ }
+
+ public static CommandMessage createMessage(int recursionInitialDepth) {
+ CommandMessage commandMessage = new CommandMessage();
+ ObjectDescriptor commandDescriptor = new ObjectDescriptor(GenerateExceptionTestCommand.class);
+ commandDescriptor.addInjection("length", new IntegerDescriptor(recursionInitialDepth));
+ commandMessage.setCommandDescriptor(commandDescriptor);
+ return commandMessage;
+ }
+
+ public Object execute(Environment environment) throws Exception {
+ StringBuilder stringBuilder = new StringBuilder();
+ while (stringBuilder.length() < length) {
+ stringBuilder.append("This is a long test message. ");
+ }
+ throw new RuntimeException(stringBuilder.toString());
+ }
+
+}
Copied: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorIsolationDbTest.java (from rev 3382, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorIsolationDbTest.java)
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorIsolationDbTest.java (rev 0)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorIsolationDbTest.java 2008-12-15 10:48:39 UTC (rev 3387)
@@ -0,0 +1,88 @@
+/**
+ * Copyright (C) 2007 Bull S. A. S.
+ * Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois
+ * This library 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
+ * version 2.1 of the License.
+ * This library 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
+ * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+ * Floor, Boston, MA 02110-1301, USA.
+ **/
+package org.jbpm.test.load;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.job.Message;
+import org.jbpm.log.Log;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.session.MessageSession;
+import org.jbpm.session.PvmDbSession;
+import org.jbpm.test.DbTestCase;
+
+
+/**
+ * This class contains job executor tests which requires to have a read commited isolation level.
+ *
+ * @author Guillaume Porcher
+ *
+ */
+public class JobExecutorIsolationDbTest extends DbTestCase {
+
+ static int jobExecutorTimeoutMillis = 500;
+ static int checkInterval = 400;
+
+ public static class SimpleTestCommand implements Command<Object> {
+ private static final Log log = Log.getLog(SimpleTestCommand.class.getName());
+
+ public Object execute(Environment environment) throws Exception {
+ log.debug("command executed !");
+ return null;
+ }
+ }
+
+ public void testInsertMessage() {
+ System.out.println("FIXME: JBPM-1769 fix db isolation test");
+ }
+
+
+ /*
+ * Basic test that only shows a simple situation in which we need to have a read commited isolation level.
+ */
+
+ // FIX rename test method back to testInsertMessage
+ public void dontTestInsertMessage() throws InterruptedException {
+ JobExecutorTest.processedMessageIds = new ArrayList<Integer>();
+ JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
+ jobExecutor.setIdleInterval(jobExecutorTimeoutMillis);
+ jobExecutor.start();
+ try {
+ processEngine.get(CommandService.class).execute(new Command<Object>() {
+ public Object execute(Environment environment) throws Exception {
+ MessageSession messageSession = environment.get(MessageSession.class);
+ CommandMessage commandMessage = new CommandMessage(new ObjectDescriptor(SimpleTestCommand.class));
+ messageSession.send(commandMessage);
+ List<Message> messages = environment.get(PvmDbSession.class).findMessages(0, 10);
+ assertNotNull(messages);
+ assertEquals(1, messages.size());
+ Thread.sleep(jobExecutorTimeoutMillis * 2);
+ messages = environment.get(PvmDbSession.class).findMessages(0, 10);
+ assertNotNull(messages);
+ assertEquals("Job has been executed before the transaction is committed !!", 1, messages.size());
+ return null;
+ }
+ });
+ Thread.sleep(jobExecutorTimeoutMillis * 2);
+ } finally {
+ jobExecutor.stop(true);
+ }
+ }
+}
Property changes on: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorIsolationDbTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:mergeinfo
+
Copied: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTest.java (from rev 3382, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/JobExecutorTest.java)
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTest.java (rev 0)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/JobExecutorTest.java 2008-12-15 10:48:39 UTC (rev 3387)
@@ -0,0 +1,384 @@
+/*
+ * 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.load;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.hibernate.Session;
+import org.jbpm.Execution;
+import org.jbpm.activity.ActivityExecution;
+import org.jbpm.activity.ExternalActivity;
+import org.jbpm.cmd.Command;
+import org.jbpm.cmd.CommandService;
+import org.jbpm.env.Environment;
+import org.jbpm.job.Job;
+import org.jbpm.log.Log;
+import org.jbpm.model.Comment;
+import org.jbpm.pvm.internal.cmd.StartExecutionCmd;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.job.JobImpl;
+import org.jbpm.pvm.internal.jobexecutor.JobDbSession;
+import org.jbpm.pvm.internal.jobexecutor.JobExecutor;
+import org.jbpm.pvm.internal.model.CommentImpl;
+import org.jbpm.session.MessageSession;
+import org.jbpm.session.PvmDbSession;
+import org.jbpm.test.DbTestCase;
+
+/**
+ * @author Tom Baeyens
+ * @author Guillaume Porcher
+ */
+public class JobExecutorTest extends DbTestCase {
+
+ private static final Log log = Log.getLog(JobExecutorTest.class.getName());
+
+ static List<Integer> processedMessageIds;
+ static Map<String, Set<Long>> exclusiveThreadIds;
+ static List<Integer> failOnceMessageIds;
+
+ static int nbrOfTestMessages = 500;
+ static int timeoutMillis = 10 * 60 * 1000; // 10 minutes
+ static int checkInterval = 400;
+ static int nbrOfTestMessagesPerExecution = 10;
+ static int nbrOfTestExecutions = 20;
+
+ CommandService commandService;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ processedMessageIds = new ArrayList<Integer>();
+ exclusiveThreadIds = new HashMap<String, Set<Long>>();
+ failOnceMessageIds = new ArrayList<Integer>();
+
+ commandService = processEngine.get(CommandService.class);
+ }
+
+ public void testSuccessfulMessageProcessing() {
+ JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
+ jobExecutor.start();
+ try {
+ insertTestMessages();
+ waitTillNoMoreMessages(jobExecutor);
+
+ } finally {
+ jobExecutor.stop(true);
+ }
+
+ for (int i = 0; i < nbrOfTestMessages; i++) {
+ assertTrue("message " + i + " is not processed: " + processedMessageIds, processedMessageIds.contains(i));
+ }
+ }
+
+ public void testMessagesPresentUponJobExecutorStartUp() {
+
+ insertTestMessages();
+
+ JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
+ jobExecutor.start();
+ try {
+ waitTillNoMoreMessages(jobExecutor);
+
+ } finally {
+ jobExecutor.stop(true);
+ }
+
+ for (int i = 0; i < nbrOfTestMessages; i++) {
+ assertTrue("message " + i + " is not processed", processedMessageIds.contains(i));
+ }
+ }
+
+ public void testExclusiveMessageProcessing() {
+ insertExclusiveTestMessages();
+
+ JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
+ jobExecutor.start();
+ try {
+
+ waitTillNoMoreMessages(jobExecutor);
+
+ } finally {
+ jobExecutor.stop(true);
+ }
+
+ commandService.execute(new Command<Object>() {
+
+ public Object execute(Environment environment) throws Exception {
+ // exclusiveMessageIds maps execution keys to a set of thread ids.
+ // the idea is that for each execution, all the exclusive jobs will
+ // be executed by 1 thread sequentially.
+
+ for (int i = 0; i < nbrOfTestExecutions; i++) {
+ String executionKey = "execution-" + i;
+ Set<Long> threadIds = exclusiveThreadIds.get(executionKey);
+ assertNotNull("no thread id set for " + executionKey + " in: " + exclusiveThreadIds, threadIds);
+ assertEquals("exclusive messages for " + executionKey + " have been executed by multiple threads: " + threadIds, 1, threadIds.size());
+ }
+ return null;
+ }
+ });
+ }
+
+ public void testFailOnceMessages() {
+ failOnceMessageIds.clear();
+
+ JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
+ jobExecutor.start();
+ try {
+ insertFailOnceTestMessages();
+ waitTillNoMoreMessages(jobExecutor);
+
+ } finally {
+ jobExecutor.stop(true);
+ }
+
+ for (int i = 0; i < nbrOfTestMessages; i++) {
+ assertTrue("message " + i + " is not failed once: " + failOnceMessageIds, failOnceMessageIds.contains(i));
+ }
+ assertEquals(nbrOfTestMessages, failOnceMessageIds.size());
+
+ commandService.execute(new Command<Object>() {
+
+ public Object execute(Environment environment) throws Exception {
+ Session session = environment.get(Session.class);
+ List<Comment> comments = session.createQuery("from " + CommentImpl.class.getName()).list();
+
+ for (Comment comment : comments) {
+ Integer messageId = new Integer(comment.getMessage());
+ assertTrue("message " + messageId + " committed twice", failOnceMessageIds.remove(messageId));
+ }
+
+ assertTrue("not all messages made a successful commit: " + failOnceMessageIds, failOnceMessageIds.isEmpty());
+ return null;
+ }
+ });
+ }
+
+ public void testFailedMessageProcessing() {
+ JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
+ jobExecutor.start();
+ try {
+ commandService.execute(new Command<Object>() {
+
+ public Object execute(Environment environment) throws Exception {
+ MessageSession messageSession = environment.get(MessageSession.class);
+ CommandMessage commandMessage = FailingTestCommand.createMessage();
+ messageSession.send(commandMessage);
+ return null;
+ }
+ });
+
+ waitTillNoMoreMessages(jobExecutor);
+
+ } finally {
+ jobExecutor.stop(true);
+ }
+
+ commandService.execute(new Command<Object>() {
+
+ public Object execute(Environment environment) throws Exception {
+ PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+ List<Job> deadJobs = pvmDbSession.findJobsWithException(0, 10);
+ assertEquals("there should be one dead job", 1, deadJobs.size());
+
+ Session session = environment.get(Session.class);
+ List commands = session.createQuery("from " + CommentImpl.class.getName()).list();
+ assertTrue("command insertion should have been rolled back", commands.isEmpty());
+ return null;
+ }
+ });
+ }
+
+ public void testExceptionInJob() {
+
+ JobExecutor jobExecutor = processEngine.get(JobExecutor.class);
+ jobExecutor.start();
+ try {
+ commandService.execute(new Command<Object>() {
+
+ // size of the error message to generate
+ // (currently there is a limit of 4000 characters)
+ int msgLength = 4100;
+
+ public Object execute(Environment environment) throws Exception {
+ MessageSession messageSession = environment.get(MessageSession.class);
+ CommandMessage commandMessage = GenerateExceptionTestCommand.createMessage(msgLength);
+ messageSession.send(commandMessage);
+ return null;
+ }
+ });
+
+ waitTillNoMoreMessages(jobExecutor);
+
+ } finally {
+ jobExecutor.stop(true);
+ }
+
+ commandService.execute(new Command<Object>() {
+
+ public Object execute(Environment environment) throws Exception {
+ PvmDbSession pvmDbSession = environment.get(PvmDbSession.class);
+ List<Job> deadJobs = pvmDbSession.findJobsWithException(0, 10);
+ assertEquals("there should be one dead jobImpl", 1, deadJobs.size());
+ return null;
+ }
+ });
+ }
+
+ // helper methods ///////////////////////////////////////////////////////////
+
+ public static class InsertMessageCmd implements Command<Object> {
+
+ private static final long serialVersionUID = 1L;
+ int i;
+
+ public InsertMessageCmd(int i) {
+ this.i = i;
+ }
+ public Object execute(Environment environment) throws Exception {
+ MessageSession messageSession = environment.get(MessageSession.class);
+ CommandMessage commandMessage = TestMessageCommand.createMessage(i);
+ messageSession.send(commandMessage);
+ return null;
+ }
+ }
+
+ void insertTestMessages() {
+ for (int i = 0; i < nbrOfTestMessages; i++) {
+ commandService.execute(new InsertMessageCmd(i));
+ }
+ }
+
+ public static class WaitState implements ExternalActivity {
+
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ActivityExecution execution) throws Exception {
+ execution.waitForSignal();
+ }
+ public void signal(ActivityExecution execution, String signalName, Map<String, Object> parameters) throws Exception {
+ execution.take(signalName);
+ }
+ }
+
+ void insertExclusiveTestMessages() {
+ deployJpdlXmlString(
+ "<process name='excl'>" +
+ " <start>" +
+ " <flow to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ commandService.execute(new Command<Object>() {
+ public Object execute(Environment environment) throws Exception {
+ MessageSession messageSession = environment.get(MessageSession.class);
+ for (int i = 0; i < nbrOfTestExecutions; i++) {
+ Execution execution =
+ new StartExecutionCmd("excl:1", null, "execution-" + i)
+ .execute(environment);
+
+ for (int j = 0; j < nbrOfTestMessagesPerExecution; j++) {
+ CommandMessage exclusiveTestMessage = ExclusiveTestCommand.createMessage(execution);
+ messageSession.send(exclusiveTestMessage);
+ }
+ }
+ return null;
+ }
+ });
+ }
+
+ public static class InsertFailOnceTestMsgCmd implements Command<Object> {
+
+ private static final long serialVersionUID = 1L;
+ int i;
+
+ public InsertFailOnceTestMsgCmd(int i) {
+ this.i = i;
+ }
+ public Object execute(Environment environment) throws Exception {
+ MessageSession messageSession = environment.get(MessageSession.class);
+ CommandMessage commandMessage = FailOnceTestCommand.createMessage(i);
+ messageSession.send(commandMessage);
+ return null;
+ }
+ }
+
+ void insertFailOnceTestMessages() {
+ for (int i = 0; i < nbrOfTestMessages; i++) {
+ commandService.execute(new InsertFailOnceTestMsgCmd(i));
+ }
+ }
+
+ private void waitTillNoMoreMessages(JobExecutor jobExecutor) {
+
+ // install a timer that will interrupt if it takes too long
+ // if that happens, it will lead to an interrupted exception and the test
+ // will fail
+ TimerTask interruptTask = new TimerTask() {
+
+ Thread testThread = Thread.currentThread();
+
+ public void run() {
+ log.debug("test " + getName() + " took too long. going to interrupt..." + testThread);
+ testThread.interrupt();
+ }
+ };
+ Timer timer = new Timer();
+ timer.schedule(interruptTask, timeoutMillis);
+
+ try {
+ boolean jobsAvailable = true;
+ while (jobsAvailable) {
+ log.debug("going to sleep for " + checkInterval + " millis, waiting for the jobImpl executor to process more jobs");
+ Thread.sleep(checkInterval);
+ jobsAvailable = areJobsAvailable();
+ }
+
+ } catch (InterruptedException e) {
+ fail("test execution exceeded treshold of " + timeoutMillis + " milliseconds");
+ } finally {
+ timer.cancel();
+ }
+ }
+
+ boolean areJobsAvailable() {
+ return commandService.execute(new Command<Boolean>() {
+ public Boolean execute(Environment environment) {
+ JobDbSession jobDbSession = environment.get(JobDbSession.class);
+
+ JobImpl< ? > firstAcquirableJob = jobDbSession.findFirstAcquirableJob();
+ if (firstAcquirableJob != null) {
+ log.debug("found more jobs to process");
+ return true;
+ }
+ return false;
+ }
+ });
+ }
+}
Copied: jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/TestMessageCommand.java (from rev 3382, jbpm4/trunk/modules/pvm/src/test/java/org/jbpm/pvm/internal/jobexecutor/TestMessageCommand.java)
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/TestMessageCommand.java (rev 0)
+++ jbpm4/trunk/modules/test-load/src/test/java/org/jbpm/test/load/TestMessageCommand.java 2008-12-15 10:48:39 UTC (rev 3387)
@@ -0,0 +1,75 @@
+/*
+ * 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.load;
+
+import java.util.List;
+import java.util.Random;
+
+import org.jbpm.cmd.Command;
+import org.jbpm.env.Environment;
+import org.jbpm.log.Log;
+import org.jbpm.pvm.internal.job.CommandMessage;
+import org.jbpm.pvm.internal.wire.descriptor.IntegerDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.session.DbSession;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TestMessageCommand implements Command<Object> {
+
+ private static final long serialVersionUID = 1L;
+ private static final Log log = Log.getLog(TestMessageCommand.class.getName());
+ static Random random = new Random();
+
+ int messageId;
+
+ public TestMessageCommand() {
+ }
+
+ public TestMessageCommand(int messageId) {
+ this.messageId = messageId;
+ }
+
+ public Object execute(Environment environment) throws Exception {
+ JobExecutorTest.processedMessageIds.add(messageId);
+
+ // let's assume that an average jobImpl takes between 0 and 150 millis to complete.
+ int workTime = random.nextInt(150);
+ log.debug("executing test message "+messageId+". this is going to take "+workTime+"ms");
+ try {
+ Thread.sleep(workTime);
+ } catch (RuntimeException e) {
+ log.debug("sleeping was interrupted");
+ }
+
+ return null;
+ }
+
+ public static CommandMessage createMessage(int i) {
+ CommandMessage commandMessage = new CommandMessage();
+ ObjectDescriptor commandDescriptor = new ObjectDescriptor(TestMessageCommand.class);
+ commandDescriptor.addInjection("messageId", new IntegerDescriptor(i));
+ commandMessage.setCommandDescriptor(commandDescriptor);
+ return commandMessage;
+ }
+}
Added: jbpm4/trunk/modules/test-load/src/test/resources/hibernate.properties
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/resources/hibernate.properties (rev 0)
+++ jbpm4/trunk/modules/test-load/src/test/resources/hibernate.properties 2008-12-15 10:48:39 UTC (rev 3387)
@@ -0,0 +1,11 @@
+hibernate.dialect org.hibernate.dialect.HSQLDialect
+hibernate.connection.driver_class org.hsqldb.jdbcDriver
+hibernate.connection.url jdbc:hsqldb:mem:.
+hibernate.connection.username sa
+hibernate.connection.password
+hibernate.hbm2ddl.auto create-drop
+hibernate.cache.use_second_level_cache true
+hibernate.cache.provider_class org.hibernate.cache.HashtableCacheProvider
+# hibernate.show_sql true
+hibernate.format_sql true
+hibernate.use_sql_comments true
Added: jbpm4/trunk/modules/test-load/src/test/resources/jbpm.cfg.xml
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/resources/jbpm.cfg.xml (rev 0)
+++ jbpm4/trunk/modules/test-load/src/test/resources/jbpm.cfg.xml 2008-12-15 10:48:39 UTC (rev 3387)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">
+
+ <process-engine>
+
+ <deployer-manager>
+ <assign-file-type>
+ <file extension=".jpdl.xml" type="jpdl" />
+ </assign-file-type>
+ <parse-jpdl />
+ <check-process />
+ <check-problems />
+ <save />
+ </deployer-manager>
+
+ <process-service />
+ <execution-service />
+ <management-service />
+
+ <command-service>
+ <retry-interceptor />
+ <environment-interceptor />
+ <standard-transaction-interceptor />
+ </command-service>
+
+ <hibernate-configuration>
+ <properties resource="hibernate.properties" />
+ <mapping resource="jbpm.pvm.typedefs.hbm.xml" />
+ <mapping resource="jbpm.pvm.wire.hbm.xml" />
+ <mapping resource="jbpm.pvm.definition.hbm.xml" />
+ <mapping resource="jbpm.pvm.execution.hbm.xml" />
+ <mapping resource="jbpm.pvm.variable.hbm.xml" />
+ <mapping resource="jbpm.pvm.job.hbm.xml" />
+ <mapping resource="jbpm.jpdl.hbm.xml" />
+ <cache-configuration resource="jbpm.pvm.cache.xml"
+ usage="nonstrict-read-write" />
+ </hibernate-configuration>
+
+ <hibernate-session-factory />
+
+ <job-executor auto-start="false" />
+ <job-test-helper />
+
+ <id-generator />
+ <variable-types resource="jbpm.pvm.types.xml" />
+
+ <business-calendar>
+ <monday hours="9:00-12:00 and 12:30-17:00"/>
+ <tuesday hours="9:00-12:00 and 12:30-17:00"/>
+ <wednesday hours="9:00-12:00 and 12:30-17:00"/>
+ <thursday hours="9:00-12:00 and 12:30-17:00"/>
+ <friday hours="9:00-12:00 and 12:30-17:00"/>
+ <holiday period="01/07/2008 - 31/08/2008"/>
+ </business-calendar>
+
+ </process-engine>
+
+ <environment>
+ <hibernate-session />
+ <transaction />
+ <pvm-db-session />
+ <job-db-session />
+ <message-session />
+ <timer-session />
+ </environment>
+
+</jbpm-configuration>
Property changes on: jbpm4/trunk/modules/test-load/src/test/resources/jbpm.cfg.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/trunk/modules/test-load/src/test/resources/logging.properties
===================================================================
--- jbpm4/trunk/modules/test-load/src/test/resources/logging.properties (rev 0)
+++ jbpm4/trunk/modules/test-load/src/test/resources/logging.properties 2008-12-15 10:48:39 UTC (rev 3387)
@@ -0,0 +1,28 @@
+handlers= java.util.logging.ConsoleHandler
+# to add the error triggered file handler
+# handlers= java.util.logging.ConsoleHandler org.jbpm.util.ErrorTriggeredFileHandler
+
+redirect.commons.logging = enabled
+
+java.util.logging.ConsoleHandler.level = FINEST
+java.util.logging.ConsoleHandler.formatter = org.jbpm.log.LogFormatter
+
+# org.jbpm.util.ErrorTriggeredFileHandler.size = 500
+# org.jbpm.util.ErrorTriggeredFileHandler.push = OFF
+# org.jbpm.util.ErrorTriggeredFileHandler.pattern = %h/jbpm%u.log
+
+# For example, set the com.xyz.foo logger to only log SEVERE messages:
+# com.xyz.foo.level = SEVERE
+
+org.jbpm.level=FINEST
+org.jbpm.pvm.internal.tx.level=FINE
+org.jbpm.pvm.internal.wire.level=FINE
+org.jbpm.pvm.internal.util.level=FINE
+
+org.hibernate.cfg.HbmBinder.level=SEVERE
+org.hibernate.cfg.SettingsFactory.level=SEVERE
+# org.hibernate.level=FINE
+# org.hibernate.SQL.level=FINEST
+# org.hibernate.type.level=FINEST
+# org.hibernate.tool.hbm2ddl.SchemaExport.level=FINEST
+# org.hibernate.transaction.level=FINEST
17 years, 4 months
JBoss JBPM SVN: r3386 - in jbpm3/trunk/modules/core/src: test/java/org/jbpm/command and 1 other directory.
by do-not-reply@jboss.org
Author: camunda
Date: 2008-12-15 05:16:26 -0500 (Mon, 15 Dec 2008)
New Revision: 3386
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/AbstractGetObjectBaseCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/AbstractProcessInstanceBaseCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/AbstractTokenBaseCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/BatchSignalCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/CancelProcessInstanceCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/CancelTokenCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/CancelWorkOnTaskCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/ChangeProcessInstanceVersionCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/DeleteProcessDefinitionCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/DeployProcessCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessDefinitionCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessDefinitionsCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessInstanceCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessInstancesCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetTaskInstanceCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetTaskListCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/NewProcessInstanceCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/SignalCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/StartProcessInstanceCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/StartWorkOnTaskCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/TaskInstanceEndCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/UnlockTokenCommand.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/VariablesCommand.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/command/ChangeProcessInstanceVersionCommandTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/command/ProcessInstanceCommandTest.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/command/TokenCommandTest.java
Log:
JBPM-1905
- Removed added return value for setter to ensure backward compatibility (JBPM-1919)
- Added methods for fluent programming
see also http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4196472
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/AbstractGetObjectBaseCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/AbstractGetObjectBaseCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/AbstractGetObjectBaseCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -205,4 +205,25 @@
{
this.jbpmContext = jbpmContext;
}
+
+ // methods for fluent programming
+
+ public AbstractGetObjectBaseCommand variablesToInclude(String[] variablesToInclude)
+ {
+ setVariablesToInclude(variablesToInclude);
+ return this;
+ }
+
+ public AbstractGetObjectBaseCommand variablesToInclude(String variableToInclude)
+ {
+ setVariablesToInclude(variableToInclude);
+ return this;
+ }
+
+ public AbstractGetObjectBaseCommand includeAllVariables(boolean includeAllVariables)
+ {
+ setIncludeAllVariables( includeAllVariables );
+ return this;
+ }
+
}
\ No newline at end of file
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/AbstractProcessInstanceBaseCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/AbstractProcessInstanceBaseCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/AbstractProcessInstanceBaseCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -112,19 +112,17 @@
public abstract ProcessInstance execute(ProcessInstance processInstance);
- public AbstractProcessInstanceBaseCommand setProcessInstanceIds(long[] processInstanceIds)
+ public void setProcessInstanceIds(long[] processInstanceIds)
{
this.operateOnSingleObject = false;
this.processInstanceIds = processInstanceIds;
- return this;
}
- public AbstractProcessInstanceBaseCommand setProcessInstanceId(long processInstanceId)
+ public void setProcessInstanceId(long processInstanceId)
{
this.operateOnSingleObject = true;
this.processInstanceIds = new long[1];
- this.processInstanceIds[0] = processInstanceId;
- return this;
+ this.processInstanceIds[0] = processInstanceId;
}
/**
@@ -153,10 +151,9 @@
return processName;
}
- public AbstractProcessInstanceBaseCommand setProcessName(String processName)
+ public void setProcessName(String processName)
{
this.processName = processName;
- return this;
}
public int getProcessVersion()
@@ -164,10 +161,9 @@
return processVersion;
}
- public AbstractProcessInstanceBaseCommand setProcessVersion(int processVersion)
+ public void setProcessVersion(int processVersion)
{
this.processVersion = processVersion;
- return this;
}
public long[] getProcessInstanceIds()
@@ -180,10 +176,40 @@
return onlyRunning;
}
- public AbstractProcessInstanceBaseCommand setOnlyRunning(boolean onlyRunning)
+ public void setOnlyRunning(boolean onlyRunning)
{
this.onlyRunning = onlyRunning;
+ }
+
+ // methods for fluent programming
+
+ public AbstractProcessInstanceBaseCommand processInstanceIds(long[] processInstanceIds)
+ {
+ setProcessInstanceIds( processInstanceIds );
return this;
}
+ public AbstractProcessInstanceBaseCommand processInstanceId(long processInstanceId)
+ {
+ setProcessInstanceId(processInstanceId);
+ return this;
+ }
+
+ public AbstractProcessInstanceBaseCommand processName(String processName)
+ {
+ setProcessName( processName );
+ return this;
+ }
+
+ public AbstractProcessInstanceBaseCommand processVersion(int processVersion)
+ {
+ setProcessVersion( processVersion );
+ return this;
+ }
+
+ public AbstractProcessInstanceBaseCommand onlyRunning(boolean onlyRunning)
+ {
+ setOnlyRunning(onlyRunning);
+ return this;
+ }
}
\ No newline at end of file
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/AbstractTokenBaseCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/AbstractTokenBaseCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/AbstractTokenBaseCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -105,40 +105,19 @@
public abstract Object execute(Token token);
- public AbstractTokenBaseCommand setTokenIds(long[] tokenIds)
+ public void setTokenIds(long[] tokenIds)
{
this.operateOnSingleObject = false;
this.tokenIds = tokenIds;
- return this;
}
- public AbstractTokenBaseCommand setTokenId(long tokenId)
+ public void setTokenId(long tokenId)
{
this.operateOnSingleObject = true;
this.tokenIds = new long[1];
this.tokenIds[0] = tokenId;
- return this;
}
- public String toString() {
- if (processName!=null && stateName!=null) {
- return this.getClass().getName()
- + " [tokenIds=" + Arrays.toString(tokenIds)
- + ";processName=" + processName
- + ";processVersion=" + (processVersion>0 ? processVersion : "NA")
- + ";stateName=" + stateName
- + getAdditionalToStringInformation()
- + "]";
- }
- else {
- return this.getClass().getName()
- + " [tokenIds=" + Arrays.toString(tokenIds)
- + ";operateOnSingleObject=" + operateOnSingleObject
- + getAdditionalToStringInformation()
- + "]";
- }
- }
-
public String getAdditionalToStringInformation() {
return "";
}
@@ -177,5 +156,55 @@
{
return tokenIds;
}
+
+ public String toString() {
+ if (processName!=null && stateName!=null) {
+ return this.getClass().getName()
+ + " [tokenIds=" + Arrays.toString(tokenIds)
+ + ";processName=" + processName
+ + ";processVersion=" + (processVersion>0 ? processVersion : "NA")
+ + ";stateName=" + stateName
+ + getAdditionalToStringInformation()
+ + "]";
+ }
+ else {
+ return this.getClass().getName()
+ + " [tokenIds=" + Arrays.toString(tokenIds)
+ + ";operateOnSingleObject=" + operateOnSingleObject
+ + getAdditionalToStringInformation()
+ + "]";
+ }
+ }
+
+ // methods for fluent programming
+ public AbstractTokenBaseCommand tokenIds(long[] tokenIds)
+ {
+ setTokenIds(tokenIds);
+ return this;
+ }
+
+ public AbstractTokenBaseCommand tokenId(long tokenId)
+ {
+ setTokenId(tokenId);
+ return this;
+ }
+
+ public AbstractTokenBaseCommand processName(String processName)
+ {
+ setProcessName(processName);
+ return this;
+ }
+
+ public AbstractTokenBaseCommand processVersion(int processVersion)
+ {
+ setProcessVersion(processVersion);
+ return this;
+ }
+
+ public AbstractTokenBaseCommand stateName(String stateName)
+ {
+ setStateName(stateName);
+ return this;
+ }
}
\ No newline at end of file
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/BatchSignalCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/BatchSignalCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/BatchSignalCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -2,7 +2,6 @@
import java.util.Date;
-import org.jbpm.JbpmContext;
import org.jbpm.graph.exe.Token;
/**
@@ -47,18 +46,16 @@
return transitionName;
}
- public BatchSignalCommand setTransitionName(String transitionName) {
+ public void setTransitionName(String transitionName) {
this.transitionName = transitionName;
- return this;
}
public Date getInStateAtLeastSince() {
return inStateAtLeastSince;
}
- public BatchSignalCommand setInStateAtLeastSince(Date inStateAtLeastSince) {
+ public void setInStateAtLeastSince(Date inStateAtLeastSince) {
this.inStateAtLeastSince = inStateAtLeastSince;
- return this;
}
@Override
@@ -68,4 +65,15 @@
+ ";inStateAtLeastSince=" + inStateAtLeastSince;
}
+ // methods for fluent programming
+
+ public BatchSignalCommand transitionName(String transitionName) {
+ setTransitionName(transitionName);
+ return this;
+ }
+
+ public BatchSignalCommand inStateAtLeastSince(Date inStateAtLeastSince) {
+ setInStateAtLeastSince(inStateAtLeastSince);
+ return this;
+ }
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/CancelProcessInstanceCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/CancelProcessInstanceCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/CancelProcessInstanceCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -70,10 +70,9 @@
return processInstanceId;
}
- public CancelProcessInstanceCommand setProcessInstanceId(long processInstanceId)
+ public void setProcessInstanceId(long processInstanceId)
{
this.processInstanceId = processInstanceId;
- return this;
}
/**
@@ -92,4 +91,11 @@
this.processInstanceId = processId;
}
+ // methods for fluent programming
+
+ public CancelProcessInstanceCommand processInstanceId(long processInstanceId)
+ {
+ setProcessInstanceId(processInstanceId);
+ return this;
+ }
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/CancelTokenCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/CancelTokenCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/CancelTokenCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -37,10 +37,16 @@
return tokenId;
}
- public CancelTokenCommand setTokenId(long tokenId)
+ public void setTokenId(long tokenId)
{
this.tokenId = tokenId;
+ }
+
+ // methods for fluent programming
+
+ public CancelTokenCommand tokenId(long tokenId)
+ {
+ setTokenId(tokenId);
return this;
}
-
}
\ No newline at end of file
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/CancelWorkOnTaskCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/CancelWorkOnTaskCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/CancelWorkOnTaskCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -40,10 +40,9 @@
return taskInstanceId;
}
- public CancelWorkOnTaskCommand setTaskInstanceId(long taskInstanceId)
+ public void setTaskInstanceId(long taskInstanceId)
{
this.taskInstanceId = taskInstanceId;
- return this;
}
@Override
@@ -51,5 +50,13 @@
{
return ";taskInstanceId=" + taskInstanceId;
}
+
+ // methods for fluent programming
+ public CancelWorkOnTaskCommand taskInstanceId(long taskInstanceId)
+ {
+ setTaskInstanceId(taskInstanceId);
+ return this;
+ }
+
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/ChangeProcessInstanceVersionCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/ChangeProcessInstanceVersionCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/ChangeProcessInstanceVersionCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -263,14 +263,13 @@
return nodeNameMapping;
}
- public ChangeProcessInstanceVersionCommand setNodeNameMapping(Map<String, String> nameMapping)
+ public void setNodeNameMapping(Map<String, String> nameMapping)
{
if (nameMapping == null) {
this.nodeNameMapping = new HashMap<String, String>();
} else {
this.nodeNameMapping = nameMapping;
}
- return this;
}
public int getNewVersion()
@@ -278,10 +277,9 @@
return newVersion;
}
- public ChangeProcessInstanceVersionCommand setNewVersion(int newVersion)
+ public void setNewVersion(int newVersion)
{
this.newVersion = newVersion;
- return this;
}
public Map getTaskNameMapping()
@@ -289,14 +287,13 @@
return taskNameMapping;
}
- public ChangeProcessInstanceVersionCommand setTaskNameMapping(Map<String, String> nameMapping)
+ public void setTaskNameMapping(Map<String, String> nameMapping)
{
if (nameMapping == null) {
this.taskNameMapping = new HashMap<String, String>();
} else {
this.taskNameMapping = nameMapping;
}
- return this;
}
/**
@@ -329,9 +326,27 @@
/**
* @deprecated use setNodeNameMapping instead
*/
- public ChangeProcessInstanceVersionCommand setNameMapping(Map nameMapping) {
- return setNodeNameMapping(nameMapping);
+ public void setNameMapping(Map nameMapping) {
+ setNodeNameMapping(nameMapping);
}
+ // methods for fluent programming
+ public ChangeProcessInstanceVersionCommand nodeNameMapping(Map<String, String> nameMapping)
+ {
+ setNodeNameMapping(nameMapping);
+ return this;
+ }
+
+ public ChangeProcessInstanceVersionCommand newVersion(int newVersion)
+ {
+ setNewVersion(newVersion);
+ return this;
+ }
+
+ public ChangeProcessInstanceVersionCommand taskNameMapping(Map<String, String> nameMapping)
+ {
+ setTaskNameMapping(nameMapping);
+ return this;
+ }
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/DeleteProcessDefinitionCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/DeleteProcessDefinitionCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/DeleteProcessDefinitionCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -35,6 +35,10 @@
private long id;
+ public DeleteProcessDefinitionCommand()
+ {
+ }
+
public DeleteProcessDefinitionCommand(long id)
{
super();
@@ -52,5 +56,23 @@
{
return this.getClass().getSimpleName() + " [processDefinition.id=" + id + "]";
}
+
+ public long getId()
+ {
+ return id;
+ }
+
+ public void setId(long id)
+ {
+ this.id = id;
+ }
+ // methods for fluent programming
+
+ public DeleteProcessDefinitionCommand id(long id)
+ {
+ setId(id);
+ return this;
+ }
+
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/DeployProcessCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/DeployProcessCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/DeployProcessCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -78,13 +78,12 @@
return par;
}
- public DeployProcessCommand setPar(byte[] par)
+ public void setPar(byte[] par)
{
this.par = par;
if (par == null || par.length == 0)
throw new IllegalArgumentException("Cannot process null process archive");
- return this;
}
public String getXml()
@@ -92,12 +91,26 @@
return xml;
}
- public DeployProcessCommand setXml(String xml)
+ public void setXml(String xml)
{
this.xml = xml;
if (xml == null || xml.length() == 0)
throw new IllegalArgumentException("Cannot process null process definition");
- return this;
}
+
+ // methods for fluent programming
+
+ public DeployProcessCommand xml(String xml)
+ {
+ setXml(xml);
+ return this;
+ }
+
+ public DeployProcessCommand par(byte[] par)
+ {
+ setPar(par);
+ return this;
+ }
+
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessDefinitionCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessDefinitionCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessDefinitionCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -46,10 +46,9 @@
return name;
}
- public GetProcessDefinitionCommand setName(String name)
+ public void setName(String name)
{
this.name = name;
- return this;
}
public int getVersion()
@@ -57,10 +56,9 @@
return version;
}
- public GetProcessDefinitionCommand setVersion(int version)
+ public void setVersion(int version)
{
this.version = version;
- return this;
}
@Override
@@ -70,4 +68,17 @@
+ ";version=" + version;
}
+ // methods for fluent programming
+
+ public GetProcessDefinitionCommand version(int version)
+ {
+ setVersion(version);
+ return this;
+ }
+
+ public GetProcessDefinitionCommand name(String name)
+ {
+ setName(name);
+ return this;
+ }
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessDefinitionsCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessDefinitionsCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessDefinitionsCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -50,10 +50,9 @@
return onlyLatest;
}
- public GetProcessDefinitionsCommand setOnlyLatest(boolean onlyLatest)
+ public void setOnlyLatest(boolean onlyLatest)
{
this.onlyLatest = onlyLatest;
- return this;
}
@Override
@@ -62,4 +61,11 @@
return "onlyLatest=" + onlyLatest;
}
+ // methods for fluent programming
+
+ public GetProcessDefinitionsCommand onlyLatest(boolean onlyLatest)
+ {
+ setOnlyLatest(onlyLatest);
+ return this;
+ }
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessInstanceCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessInstanceCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessInstanceCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -59,10 +59,9 @@
return processInstanceId;
}
- public GetProcessInstanceCommand setProcessInstanceId(long processInstanceId)
+ public void setProcessInstanceId(long processInstanceId)
{
this.processInstanceId = processInstanceId;
- return this;
}
public long getTaskInstanceId()
@@ -70,10 +69,9 @@
return taskInstanceId;
}
- public GetProcessInstanceCommand setTaskInstanceId(long taskInstanceId)
+ public void setTaskInstanceId(long taskInstanceId)
{
this.taskInstanceId = taskInstanceId;
- return this;
}
public long getTokenId()
@@ -81,10 +79,9 @@
return tokenId;
}
- public GetProcessInstanceCommand setTokenId(long tokenId)
+ public void setTokenId(long tokenId)
{
this.tokenId = tokenId;
- return this;
}
@Override
@@ -95,4 +92,23 @@
+ ";taskInstanceId=" + taskInstanceId;
}
+ // methods for fluent programming
+
+ public GetProcessInstanceCommand processInstanceId(long processInstanceId)
+ {
+ setProcessInstanceId(processInstanceId);
+ return this;
+ }
+
+ public GetProcessInstanceCommand taskInstanceId(long taskInstanceId)
+ {
+ setTaskInstanceId(taskInstanceId);
+ return this;
+ }
+
+ public GetProcessInstanceCommand tokenId(long tokenId)
+ {
+ setTokenId(tokenId);
+ return this;
+ }
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessInstancesCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessInstancesCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetProcessInstancesCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -157,10 +157,9 @@
return fromStartDate;
}
- public GetProcessInstancesCommand setFromStartDate(Date fromStartDate)
+ public void setFromStartDate(Date fromStartDate)
{
this.fromStartDate = fromStartDate;
- return this;
}
public boolean isOnlyRunning()
@@ -168,10 +167,9 @@
return onlyRunning;
}
- public GetProcessInstancesCommand setOnlyRunning(boolean onlyRunning)
+ public void setOnlyRunning(boolean onlyRunning)
{
this.onlyRunning = onlyRunning;
- return this;
}
/**
@@ -195,10 +193,9 @@
return processDefinitionName;
}
- public GetProcessInstancesCommand setProcessDefinitionName(String processName)
+ public void setProcessDefinitionName(String processName)
{
this.processDefinitionName = processName;
- return this;
}
public String getStateName()
@@ -206,10 +203,9 @@
return stateName;
}
- public GetProcessInstancesCommand setStateName(String stateName)
+ public void setStateName(String stateName)
{
this.stateName = stateName;
- return this;
}
public Date getUntilStartDate()
@@ -217,10 +213,9 @@
return untilStartDate;
}
- public GetProcessInstancesCommand setUntilStartDate(Date untilStartDate)
+ public void setUntilStartDate(Date untilStartDate)
{
this.untilStartDate = untilStartDate;
- return this;
}
public String getVersion()
@@ -228,10 +223,9 @@
return version;
}
- public GetProcessInstancesCommand setVersion(String version)
+ public void setVersion(String version)
{
this.version = version;
- return this;
}
public long getProcessInstanceId()
@@ -239,10 +233,9 @@
return processInstanceId;
}
- public GetProcessInstancesCommand setProcessInstanceId(long processId)
+ public void setProcessInstanceId(long processId)
{
this.processInstanceId = processId;
- return this;
}
/**
@@ -273,4 +266,47 @@
+ ";onlyRunning=" + onlyRunning;
}
+ // methods for fluent programming
+
+ public GetProcessInstancesCommand fromStartDate(Date fromStartDate)
+ {
+ setFromStartDate(fromStartDate);
+ return this;
+ }
+
+ public GetProcessInstancesCommand onlyRunning(boolean onlyRunning)
+ {
+ setOnlyRunning(onlyRunning);
+ return this;
+ }
+
+ public GetProcessInstancesCommand processDefinitionName(String processName)
+ {
+ setProcessDefinitionName(processName);
+ return this;
+ }
+
+ public GetProcessInstancesCommand stateName(String stateName)
+ {
+ setStateName(stateName);
+ return this;
+ }
+
+ public GetProcessInstancesCommand untilStartDate(Date untilStartDate)
+ {
+ setUntilStartDate(untilStartDate);
+ return this;
+ }
+
+ public GetProcessInstancesCommand version(String version)
+ {
+ setVersion(version);
+ return this;
+ }
+
+ public GetProcessInstancesCommand processInstanceId(long processId)
+ {
+ setProcessInstanceId(processId);
+ return this;
+ }
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetTaskInstanceCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetTaskInstanceCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetTaskInstanceCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -100,10 +100,9 @@
return taskInstanceId;
}
- public GetTaskInstanceCommand setTaskInstanceId(long taskInstanceId)
+ public void setTaskInstanceId(long taskInstanceId)
{
this.taskInstanceId = taskInstanceId;
- return this;
}
public long getTokenId()
@@ -111,10 +110,9 @@
return tokenId;
}
- public GetTaskInstanceCommand setTokenId(long tokenId)
+ public void setTokenId(long tokenId)
{
this.tokenId = tokenId;
- return this;
}
public long getProcessInstanceId()
@@ -122,10 +120,9 @@
return processInstanceId;
}
- public GetTaskInstanceCommand setProcessInstanceId(long processInstanceId)
+ public void setProcessInstanceId(long processInstanceId)
{
this.processInstanceId = processInstanceId;
- return this;
}
@Override
@@ -135,4 +132,24 @@
+ ";tokenId=" + tokenId
+ ";taskInstanceId=" + taskInstanceId;
}
+
+ // methods for fluent programming
+
+ public GetTaskInstanceCommand taskInstanceId(long taskInstanceId)
+ {
+ setTaskInstanceId(taskInstanceId);
+ return this;
+ }
+
+ public GetTaskInstanceCommand tokenId(long tokenId)
+ {
+ setTokenId(tokenId);
+ return this;
+ }
+
+ public GetTaskInstanceCommand processInstanceId(long processInstanceId)
+ {
+ setProcessInstanceId(processInstanceId);
+ return this;
+ }
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetTaskListCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetTaskListCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/GetTaskListCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -84,16 +84,14 @@
return actor;
}
- public GetTaskListCommand setActor(String actor)
+ public void setActor(String actor)
{
this.actor = new String[] { actor };
- return this;
}
- public GetTaskListCommand setActor(String[] actor)
+ public void setActor(String[] actor)
{
this.actor = actor;
- return this;
}
@Override
@@ -102,4 +100,18 @@
return "actors=" + Arrays.toString( actor );
}
+ // methods for fluent programming
+
+ public GetTaskListCommand actor(String actor)
+ {
+ this.actor = new String[] { actor };
+ return this;
+ }
+
+ public GetTaskListCommand actor(String[] actor)
+ {
+ this.actor = actor;
+ return this;
+ }
+
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/NewProcessInstanceCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/NewProcessInstanceCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/NewProcessInstanceCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -121,10 +121,9 @@
return actorId;
}
- public NewProcessInstanceCommand setActorId(String actorId)
+ public void setActorId(String actorId)
{
this.actorId = actorId;
- return this;
}
public long getProcessDefinitionId()
@@ -132,10 +131,9 @@
return processDefinitionId;
}
- public NewProcessInstanceCommand setProcessDefinitionId(long processId)
+ public void setProcessDefinitionId(long processId)
{
this.processDefinitionId = processId;
- return this;
}
/**
@@ -154,37 +152,49 @@
this.processDefinitionId = processId;
}
+ /**
+ * @deprecated use getProcessDefinitionName instead
+ */
public String getProcessName()
{
return processDefinitionName;
}
- public NewProcessInstanceCommand setProcessName(String processName)
+ /**
+ * @deprecated use setProcessDefinitionName instead
+ */
+ public void setProcessName(String processName)
{
this.processDefinitionName = processName;
- return this;
}
-
+
public boolean isCreateStartTask()
{
return createStartTask;
}
- public NewProcessInstanceCommand setCreateStartTask(boolean createStartTask)
+ public void setCreateStartTask(boolean createStartTask)
{
this.createStartTask = createStartTask;
- return this;
}
public Map getVariables()
{
return variables;
}
+ public String getProcessDefinitionName()
+ {
+ return processDefinitionName;
+ }
- public NewProcessInstanceCommand setVariables(Map variables)
+ public void setProcessDefinitionName(String processDefinitionName)
{
+ this.processDefinitionName = processDefinitionName;
+ }
+
+ public void setVariables(Map variables)
+ {
this.variables = variables;
- return this;
}
public String getKey()
@@ -192,10 +202,9 @@
return key;
}
- public NewProcessInstanceCommand setKey(String key)
+ public void setKey(String key)
{
this.key = key;
- return this;
}
@Override
@@ -207,5 +216,44 @@
+ ";businessKey=" + key
// TODO: not sure how this is
+ ";variables=" + variables;
- }
+ }
+
+ // methods for fluent programming
+
+ public NewProcessInstanceCommand actorId(String actorId)
+ {
+ setActorId(actorId);
+ return this;
+ }
+
+ public NewProcessInstanceCommand processDefinitionId(long processId)
+ {
+ setProcessDefinitionId(processId);
+ return this;
+ }
+
+ public NewProcessInstanceCommand processDefinitionName(String processName)
+ {
+ setProcessDefinitionName(processName);
+ return this;
+ }
+
+ public NewProcessInstanceCommand createStartTask(boolean createStartTask)
+ {
+ setCreateStartTask(createStartTask);
+ return this;
+ }
+
+ public NewProcessInstanceCommand variables(Map variables)
+ {
+ setVariables(variables);
+ return this;
+ }
+
+ public NewProcessInstanceCommand key(String key)
+ {
+ setKey(key);
+ return this;
+ }
+
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/SignalCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/SignalCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/SignalCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -121,10 +121,9 @@
return tokenId;
}
- public SignalCommand setTokenId(long tokenId)
+ public void setTokenId(long tokenId)
{
this.tokenId = tokenId;
- return this;
}
public String getTransitionName()
@@ -132,10 +131,9 @@
return transitionName;
}
- public SignalCommand setTransitionName(String transitionName)
+ public void setTransitionName(String transitionName)
{
this.transitionName = transitionName;
- return this;
}
public Map getVariables()
@@ -143,10 +141,9 @@
return variables;
}
- public SignalCommand setVariables(Map variables)
+ public void setVariables(Map variables)
{
this.variables = variables;
- return this;
}
public String getExpectedStateName()
@@ -154,10 +151,9 @@
return expectedStateName;
}
- public SignalCommand setExpectedStateName(String expectedStateName)
+ public void setExpectedStateName(String expectedStateName)
{
this.expectedStateName = expectedStateName;
- return this;
}
@Override
@@ -170,4 +166,29 @@
+ ";variables=" + variables;
}
+ // methods for fluent programming
+
+ public SignalCommand tokenId(long tokenId)
+ {
+ setTokenId(tokenId);
+ return this;
+ }
+
+ public SignalCommand transitionName(String transitionName)
+ {
+ setTransitionName(transitionName);
+ return this;
+ }
+
+ public SignalCommand variables(Map variables)
+ {
+ setVariables(variables);
+ return this;
+ }
+
+ public SignalCommand expectedStateName(String expectedStateName)
+ {
+ setExpectedStateName(expectedStateName);
+ return this;
+ }
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/StartProcessInstanceCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/StartProcessInstanceCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/StartProcessInstanceCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -40,10 +40,9 @@
return startTransitionName;
}
- public StartProcessInstanceCommand setStartTransitionName(String startTransitionName)
+ public void setStartTransitionName(String startTransitionName)
{
this.startTransitionName = startTransitionName;
- return this;
}
@Override
@@ -52,5 +51,13 @@
return super.getAdditionalToStringInformation()
+ ";startTransitionName=" + startTransitionName;
}
+
+ // methods for fluent programming
+ public StartProcessInstanceCommand startTransitionName(String startTransitionName)
+ {
+ setStartTransitionName(startTransitionName);
+ return this;
+ }
+
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/StartWorkOnTaskCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/StartWorkOnTaskCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/StartWorkOnTaskCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -54,10 +54,9 @@
return overwriteSwimlane;
}
- public StartWorkOnTaskCommand setOverwriteSwimlane(boolean overwriteSwimlane)
+ public void setOverwriteSwimlane(boolean overwriteSwimlane)
{
this.overwriteSwimlane = overwriteSwimlane;
- return this;
}
public long getTaskInstanceId()
@@ -65,16 +64,14 @@
return taskInstanceId;
}
- public StartWorkOnTaskCommand setTaskInstanceId(long taskInstanceId)
+ public void setTaskInstanceId(long taskInstanceId)
{
this.taskInstanceId = taskInstanceId;
- return this;
}
- public StartWorkOnTaskCommand setActorId(String actorId)
+ public void setActorId(String actorId)
{
this.actorId = actorId;
- return this;
}
public String getActorId()
@@ -88,5 +85,25 @@
return "tokenId=" + taskInstanceId
+ ";transitionName=" + actorId
+ ";processDefinitionName=" + overwriteSwimlane;
- }
+ }
+
+ // methods for fluent programming
+
+ public StartWorkOnTaskCommand overwriteSwimlane(boolean overwriteSwimlane)
+ {
+ setOverwriteSwimlane(overwriteSwimlane);
+ return this;
+ }
+
+ public StartWorkOnTaskCommand taskInstanceId(long taskInstanceId)
+ {
+ setTaskInstanceId(taskInstanceId);
+ return this;
+ }
+
+ public StartWorkOnTaskCommand actorId(String actorId)
+ {
+ setActorId(actorId);
+ return this;
+ }
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/TaskInstanceEndCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/TaskInstanceEndCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/TaskInstanceEndCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -95,10 +95,9 @@
return taskInstanceId;
}
- public TaskInstanceEndCommand setTaskInstanceId(long taskInstanceId)
+ public void setTaskInstanceId(long taskInstanceId)
{
this.taskInstanceId = taskInstanceId;
- return this;
}
public String getTransitionName()
@@ -106,10 +105,9 @@
return transitionName;
}
- public TaskInstanceEndCommand setTransitionName(String transitionName)
+ public void setTransitionName(String transitionName)
{
this.transitionName = transitionName;
- return this;
}
public Map getVariables()
@@ -117,10 +115,9 @@
return variables;
}
- public TaskInstanceEndCommand setVariables(Map variables)
+ public void setVariables(Map variables)
{
this.variables = variables;
- return this;
}
@Override
@@ -131,4 +128,23 @@
+ ";variables=" + variables;
}
+ // methods for fluent programming
+
+ public TaskInstanceEndCommand taskInstanceId(long taskInstanceId)
+ {
+ setTaskInstanceId(taskInstanceId);
+ return this;
+ }
+
+ public TaskInstanceEndCommand transitionName(String transitionName)
+ {
+ setTransitionName(transitionName);
+ return this;
+ }
+
+ public TaskInstanceEndCommand variables(Map variables)
+ {
+ setVariables(variables);
+ return this;
+ }
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/UnlockTokenCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/UnlockTokenCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/UnlockTokenCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -40,9 +40,15 @@
return lockOwner;
}
- public UnlockTokenCommand setLockOwner(String lockOwner) {
+ public void setLockOwner(String lockOwner) {
this.lockOwner = lockOwner;
- return this;
}
+ // methods for fluent programming
+
+ public UnlockTokenCommand lockOwner(String lockOwner) {
+ setLockOwner(lockOwner);
+ return this;
+ }
+
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/VariablesCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/VariablesCommand.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/VariablesCommand.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -67,10 +67,9 @@
return taskInstanceId;
}
- public VariablesCommand setTaskInstanceId(long taskInstanceId)
+ public void setTaskInstanceId(long taskInstanceId)
{
this.taskInstanceId = taskInstanceId;
- return this;
}
public long getTokenId()
@@ -78,10 +77,9 @@
return tokenId;
}
- public VariablesCommand setTokenId(long tokenId)
+ public void setTokenId(long tokenId)
{
this.tokenId = tokenId;
- return this;
}
public Map getVariables()
@@ -89,10 +87,9 @@
return variables;
}
- public VariablesCommand setVariables(Map variables)
+ public void setVariables(Map variables)
{
this.variables = variables;
- return this;
}
@Override
@@ -103,4 +100,24 @@
+ ";variables=" + variables;
}
+ // methods for fluent programming
+
+ public VariablesCommand taskInstanceId(long taskInstanceId)
+ {
+ setTaskInstanceId(taskInstanceId);
+ return this;
+ }
+
+ public VariablesCommand tokenId(long tokenId)
+ {
+ setTokenId(tokenId);
+ return this;
+ }
+
+ public VariablesCommand variables(Map variables)
+ {
+ setVariables(variables);
+ return this;
+ }
+
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/command/ChangeProcessInstanceVersionCommandTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/command/ChangeProcessInstanceVersionCommandTest.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/command/ChangeProcessInstanceVersionCommandTest.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -116,7 +116,7 @@
// now change all process instances to most current version
try
{
- new ChangeProcessInstanceVersionCommand().setProcessName("TestChangeVersion").execute(jbpmContext);
+ new ChangeProcessInstanceVersionCommand().processName("TestChangeVersion").execute(jbpmContext);
fail("Exception expected, saying that state2 is missing in new version");
}
catch (JbpmException ex)
@@ -127,7 +127,7 @@
HashMap nameMap = new HashMap();
nameMap.put("state2", "state2b");
// now supply a mapping for the missing node
- new ChangeProcessInstanceVersionCommand().setNodeNameMapping(nameMap).setProcessName("TestChangeVersion").execute(jbpmContext);
+ new ChangeProcessInstanceVersionCommand().nodeNameMapping(nameMap).processName("TestChangeVersion").execute(jbpmContext);
newTransaction();
pi1 = graphSession.loadProcessInstance(pi1.getId());
@@ -215,7 +215,7 @@
// now change all process instances to most current version
try
{
- new ChangeProcessInstanceVersionCommand().setProcessInstanceId(pi1.getId()).execute(jbpmContext);
+ new ChangeProcessInstanceVersionCommand().processInstanceId(pi1.getId()).execute(jbpmContext);
fail("Exception expected, saying that phase2 is missing in new version");
}
catch (JbpmException ex)
@@ -226,7 +226,7 @@
HashMap nameMap = new HashMap();
nameMap.put("path2", "path2b");
// now supply a mapping for the missing node
- new ChangeProcessInstanceVersionCommand().setNodeNameMapping(nameMap).setProcessInstanceId(pi1.getId()).execute(jbpmContext);
+ new ChangeProcessInstanceVersionCommand().nodeNameMapping(nameMap).processInstanceId(pi1.getId()).execute(jbpmContext);
newTransaction();
@@ -314,9 +314,9 @@
// now supply a mapping for the missing node
new ChangeProcessInstanceVersionCommand()
- .setNodeNameMapping(nodeNameMap)
- .setTaskNameMapping(taskNameMap)
- .setProcessInstanceId(pi1.getId())
+ .nodeNameMapping(nodeNameMap)
+ .taskNameMapping(taskNameMap)
+ .processInstanceId(pi1.getId())
.execute(jbpmContext);
newTransaction();
@@ -421,7 +421,7 @@
// process instance 1 can me updated, state names haven't changed in this path:
new ChangeProcessInstanceVersionCommand()
- .setProcessInstanceId(pi1.getId())
+ .processInstanceId(pi1.getId())
.execute(jbpmContext);
HashMap nameMap = new HashMap();
@@ -431,9 +431,9 @@
try
{
new ChangeProcessInstanceVersionCommand()
- .setNodeNameMapping(nameMap)
- .setTaskNameMapping(nameMap)
- .setProcessName("testTaskInstances")
+ .nodeNameMapping(nameMap)
+ .taskNameMapping(nameMap)
+ .processName("testTaskInstances")
.execute(jbpmContext);
// fail because task2 is not mapped
fail("Exception expected, saying that theTask2b is missing in new version");
@@ -446,9 +446,9 @@
// now supply a mapping for the missing task
nameMap.put("theTask2", "theTask2b");
new ChangeProcessInstanceVersionCommand()
- .setNodeNameMapping(nameMap)
- .setTaskNameMapping(nameMap)
- .setProcessName("testTaskInstances")
+ .nodeNameMapping(nameMap)
+ .taskNameMapping(nameMap)
+ .processName("testTaskInstances")
.execute(jbpmContext);
newTransaction();
@@ -527,8 +527,8 @@
HashMap nameMap = new HashMap();
nameMap.put("timer1", "timer2");
new ChangeProcessInstanceVersionCommand()
- .setNodeNameMapping(nameMap)
- .setProcessInstanceId(pi1.getId())
+ .nodeNameMapping(nameMap)
+ .processInstanceId(pi1.getId())
.execute(jbpmContext);
// load changed stuff
@@ -602,9 +602,9 @@
nameMap.put("timer1", "timer2");
nameMap.put("myTask", "myTask2");
new ChangeProcessInstanceVersionCommand()
- .setNodeNameMapping(nameMap)
- .setTaskNameMapping(nameMap)
- .setProcessInstanceId(pi1.getId())
+ .nodeNameMapping(nameMap)
+ .taskNameMapping(nameMap)
+ .processInstanceId(pi1.getId())
.execute(jbpmContext);
// load changed stuff
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/command/ProcessInstanceCommandTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/command/ProcessInstanceCommandTest.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/command/ProcessInstanceCommandTest.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -119,7 +119,7 @@
}
// execute SuspendProcessInstanceCommand
- new SuspendProcessInstanceCommand().setProcessInstanceId(processInstance.getId()).execute(jbpmContext);
+ new SuspendProcessInstanceCommand().processInstanceId(processInstance.getId()).execute(jbpmContext);
// and verify
assertTrue(processInstance.isSuspended());
@@ -142,7 +142,7 @@
}
// execute ResumeProcessInstanceCommand
- new ResumeProcessInstanceCommand().setProcessInstanceId(processInstance.getId()).execute(jbpmContext);
+ new ResumeProcessInstanceCommand().processInstanceId(processInstance.getId()).execute(jbpmContext);
// and verify
assertFalse(processInstance.isSuspended());
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/command/TokenCommandTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/command/TokenCommandTest.java 2008-12-15 09:51:19 UTC (rev 3385)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/command/TokenCommandTest.java 2008-12-15 10:16:26 UTC (rev 3386)
@@ -45,7 +45,7 @@
}
// unlocking without owner is a force unlock -> works
- new UnlockTokenCommand().setTokenId(tokenId).execute(jbpmContext);
+ new UnlockTokenCommand().tokenId(tokenId).execute(jbpmContext);
// Token token = jbpmContext.loadTokenForUpdate(processInstance.getRootToken().getId());
// token.foreUnlock();
@@ -53,14 +53,14 @@
processInstance = saveAndReload(processInstance);
processInstance.getRootToken().lock("TEST-OWNER");
processInstance = saveAndReload(processInstance);
- new UnlockTokenCommand().setLockOwner("TEST-OWNER").setTokenId(tokenId).execute(jbpmContext);
+ new UnlockTokenCommand().lockOwner("TEST-OWNER").tokenId(tokenId).execute(jbpmContext);
// unlocking with wrong owner fails
processInstance = saveAndReload(processInstance);
processInstance.getRootToken().lock("TEST-OWNER");
processInstance = saveAndReload(processInstance);
try {
- new UnlockTokenCommand().setLockOwner("OTHER-OWNER").setTokenId(tokenId).execute(jbpmContext);
+ new UnlockTokenCommand().lockOwner("OTHER-OWNER").tokenId(tokenId).execute(jbpmContext);
fail("'OTHER-OWNER' can't unlock token exception expected");
}
catch (JbpmException ex) {
17 years, 4 months
JBoss JBPM SVN: r3385 - jbpm3/branches.
by do-not-reply@jboss.org
Author: tkirby
Date: 2008-12-15 04:51:19 -0500 (Mon, 15 Dec 2008)
New Revision: 3385
Added:
jbpm3/branches/jpdl-3.2.2-SOA-4.2/
Log:
replacing soa 3.2.2 branch
Copied: jbpm3/branches/jpdl-3.2.2-SOA-4.2 (from rev 3384, jbpm3/tags/jpdl-3.2.2-SOA-4.2.0.CP03)
17 years, 4 months