JBoss JBPM SVN: r2500 - in jbpm3/trunk/modules/core/src: test/java/org/jbpm/instantiation and 1 other directory.
by do-not-reply@jboss.org
Author: camunda
Date: 2008-10-07 10:20:14 -0400 (Tue, 07 Oct 2008)
New Revision: 2500
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassloadersTest.java
Log:
fixed correct cleanup in tests (missing jbpmContext.close)
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java 2008-10-07 14:08:05 UTC (rev 2499)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java 2008-10-07 14:20:14 UTC (rev 2500)
@@ -72,8 +72,12 @@
} else if (jbpmClassloader.equals("context")) {
return Thread.currentThread().getContextClassLoader();
} else if (jbpmClassloader.equals("custom")) {
- String jbpmClassloaderClassname = JbpmConfiguration.Configs.getString("jbpm.customClassLoader.className");
+ String jbpmClassloaderClassname = null;
try {
+ if (!JbpmConfiguration.Configs.hasObject("jbpm.customClassLoader.className")) {
+ throw new JbpmException("'jbpm.classloader' property set to 'custom' but 'jbpm.customClassLoader.className' is empty!");
+ }
+ jbpmClassloaderClassname = JbpmConfiguration.Configs.getString("jbpm.customClassLoader.className");
if (jbpmClassloaderClassname == null) {
throw new JbpmException("'jbpm.classloader' property set to 'custom' but 'jbpm.customClassLoader.className' is empty!");
}
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassloadersTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassloadersTest.java 2008-10-07 14:08:05 UTC (rev 2499)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassloadersTest.java 2008-10-07 14:20:14 UTC (rev 2500)
@@ -23,6 +23,7 @@
import org.jbpm.AbstractJbpmTestCase;
import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmConfigurationTestHelper;
import org.jbpm.JbpmContext;
import org.jbpm.graph.def.ProcessDefinition;
@@ -35,7 +36,7 @@
* @author bernd.ruecker(a)camunda.com
*/
public class ConfigurableClassloadersTest extends AbstractJbpmTestCase {
-
+
public void testDefaultBehavior() {
JbpmConfiguration.getInstance();
ClassLoader processClassLoader = JbpmConfiguration.getProcessClassLoader(null);
@@ -107,6 +108,8 @@
fail("we should get an exception because custom class loader class not specified");
}
catch (Exception ex) {}
+
+ jbpmContext.close();
jbpmConfiguration.close();
}
17 years, 6 months
JBoss JBPM SVN: r2499 - jbpm3/trunk/modules/core/src/test/java/org/jbpm/instantiation.
by do-not-reply@jboss.org
Author: camunda
Date: 2008-10-07 10:08:05 -0400 (Tue, 07 Oct 2008)
New Revision: 2499
Modified:
jbpm3/trunk/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassloadersTest.java
Log:
typo in classname of test ProcessClassLoaderFactory
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassloadersTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassloadersTest.java 2008-10-07 14:02:30 UTC (rev 2498)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassloadersTest.java 2008-10-07 14:08:05 UTC (rev 2499)
@@ -64,7 +64,7 @@
" <jbpm-context>" +
" </jbpm-context>" +
" <string name='jbpm.classLoader' value='jbpm' /> " +
- " <bean name='jbpm.processClassLoader' class='org.jbpm.instantiation.ProcessClassLoaderFactoryTest$TestProcessClassLoaderFactory' singelton='true' />" +
+ " <bean name='jbpm.processClassLoader' class='org.jbpm.instantiation.ConfigurableClassloadersTest$TestProcessClassLoaderFactory' singelton='true' />" +
"</jbpm-configuration>"
);
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
@@ -116,7 +116,7 @@
" <jbpm-context>" +
" </jbpm-context>" +
" <string name='jbpm.classLoader' value='custom' /> " +
- " <string name='jbpm.customClassLoader.className' value='org.jbpm.instantiation.ProcessClassLoaderFactoryTest$MyClassLoader' />" +
+ " <string name='jbpm.customClassLoader.className' value='org.jbpm.instantiation.ConfigurableClassloadersTest$MyClassLoader' />" +
"</jbpm-configuration>"
);
JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
17 years, 6 months
JBoss JBPM SVN: r2498 - in jbpm3/trunk/modules/core/src: main/java/org/jbpm/configuration and 10 other directories.
by do-not-reply@jboss.org
Author: camunda
Date: 2008-10-07 10:02:30 -0400 (Tue, 07 Oct 2008)
New Revision: 2498
Added:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/instantiation/DefaultProcessClassLoaderFactory.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/instantiation/ProcessClassLoaderFactory.java
jbpm3/trunk/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassloadersTest.java
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryParser.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/context/exe/converter/SerializableToByteArrayConverter.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Action.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/node/Decision.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/instantiation/Delegation.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/mail/Mail.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/def/TaskController.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskMgmtInstance.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/util/XmlUtil.java
jbpm3/trunk/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
Log:
JBPM-1148
Made classloader configurable in jbpm.cfg.xml
Introduced getJbpmConfigurationStream as special method to load the "jbpm.cfg.xml" (NOT with the configured classloader, otherwise we get an endless loop)
Introduced ProcessClassLoaderFactory, configurable in jbpm.cfg.xml
(see https://jira.jboss.org/jira/browse/JBPM-1148)
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java 2008-10-07 11:37:40 UTC (rev 2497)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/JbpmConfiguration.java 2008-10-07 14:02:30 UTC (rev 2498)
@@ -36,6 +36,10 @@
import org.jbpm.configuration.ObjectFactoryParser;
import org.jbpm.configuration.ObjectInfo;
import org.jbpm.configuration.ValueInfo;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.instantiation.DefaultProcessClassLoaderFactory;
+import org.jbpm.instantiation.ProcessClassLoader;
+import org.jbpm.instantiation.ProcessClassLoaderFactory;
import org.jbpm.job.executor.JobExecutor;
import org.jbpm.persistence.db.DbPersistenceServiceFactory;
import org.jbpm.persistence.db.StaleObjectLogConfigurer;
@@ -292,7 +296,7 @@
try
{
log.info("using jbpm configuration resource '" + resource + "'");
- InputStream jbpmCfgXmlStream = ClassLoaderUtil.getStream(resource);
+ InputStream jbpmCfgXmlStream = ClassLoaderUtil.getJbpmConfigurationStream(resource);
// if a custom resource is to be used, but is not found in the classpath
// log a warning (otherwise, users who want to load custom stuff
@@ -412,7 +416,7 @@
log.debug("creating jbpm configuration from resource '" + resource + "'");
if (resource != null)
{
- inputStream = ClassLoaderUtil.getStream(resource);
+ inputStream = ClassLoaderUtil.getJbpmConfigurationStream(resource);
}
ObjectFactory objectFactory = parseObjectFactory(inputStream);
return createJbpmConfiguration(objectFactory);
@@ -450,7 +454,19 @@
}
return serviceFactory;
}
+
+ public static ClassLoader getProcessClassLoader(ProcessDefinition processDefinition) {
+ ProcessClassLoaderFactory factory = null;
+ if (Configs.hasObject("jbpm.processClassLoader")) {
+ factory = (ProcessClassLoaderFactory) Configs.getObject("jbpm.processClassLoader");
+ }
+ else {
+ factory = new DefaultProcessClassLoaderFactory();
+ }
+ return factory.getProcessClassLoader(processDefinition);
+ }
+
/**
* gives the jbpm domain model access to configuration information via the current JbpmContext.
*/
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java 2008-10-07 11:37:40 UTC (rev 2497)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryImpl.java 2008-10-07 14:02:30 UTC (rev 2498)
@@ -37,7 +37,7 @@
private static final long serialVersionUID = 1L;
- ClassLoader classLoader = ClassLoaderUtil.getClassLoader();
+ ClassLoader classLoader = null; // lazy load it later! See below..
List objectInfos = null;
Map namedObjectInfos = null;
Map singletons = new HashMap();
@@ -158,6 +158,12 @@
}
Class loadClass(String className) {
+ // "lazy load" classloader, shouldn't be loaded too early
+ // because if jbpm.cfg.xml is not yet parsed, the correct class loader
+ // may not be initialized yet.
+ if (classLoader==null) {
+ classLoader = ClassLoaderUtil.getClassLoader();
+ }
try {
return classLoader.loadClass(className);
} catch (ClassNotFoundException e) {
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryParser.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryParser.java 2008-10-07 11:37:40 UTC (rev 2497)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/configuration/ObjectFactoryParser.java 2008-10-07 14:02:30 UTC (rev 2498)
@@ -84,7 +84,7 @@
}
public static ObjectFactoryImpl parseResource(String resource) {
- Element rootElement = XmlUtil.parseXmlResource(resource).getDocumentElement();
+ Element rootElement = XmlUtil.parseXmlResource(resource, true).getDocumentElement();
return createObjectFactory(rootElement);
}
@@ -101,7 +101,7 @@
}
public void parseElementsFromResource(String resource, ObjectFactoryImpl objectFactoryImpl) {
- Element rootElement = XmlUtil.parseXmlResource(resource).getDocumentElement();
+ Element rootElement = XmlUtil.parseXmlResource(resource, true).getDocumentElement();
parseElements(rootElement, objectFactoryImpl);
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/context/exe/converter/SerializableToByteArrayConverter.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/context/exe/converter/SerializableToByteArrayConverter.java 2008-10-07 11:37:40 UTC (rev 2497)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/context/exe/converter/SerializableToByteArrayConverter.java 2008-10-07 14:02:30 UTC (rev 2498)
@@ -29,6 +29,7 @@
import java.io.ObjectOutputStream;
import java.io.Serializable;
+import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmException;
import org.jbpm.bytes.ByteArray;
import org.jbpm.context.exe.Converter;
@@ -80,7 +81,7 @@
ByteArray byteArray = (ByteArray) o;
InputStream memoryStream = new ByteArrayInputStream(byteArray.getBytes());
try {
- ObjectInputStream objectStream = new CustomLoaderObjectInputStream(memoryStream, ClassLoaderUtil.getProcessClassLoader(processDefinition));
+ ObjectInputStream objectStream = new CustomLoaderObjectInputStream(memoryStream, JbpmConfiguration.getProcessClassLoader(processDefinition));
return objectStream.readObject();
}
catch(IOException ex) {
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Action.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Action.java 2008-10-07 11:37:40 UTC (rev 2497)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Action.java 2008-10-07 14:02:30 UTC (rev 2498)
@@ -25,6 +25,7 @@
import java.util.Map;
import org.dom4j.Element;
+import org.jbpm.JbpmConfiguration;
import org.jbpm.graph.exe.ExecutionContext;
import org.jbpm.instantiation.Delegation;
import org.jbpm.jpdl.el.impl.JbpmExpressionEvaluator;
@@ -115,7 +116,7 @@
ClassLoader surroundingClassLoader = Thread.currentThread().getContextClassLoader();
try {
// set context class loader correctly for delegation class (https://jira.jboss.org/jira/browse/JBPM-1448)
- Thread.currentThread().setContextClassLoader(ClassLoaderUtil.getProcessClassLoader(processDefinition));
+ Thread.currentThread().setContextClassLoader(JbpmConfiguration.getProcessClassLoader(processDefinition));
if (referencedAction != null) {
referencedAction.execute(executionContext);
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/node/Decision.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/node/Decision.java 2008-10-07 11:37:40 UTC (rev 2497)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/node/Decision.java 2008-10-07 14:02:30 UTC (rev 2498)
@@ -27,6 +27,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.dom4j.Element;
+import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmException;
import org.jbpm.graph.def.Node;
import org.jbpm.graph.def.Transition;
@@ -76,7 +77,7 @@
ClassLoader surroundingClassLoader = Thread.currentThread().getContextClassLoader();
try {
// set context class loader correctly for delegation class (https://jira.jboss.org/jira/browse/JBPM-1448)
- Thread.currentThread().setContextClassLoader(ClassLoaderUtil.getProcessClassLoader(processDefinition));
+ Thread.currentThread().setContextClassLoader(JbpmConfiguration.getProcessClassLoader(processDefinition));
try {
if (decisionDelegation != null) {
Added: jbpm3/trunk/modules/core/src/main/java/org/jbpm/instantiation/DefaultProcessClassLoaderFactory.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/instantiation/DefaultProcessClassLoaderFactory.java (rev 0)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/instantiation/DefaultProcessClassLoaderFactory.java 2008-10-07 14:02:30 UTC (rev 2498)
@@ -0,0 +1,21 @@
+package org.jbpm.instantiation;
+
+import java.io.Serializable;
+
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.util.ClassLoaderUtil;
+
+/**
+ * Default implementation of {@link ProcessClassLoaderFactory}.
+ *
+ * @author bernd.ruecker(a)camunda.com
+ */
+public class DefaultProcessClassLoaderFactory implements ProcessClassLoaderFactory, Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ public ClassLoader getProcessClassLoader(ProcessDefinition processDefinition) {
+ // default behavior like before https://jira.jboss.org/jira/browse/JBPM-1148
+ return new ProcessClassLoader(ClassLoaderUtil.getClassLoader(), processDefinition);
+ }
+}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/instantiation/Delegation.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/instantiation/Delegation.java 2008-10-07 11:37:40 UTC (rev 2497)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/instantiation/Delegation.java 2008-10-07 14:02:30 UTC (rev 2498)
@@ -37,6 +37,7 @@
import org.dom4j.Node;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
+import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmException;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.jpdl.xml.JpdlXmlReader;
@@ -132,7 +133,7 @@
Object newInstance = null;
// find the classloader to use
- ClassLoader classLoader = ClassLoaderUtil.getProcessClassLoader(processDefinition);
+ ClassLoader classLoader = JbpmConfiguration.getProcessClassLoader(processDefinition);
// load the class that needs to be instantiated
Class clazz = null;
Added: jbpm3/trunk/modules/core/src/main/java/org/jbpm/instantiation/ProcessClassLoaderFactory.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/instantiation/ProcessClassLoaderFactory.java (rev 0)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/instantiation/ProcessClassLoaderFactory.java 2008-10-07 14:02:30 UTC (rev 2498)
@@ -0,0 +1,21 @@
+package org.jbpm.instantiation;
+
+import org.jbpm.graph.def.ProcessDefinition;
+
+/**
+ * Factory to retrieve the Process{@link ClassLoader} which is then used
+ * to load delegation classes used by the process.
+ *
+ * Default is the build in {@link ProcessClassLoader}, which
+ * tries to load the classes from the jbpm database first.
+ *
+ * Can be configured by setting the property <b>'jbpm.processClassLoader'</b>
+ * in the jbpm.cfg.xml to the class name of the custom class loader.
+ *
+ * @author bernd.ruecker(a)camunda.com
+ */
+public interface ProcessClassLoaderFactory {
+
+ public ClassLoader getProcessClassLoader(ProcessDefinition processDefinition);
+
+}
\ No newline at end of file
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/mail/Mail.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/mail/Mail.java 2008-10-07 11:37:40 UTC (rev 2497)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/mail/Mail.java 2008-10-07 14:02:30 UTC (rev 2498)
@@ -273,7 +273,7 @@
if (templates==null) {
templates = new HashMap();
String mailTemplatesResource = JbpmConfiguration.Configs.getString("resource.mail.templates");
- org.w3c.dom.Element mailTemplatesElement = XmlUtil.parseXmlResource(mailTemplatesResource).getDocumentElement();
+ org.w3c.dom.Element mailTemplatesElement = XmlUtil.parseXmlResource(mailTemplatesResource, false).getDocumentElement();
List mailTemplateElements = XmlUtil.elements(mailTemplatesElement, "mail-template");
Iterator iter = mailTemplateElements.iterator();
while (iter.hasNext()) {
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/def/TaskController.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/def/TaskController.java 2008-10-07 11:37:40 UTC (rev 2497)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/def/TaskController.java 2008-10-07 14:02:30 UTC (rev 2498)
@@ -27,11 +27,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jbpm.JbpmConfiguration;
import org.jbpm.context.def.VariableAccess;
import org.jbpm.context.exe.ContextInstance;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;
import org.jbpm.instantiation.Delegation;
+import org.jbpm.instantiation.ProcessClassLoaderFactory;
import org.jbpm.instantiation.UserCodeInterceptorConfig;
import org.jbpm.taskmgmt.exe.TaskInstance;
import org.jbpm.util.ClassLoaderUtil;
@@ -73,8 +75,8 @@
public void initializeVariables(TaskInstance taskInstance) {
ClassLoader surroundingClassLoader = Thread.currentThread().getContextClassLoader();
try {
- // set context class loader correctly for delegation class (https://jira.jboss.org/jira/browse/JBPM-1448)
- Thread.currentThread().setContextClassLoader(ClassLoaderUtil.getProcessClassLoader(taskInstance.getTask().getProcessDefinition()));
+ // set context class loader correctly for delegation class (https://jira.jboss.org/jira/browse/JBPM-1448)
+ Thread.currentThread().setContextClassLoader(JbpmConfiguration.getProcessClassLoader(taskInstance.getTask().getProcessDefinition()));
if (taskControllerDelegation != null) {
TaskControllerHandler taskControllerHandler = (TaskControllerHandler) taskControllerDelegation.instantiate();
@@ -122,7 +124,7 @@
ClassLoader surroundingClassLoader = Thread.currentThread().getContextClassLoader();
try {
// set context class loader correctly for delegation class (https://jira.jboss.org/jira/browse/JBPM-1448)
- Thread.currentThread().setContextClassLoader(ClassLoaderUtil.getProcessClassLoader(taskInstance.getTask().getProcessDefinition()));
+ Thread.currentThread().setContextClassLoader(JbpmConfiguration.getProcessClassLoader(taskInstance.getTask().getProcessDefinition()));
if (taskControllerDelegation != null) {
TaskControllerHandler taskControllerHandler = (TaskControllerHandler) taskControllerDelegation.instantiate();
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskMgmtInstance.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskMgmtInstance.java 2008-10-07 11:37:40 UTC (rev 2497)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskMgmtInstance.java 2008-10-07 14:02:30 UTC (rev 2498)
@@ -268,7 +268,7 @@
ClassLoader surroundingClassLoader = Thread.currentThread().getContextClassLoader();
try {
// set context class loader correctly for delegation class (https://jira.jboss.org/jira/browse/JBPM-1448)
- Thread.currentThread().setContextClassLoader(ClassLoaderUtil.getProcessClassLoader(executionContext.getProcessDefinition()));
+ Thread.currentThread().setContextClassLoader(JbpmConfiguration.getProcessClassLoader(executionContext.getProcessDefinition()));
// instantiate the assignment handler
AssignmentHandler assignmentHandler = (AssignmentHandler) assignmentDelegation.instantiate();
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java 2008-10-07 11:37:40 UTC (rev 2497)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/util/ClassLoaderUtil.java 2008-10-07 14:02:30 UTC (rev 2498)
@@ -25,9 +25,11 @@
import java.io.InputStream;
import java.util.Properties;
+import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmException;
import org.jbpm.graph.def.ProcessDefinition;
import org.jbpm.instantiation.ProcessClassLoader;
+import org.jbpm.instantiation.ProcessClassLoaderFactory;
/**
* provides centralized classloader lookup.
@@ -45,56 +47,90 @@
throw new JbpmException("class not found '"+className+"'", e);
}
}
-
+
+ /**
+ * returns the {@link ClassLoader} which is used in jbpm.
+ * Can be configured in jbpm.cfg.xml by the property
+ * <b>'jbpm.classloader'</b>
+ *
+ * <td>
+ * <li>'jbpm': (default value) uses the {@link ClassLoaderUtil}.class.getClassLoader()
+ * {@link ClassLoader}. This was the only behavior available before <a href="https://jira.jboss.org/jira/browse/JBPM-1148">JBPM-1148</a>.</li>
+ *
+ * <li>'context': uses the Thread.currentThread().getContextClassLoader().</li>
+ *
+ * <li>'custom': means that a ClassLoader class has to be provided in the property
+ * <b>'jbpm.classloader.classname'</b></li>
+ * </td>
+ */
public static ClassLoader getClassLoader() {
- // if this is made configurable, make sure it's done with the
- // jvm system properties
- // System.getProperty("jbpm.classloader")
- // - 'jbpm'
- // - 'context'
- //
- // or something like Thread.currentThread().getContextClassLoader();
- return ClassLoaderUtil.class.getClassLoader();
+ if (JbpmConfiguration.Configs.hasObject("jbpm.classLoader")) {
+ String jbpmClassloader = JbpmConfiguration.Configs.getString("jbpm.classLoader");
+
+ if (jbpmClassloader.equals("jbpm")) {
+ return ClassLoaderUtil.class.getClassLoader();
+ } else if (jbpmClassloader.equals("context")) {
+ return Thread.currentThread().getContextClassLoader();
+ } else if (jbpmClassloader.equals("custom")) {
+ String jbpmClassloaderClassname = JbpmConfiguration.Configs.getString("jbpm.customClassLoader.className");
+ try {
+ if (jbpmClassloaderClassname == null) {
+ throw new JbpmException("'jbpm.classloader' property set to 'custom' but 'jbpm.customClassLoader.className' is empty!");
+ }
+
+ Class clazz = ClassLoaderUtil.class.getClassLoader().loadClass(jbpmClassloaderClassname);
+ if (clazz==null)
+ clazz = Thread.currentThread().getContextClassLoader().loadClass(jbpmClassloaderClassname);
+
+ return (ClassLoader) clazz.newInstance();
+ } catch (InstantiationException e) {
+ throw new JbpmException("Error instantiating custom classloader " + jbpmClassloaderClassname, e);
+ } catch (IllegalAccessException e) {
+ throw new JbpmException("Error accessing custom classloader " + jbpmClassloaderClassname, e);
+ } catch (ClassNotFoundException e) {
+ throw new JbpmException("Custom classloader " + jbpmClassloaderClassname + " not found ", e);
+ }
+ } else {
+ throw new JbpmException("'jbpm.classloader' property set to '" + jbpmClassloader + "' but only the values 'jbpm'/'context'/'custom' are supported!");
+ }
+ } else {
+ // default behavior like before https://jira.jboss.org/jira/browse/JBPM-1148
+ return ClassLoaderUtil.class.getClassLoader();
+ }
}
public static InputStream getStream(String resource) {
- return getClassLoader().getResourceAsStream(resource);
+ return getClassLoader().getResourceAsStream(resource);
}
-
- public static Properties getProperties(String resource) {
- Properties properties = new Properties();
- try {
- properties.load(getStream(resource));
- } catch (IOException e) {
- throw new JbpmException("couldn't load properties file '"+resource+"'", e);
- }
- return properties;
- }
-
+
/**
- * searches the given resource, first on the root of the classpath and if not
- * not found there, in the given directory.
- public static InputStream getStream(String resource, String directory) {
- InputStream is = getClassLoader().getResourceAsStream(resource);
- if (is==null) {
- is = getClassLoader().getResourceAsStream(directory+"/"+resource);
+ * Load jbpm configuration related resources as stream (normally jbpm.cfg.xml).
+ *
+ * This method first tries to load the resource from the {@link ClassLoaderUtil}
+ * class loader, if not found it tries the context class loader.
+ *
+ * If this doesn't return any ressource the call is delegated to the class
+ * loader configured by calling getClassLoader().
+ *
+ * This is a special method because the class loader which has to be used
+ * for loading the jbpm.cfg.xml cannot be configured in the jbpm.cfg.xml
+ * itself.
+ */
+ public static InputStream getJbpmConfigurationStream(String resource) {
+ InputStream jbpmCfgStream = ClassLoaderUtil.class.getClassLoader().getResourceAsStream(resource);
+ if (jbpmCfgStream==null) {
+ jbpmCfgStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
}
- return is;
+ return jbpmCfgStream;
}
-
- public static Properties getProperties(String resource, String directory) {
+
+ public static Properties getProperties(String resource) {
Properties properties = new Properties();
try {
- properties.load(getStream(resource, directory));
+ properties.load(getStream(resource));
} catch (IOException e) {
throw new JbpmException("couldn't load properties file '"+resource+"'", e);
}
return properties;
}
- */
-
- public static ClassLoader getProcessClassLoader(ProcessDefinition processDefinition) {
- return new ProcessClassLoader(ClassLoaderUtil.class.getClassLoader(), processDefinition);
- }
-
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/util/XmlUtil.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/util/XmlUtil.java 2008-10-07 11:37:40 UTC (rev 2497)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/util/XmlUtil.java 2008-10-07 14:02:30 UTC (rev 2498)
@@ -58,8 +58,19 @@
return parseXmlInputSource(new InputSource(bais));
}
- public static Document parseXmlResource(String resource) {
- InputStream inputStream = ClassLoaderUtil.getStream(resource);
+ /**
+ * @param isJbpmConfiguration specifies if the resource should be loaded
+ * with the "limited" bootstrap class loader for jbpm config.
+ */
+ public static Document parseXmlResource(String resource, boolean isJbpmConfiguration) {
+ // decide which class loading mechanism to use for loading the jbpm
+ // configuration (see https://jira.jboss.org/jira/browse/JBPM-1148)
+ InputStream inputStream = null;
+ if (isJbpmConfiguration)
+ inputStream = ClassLoaderUtil.getJbpmConfigurationStream(resource);
+ else
+ inputStream = ClassLoaderUtil.getStream(resource);
+
if (inputStream == null)
throw new IllegalArgumentException("Cannot load resource: " + resource);
InputSource inputSource = new InputSource(inputStream);
Modified: jbpm3/trunk/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
===================================================================
--- jbpm3/trunk/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml 2008-10-07 11:37:40 UTC (rev 2497)
+++ jbpm3/trunk/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml 2008-10-07 14:02:30 UTC (rev 2498)
@@ -30,6 +30,11 @@
<string name="resource.varmapping" value="org/jbpm/context/exe/jbpm.varmapping.xml" />
<string name="resource.mail.templates" value="jbpm.mail.templates.xml" />
+ <!-- class loading -->
+ <!-- <string name="jbpm.classLoader" value="jbpm" />
+ <string name="jbpm.customClassLoader.className" value="com...MyClassLoaderUtil" />
+ <bean name="jbpm.processClassLoader" class="org.jbpm.instantiation.DefaultProcessClassLoaderFactory" singelton="true" />-->
+
<!-- make sure the block size matches the length in ByteArray.hbm.xml -->
<int name="jbpm.byte.block.size" value="1024" singleton="true" />
<bean name="jbpm.task.instance.factory" class="org.jbpm.taskmgmt.impl.DefaultTaskInstanceFactoryImpl" singleton="true" />
Added: jbpm3/trunk/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassloadersTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassloadersTest.java (rev 0)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/instantiation/ConfigurableClassloadersTest.java 2008-10-07 14:02:30 UTC (rev 2498)
@@ -0,0 +1,133 @@
+/*
+ * 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.instantiation;
+
+import org.jbpm.AbstractJbpmTestCase;
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.graph.def.ProcessDefinition;
+
+/**
+ * {@link ProcessClassLoaderFactory} and class loader can be configured
+ * via {@link JbpmConfiguration} / jbpm.cfg.xml. Test if that works.
+ *
+ * Introduced with https://jira.jboss.org/jira/browse/JBPM-1148
+ *
+ * @author bernd.ruecker(a)camunda.com
+ */
+public class ConfigurableClassloadersTest extends AbstractJbpmTestCase {
+
+ public void testDefaultBehavior() {
+ JbpmConfiguration.getInstance();
+ ClassLoader processClassLoader = JbpmConfiguration.getProcessClassLoader(null);
+
+ assertNotNull(processClassLoader);
+ assertEquals(ProcessClassLoader.class, processClassLoader.getClass());
+ }
+
+ public static class MyClassLoader extends ClassLoader {
+ public MyClassLoader() {
+ }
+ public MyClassLoader(ClassLoader parent) {
+ super(parent);
+ }
+ }
+
+ public static class TestProcessClassLoaderFactory implements ProcessClassLoaderFactory {
+ public ClassLoader getProcessClassLoader(ProcessDefinition processDefinition) {
+ return new MyClassLoader(Thread.currentThread().getContextClassLoader());
+ }
+ }
+
+ public void testOwnProcessFactory() {
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
+ "<jbpm-configuration>" +
+ " <jbpm-context>" +
+ " </jbpm-context>" +
+ " <string name='jbpm.classLoader' value='jbpm' /> " +
+ " <bean name='jbpm.processClassLoader' class='org.jbpm.instantiation.ProcessClassLoaderFactoryTest$TestProcessClassLoaderFactory' singelton='true' />" +
+ "</jbpm-configuration>"
+ );
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+
+ ClassLoader processClassLoader = JbpmConfiguration.getProcessClassLoader(null);
+ assertNotNull(processClassLoader);
+ assertEquals(MyClassLoader.class, processClassLoader.getClass());
+
+ jbpmContext.close();
+ jbpmConfiguration.close();
+ }
+
+ public void testContextClassloaderFactory() {
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
+ "<jbpm-configuration>" +
+ " <jbpm-context>" +
+ " </jbpm-context>" +
+ " <string name='jbpm.classLoader' value='context' /> " +
+ "</jbpm-configuration>"
+ );
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+
+ assertNotNull(jbpmContext);
+
+ jbpmContext.close();
+ jbpmConfiguration.close();
+ }
+
+ public void testCustomClassloaderFactoryWithoutClassname() {
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
+ "<jbpm-configuration>" +
+ " <jbpm-context>" +
+ " </jbpm-context>" +
+ " <string name='jbpm.classLoader' value='custom' /> " +
+ "</jbpm-configuration>"
+ );
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try {
+ ClassLoader processClassLoader = JbpmConfiguration.getProcessClassLoader(null);
+ fail("we should get an exception because custom class loader class not specified");
+ }
+ catch (Exception ex) {}
+ jbpmConfiguration.close();
+ }
+
+ public void testCustomClassloaderFactory() {
+ JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
+ "<jbpm-configuration>" +
+ " <jbpm-context>" +
+ " </jbpm-context>" +
+ " <string name='jbpm.classLoader' value='custom' /> " +
+ " <string name='jbpm.customClassLoader.className' value='org.jbpm.instantiation.ProcessClassLoaderFactoryTest$MyClassLoader' />" +
+ "</jbpm-configuration>"
+ );
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+
+ ClassLoader processClassLoader = JbpmConfiguration.getProcessClassLoader(null);
+ assertNotNull(processClassLoader);
+ // not configured, must be default
+ assertEquals(ProcessClassLoader.class, processClassLoader.getClass());
+
+ jbpmContext.close();
+ jbpmConfiguration.close();
+ }
+
+}
17 years, 6 months
JBoss JBPM SVN: r2497 - in jbpm3/trunk/modules/core/src/main/java/org/jbpm: graph/node and 2 other directories.
by do-not-reply@jboss.org
Author: camunda
Date: 2008-10-07 07:37:40 -0400 (Tue, 07 Oct 2008)
New Revision: 2497
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Action.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/node/Decision.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/def/TaskController.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskMgmtInstance.java
Log:
JBPM-1448
set ContextClassLoader correctly to ProcessClassLoader wherever Delegation classes are instantiated and used (https://jira.jboss.org/jira/browse/JBPM-1448)
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Action.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Action.java 2008-10-07 11:09:44 UTC (rev 2496)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/def/Action.java 2008-10-07 11:37:40 UTC (rev 2497)
@@ -30,6 +30,7 @@
import org.jbpm.jpdl.el.impl.JbpmExpressionEvaluator;
import org.jbpm.jpdl.xml.JpdlXmlReader;
import org.jbpm.jpdl.xml.Parsable;
+import org.jbpm.util.ClassLoaderUtil;
import org.jbpm.util.EqualsUtil;
public class Action implements ActionHandler, Parsable, Serializable {
@@ -111,15 +112,23 @@
}
public void execute(ExecutionContext executionContext) throws Exception {
- if (referencedAction!=null) {
- referencedAction.execute(executionContext);
+ ClassLoader surroundingClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ // set context class loader correctly for delegation class (https://jira.jboss.org/jira/browse/JBPM-1448)
+ Thread.currentThread().setContextClassLoader(ClassLoaderUtil.getProcessClassLoader(processDefinition));
- } else if (actionExpression!=null) {
- JbpmExpressionEvaluator.evaluate(actionExpression, executionContext);
+ if (referencedAction != null) {
+ referencedAction.execute(executionContext);
- } else if (actionDelegation!=null) {
- ActionHandler actionHandler = (ActionHandler)actionDelegation.getInstance();
- actionHandler.execute(executionContext);
+ } else if (actionExpression != null) {
+ JbpmExpressionEvaluator.evaluate(actionExpression, executionContext);
+
+ } else if (actionDelegation != null) {
+ ActionHandler actionHandler = (ActionHandler) actionDelegation.getInstance();
+ actionHandler.execute(executionContext);
+ }
+ } finally {
+ Thread.currentThread().setContextClassLoader(surroundingClassLoader);
}
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/node/Decision.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/node/Decision.java 2008-10-07 11:09:44 UTC (rev 2496)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/graph/node/Decision.java 2008-10-07 11:37:40 UTC (rev 2497)
@@ -35,6 +35,7 @@
import org.jbpm.jpdl.el.impl.JbpmExpressionEvaluator;
import org.jbpm.jpdl.xml.JpdlXmlReader;
import org.jbpm.jpdl.xml.Parsable;
+import org.jbpm.util.ClassLoaderUtil;
/**
* decision node.
@@ -72,73 +73,84 @@
public void execute(ExecutionContext executionContext) {
Transition transition = null;
-
+ ClassLoader surroundingClassLoader = Thread.currentThread().getContextClassLoader();
try {
- if (decisionDelegation!=null) {
- DecisionHandler decisionHandler = (DecisionHandler) decisionDelegation.instantiate();
- String transitionName = decisionHandler.decide(executionContext);
- transition = getLeavingTransition(transitionName);
- if (transition==null) {
- throw new JbpmException("decision '"+name+"' selected non existing transition '"+transitionName+"'" );
- }
-
- } else if (decisionExpression!=null) {
- Object result = JbpmExpressionEvaluator.evaluate(decisionExpression, executionContext);
- if (result==null) {
- throw new JbpmException("decision expression '"+decisionExpression+"' returned null");
- }
- String transitionName = result.toString();
- transition = getLeavingTransition(transitionName);
- if (transition==null) {
- throw new JbpmException("decision '"+name+"' selected non existing transition '"+transitionName+"'" );
- }
-
- } else if (decisionConditions!=null && !decisionConditions.isEmpty()) {
- // backwards compatible mode based on separate DecisionCondition's
- Iterator iter = decisionConditions.iterator();
- while (iter.hasNext() && (transition==null)) {
- DecisionCondition decisionCondition = (DecisionCondition) iter.next();
- Object result = JbpmExpressionEvaluator.evaluate(decisionCondition.getExpression(), executionContext);
- if (Boolean.TRUE.equals(result)) {
- String transitionName = decisionCondition.getTransitionName();
- transition = getLeavingTransition(transitionName);
- if (transition!=null) {
- transition.removeConditionEnforcement();
- }
+ // set context class loader correctly for delegation class (https://jira.jboss.org/jira/browse/JBPM-1448)
+ Thread.currentThread().setContextClassLoader(ClassLoaderUtil.getProcessClassLoader(processDefinition));
+
+ try {
+ if (decisionDelegation != null) {
+ DecisionHandler decisionHandler = (DecisionHandler) decisionDelegation.instantiate();
+ String transitionName = decisionHandler.decide(executionContext);
+ transition = getLeavingTransition(transitionName);
+ if (transition == null) {
+ throw new JbpmException("decision '" + name + "' selected non existing transition '" + transitionName + "'");
}
- }
-
- } else {
- // new mode based on conditions in the transition itself
- Iterator iter = leavingTransitions.iterator();
- while (iter.hasNext() && (transition==null)) {
- Transition candidate = (Transition) iter.next();
-
- String conditionExpression = candidate.getCondition();
- if (conditionExpression!=null) {
- Object result = JbpmExpressionEvaluator.evaluate(conditionExpression, executionContext);
+
+ } else if (decisionExpression != null) {
+ Object result = JbpmExpressionEvaluator.evaluate(decisionExpression, executionContext);
+ if (result == null) {
+ throw new JbpmException("decision expression '" + decisionExpression + "' returned null");
+ }
+ String transitionName = result.toString();
+ transition = getLeavingTransition(transitionName);
+ if (transition == null) {
+ throw new JbpmException("decision '" + name + "' selected non existing transition '" + transitionName + "'");
+ }
+
+ } else if (decisionConditions != null && !decisionConditions.isEmpty()) {
+ // backwards compatible mode based on separate DecisionCondition's
+ Iterator iter = decisionConditions.iterator();
+ while (iter.hasNext() && (transition == null)) {
+ DecisionCondition decisionCondition = (DecisionCondition) iter.next();
+ Object result = JbpmExpressionEvaluator.evaluate(decisionCondition.getExpression(), executionContext);
if (Boolean.TRUE.equals(result)) {
- transition = candidate;
+ String transitionName = decisionCondition.getTransitionName();
+ transition = getLeavingTransition(transitionName);
+ if (transition != null) {
+ transition.removeConditionEnforcement();
+ }
}
}
+
+ } else {
+ // new mode based on conditions in the transition itself
+ Iterator iter = leavingTransitions.iterator();
+ while (iter.hasNext() && (transition == null)) {
+ Transition candidate = (Transition) iter.next();
+
+ String conditionExpression = candidate.getCondition();
+ if (conditionExpression != null) {
+ Object result = JbpmExpressionEvaluator.evaluate(conditionExpression, executionContext);
+ if (Boolean.TRUE.equals(result)) {
+ transition = candidate;
+ }
+ }
+ }
+
}
- }
+ if (transition == null) {
+ transition = getDefaultLeavingTransition();
+ log.debug("decision didn't select transition, taking default " + transition);
+ }
- if (transition==null) {
- transition = getDefaultLeavingTransition();
- log.debug("decision didn't select transition, taking default "+transition);
+ // since the decision node evaluates condition expressions, the
+ // condition of the
+ // taken transition will always be met. therefor we can safely turn off
+ // the
+ // standard condition enforcement in the transitions after a decision
+ // node.
+ transition.removeConditionEnforcement();
+
+ } catch (Exception exception) {
+ raiseException(exception, executionContext);
}
- // since the decision node evaluates condition expressions, the condition of the
- // taken transition will always be met. therefor we can safely turn off the
- // standard condition enforcement in the transitions after a decision node.
- transition.removeConditionEnforcement();
-
- } catch (Exception exception) {
- raiseException(exception, executionContext);
}
-
+ finally {
+ Thread.currentThread().setContextClassLoader(surroundingClassLoader);
+ }
log.debug("decision "+name+" is taking '"+transition+"'");
executionContext.leaveNode(transition);
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/def/TaskController.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/def/TaskController.java 2008-10-07 11:09:44 UTC (rev 2496)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/def/TaskController.java 2008-10-07 11:37:40 UTC (rev 2497)
@@ -34,6 +34,7 @@
import org.jbpm.instantiation.Delegation;
import org.jbpm.instantiation.UserCodeInterceptorConfig;
import org.jbpm.taskmgmt.exe.TaskInstance;
+import org.jbpm.util.ClassLoaderUtil;
import org.jbpm.util.EqualsUtil;
/**
@@ -70,101 +71,116 @@
* visible (that means that the user did not specify a special task instance scope).
*/
public void initializeVariables(TaskInstance taskInstance) {
- if (taskControllerDelegation != null) {
- TaskControllerHandler taskControllerHandler = (TaskControllerHandler) taskControllerDelegation.instantiate();
- ProcessInstance processInstance = taskInstance.getTaskMgmtInstance().getProcessInstance();
- ContextInstance contextInstance = (processInstance!=null ? processInstance.getContextInstance() : null);
- Token token = taskInstance.getToken();
-
- if (UserCodeInterceptorConfig.userCodeInterceptor!=null) {
- UserCodeInterceptorConfig.userCodeInterceptor.executeTaskControllerInitialization(taskControllerHandler, taskInstance, contextInstance, token);
+ ClassLoader surroundingClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ // set context class loader correctly for delegation class (https://jira.jboss.org/jira/browse/JBPM-1448)
+ Thread.currentThread().setContextClassLoader(ClassLoaderUtil.getProcessClassLoader(taskInstance.getTask().getProcessDefinition()));
+
+ if (taskControllerDelegation != null) {
+ TaskControllerHandler taskControllerHandler = (TaskControllerHandler) taskControllerDelegation.instantiate();
+ ProcessInstance processInstance = taskInstance.getTaskMgmtInstance().getProcessInstance();
+ ContextInstance contextInstance = (processInstance != null ? processInstance.getContextInstance() : null);
+ Token token = taskInstance.getToken();
+
+ if (UserCodeInterceptorConfig.userCodeInterceptor != null) {
+ UserCodeInterceptorConfig.userCodeInterceptor.executeTaskControllerInitialization(taskControllerHandler, taskInstance, contextInstance, token);
+ } else {
+ taskControllerHandler.initializeTaskVariables(taskInstance, contextInstance, token);
+ }
+
} else {
- taskControllerHandler.initializeTaskVariables(taskInstance, contextInstance, token);
- }
+ Token token = taskInstance.getToken();
+ ProcessInstance processInstance = token.getProcessInstance();
+ ContextInstance contextInstance = processInstance.getContextInstance();
- } else {
- Token token = taskInstance.getToken();
- ProcessInstance processInstance = token.getProcessInstance();
- ContextInstance contextInstance = processInstance.getContextInstance();
-
- if (variableAccesses!=null) {
- Iterator iter = variableAccesses.iterator();
- while (iter.hasNext()) {
- VariableAccess variableAccess = (VariableAccess) iter.next();
- String mappedName = variableAccess.getMappedName();
- if (variableAccess.isReadable()) {
- String variableName = variableAccess.getVariableName();
- Object value = contextInstance.getVariable(variableName, token);
- log.debug("creating task instance variable '"+mappedName+"' from process variable '"+variableName+"', value '"+value+"'");
- taskInstance.setVariableLocally(mappedName, value);
- } else {
- log.debug("creating task instance local variable '"+mappedName+"'. initializing with null value.");
- taskInstance.setVariableLocally(mappedName, null);
+ if (variableAccesses != null) {
+ Iterator iter = variableAccesses.iterator();
+ while (iter.hasNext()) {
+ VariableAccess variableAccess = (VariableAccess) iter.next();
+ String mappedName = variableAccess.getMappedName();
+ if (variableAccess.isReadable()) {
+ String variableName = variableAccess.getVariableName();
+ Object value = contextInstance.getVariable(variableName, token);
+ log.debug("creating task instance variable '" + mappedName + "' from process variable '" + variableName + "', value '" + value + "'");
+ taskInstance.setVariableLocally(mappedName, value);
+ } else {
+ log.debug("creating task instance local variable '" + mappedName + "'. initializing with null value.");
+ taskInstance.setVariableLocally(mappedName, null);
+ }
}
}
}
- }
+ } finally {
+ Thread.currentThread().setContextClassLoader(surroundingClassLoader);
+ }
}
/**
* update the process variables from the the task-instance variables.
*/
public void submitParameters(TaskInstance taskInstance) {
- if (taskControllerDelegation != null) {
- TaskControllerHandler taskControllerHandler = (TaskControllerHandler) taskControllerDelegation.instantiate();
- ProcessInstance processInstance = taskInstance.getTaskMgmtInstance().getProcessInstance();
- ContextInstance contextInstance = (processInstance!=null ? processInstance.getContextInstance() : null);
- Token token = taskInstance.getToken();
+ ClassLoader surroundingClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ // set context class loader correctly for delegation class (https://jira.jboss.org/jira/browse/JBPM-1448)
+ Thread.currentThread().setContextClassLoader(ClassLoaderUtil.getProcessClassLoader(taskInstance.getTask().getProcessDefinition()));
- if (UserCodeInterceptorConfig.userCodeInterceptor!=null) {
- UserCodeInterceptorConfig.userCodeInterceptor.executeTaskControllerSubmission(taskControllerHandler, taskInstance, contextInstance, token);
+ if (taskControllerDelegation != null) {
+ TaskControllerHandler taskControllerHandler = (TaskControllerHandler) taskControllerDelegation.instantiate();
+ ProcessInstance processInstance = taskInstance.getTaskMgmtInstance().getProcessInstance();
+ ContextInstance contextInstance = (processInstance != null ? processInstance.getContextInstance() : null);
+ Token token = taskInstance.getToken();
+
+ if (UserCodeInterceptorConfig.userCodeInterceptor != null) {
+ UserCodeInterceptorConfig.userCodeInterceptor.executeTaskControllerSubmission(taskControllerHandler, taskInstance, contextInstance, token);
+ } else {
+ taskControllerHandler.submitTaskVariables(taskInstance, contextInstance, token);
+ }
+
} else {
- taskControllerHandler.submitTaskVariables(taskInstance, contextInstance, token);
- }
- } else {
+ Token token = taskInstance.getToken();
+ ProcessInstance processInstance = token.getProcessInstance();
+ ContextInstance contextInstance = processInstance.getContextInstance();
- Token token = taskInstance.getToken();
- ProcessInstance processInstance = token.getProcessInstance();
- ContextInstance contextInstance = processInstance.getContextInstance();
-
- if (variableAccesses!=null) {
- String missingTaskVariables = null;
- Iterator iter = variableAccesses.iterator();
- while (iter.hasNext()) {
- VariableAccess variableAccess = (VariableAccess) iter.next();
- String mappedName = variableAccess.getMappedName();
- // first check if the required variableInstances are present
- if ( (variableAccess.isRequired())
- && (! taskInstance.hasVariableLocally(mappedName))
- ) {
- if (missingTaskVariables==null) {
- missingTaskVariables = mappedName;
- } else {
- missingTaskVariables += ", "+mappedName;
+ if (variableAccesses != null) {
+ String missingTaskVariables = null;
+ Iterator iter = variableAccesses.iterator();
+ while (iter.hasNext()) {
+ VariableAccess variableAccess = (VariableAccess) iter.next();
+ String mappedName = variableAccess.getMappedName();
+ // first check if the required variableInstances are present
+ if ((variableAccess.isRequired()) && (!taskInstance.hasVariableLocally(mappedName))) {
+ if (missingTaskVariables == null) {
+ missingTaskVariables = mappedName;
+ } else {
+ missingTaskVariables += ", " + mappedName;
+ }
}
}
- }
- // if there are missing, required parameters, throw an IllegalArgumentException
- if (missingTaskVariables!=null) {
- throw new IllegalArgumentException("missing task variables: "+missingTaskVariables);
- }
+ // if there are missing, required parameters, throw an
+ // IllegalArgumentException
+ if (missingTaskVariables != null) {
+ throw new IllegalArgumentException("missing task variables: " + missingTaskVariables);
+ }
- iter = variableAccesses.iterator();
- while (iter.hasNext()) {
- VariableAccess variableAccess = (VariableAccess) iter.next();
- String mappedName = variableAccess.getMappedName();
- String variableName = variableAccess.getVariableName();
- if (variableAccess.isWritable()) {
- Object value = taskInstance.getVariable(mappedName);
- if (value!=null) {
- log.debug("submitting task variable '"+mappedName+"' to process variable '"+variableName+"', value '"+value+"'");
- contextInstance.setVariable(variableName, value, token);
+ iter = variableAccesses.iterator();
+ while (iter.hasNext()) {
+ VariableAccess variableAccess = (VariableAccess) iter.next();
+ String mappedName = variableAccess.getMappedName();
+ String variableName = variableAccess.getVariableName();
+ if (variableAccess.isWritable()) {
+ Object value = taskInstance.getVariable(mappedName);
+ if (value != null) {
+ log.debug("submitting task variable '" + mappedName + "' to process variable '" + variableName + "', value '" + value + "'");
+ contextInstance.setVariable(variableName, value, token);
+ }
}
}
}
}
+ } finally {
+ Thread.currentThread().setContextClassLoader(surroundingClassLoader);
}
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskMgmtInstance.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskMgmtInstance.java 2008-10-07 11:09:44 UTC (rev 2496)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/taskmgmt/exe/TaskMgmtInstance.java 2008-10-07 11:37:40 UTC (rev 2497)
@@ -54,6 +54,7 @@
import org.jbpm.taskmgmt.def.Task;
import org.jbpm.taskmgmt.def.TaskMgmtDefinition;
import org.jbpm.taskmgmt.log.TaskCreateLog;
+import org.jbpm.util.ClassLoaderUtil;
import org.jbpm.util.Clock;
/**
@@ -264,14 +265,23 @@
}
void performAssignmentDelegation(Delegation assignmentDelegation, Assignable assignable, ExecutionContext executionContext) throws Exception {
- // instantiate the assignment handler
- AssignmentHandler assignmentHandler = (AssignmentHandler) assignmentDelegation.instantiate();
- // invoke the assignment handler
- if (UserCodeInterceptorConfig.userCodeInterceptor!=null) {
- UserCodeInterceptorConfig.userCodeInterceptor.executeAssignment(assignmentHandler, assignable, executionContext);
- } else {
- assignmentHandler.assign(assignable, executionContext);
- }
+ ClassLoader surroundingClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ // set context class loader correctly for delegation class (https://jira.jboss.org/jira/browse/JBPM-1448)
+ Thread.currentThread().setContextClassLoader(ClassLoaderUtil.getProcessClassLoader(executionContext.getProcessDefinition()));
+
+ // instantiate the assignment handler
+ AssignmentHandler assignmentHandler = (AssignmentHandler) assignmentDelegation.instantiate();
+ // invoke the assignment handler
+ if (UserCodeInterceptorConfig.userCodeInterceptor != null) {
+ UserCodeInterceptorConfig.userCodeInterceptor.executeAssignment(assignmentHandler, assignable, executionContext);
+ } else {
+ assignmentHandler.assign(assignable, executionContext);
+ }
+
+ } finally {
+ Thread.currentThread().setContextClassLoader(surroundingClassLoader);
+ }
}
void performAssignmentActorIdExpr(String actorIdExpression, Assignable assignable, ExecutionContext executionContext) {
17 years, 6 months
JBoss JBPM SVN: r2495 - in jbpm3/trunk/modules/core: src/test/java/org/jbpm/job/executor and 1 other directory.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-10-07 04:41:10 -0400 (Tue, 07 Oct 2008)
New Revision: 2495
Modified:
jbpm3/trunk/modules/core/pom.xml
jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java
Log:
[JBPM-1771] Fix JobExecutorDbTest on postgresql
Modified: jbpm3/trunk/modules/core/pom.xml
===================================================================
--- jbpm3/trunk/modules/core/pom.xml 2008-10-06 23:29:44 UTC (rev 2494)
+++ jbpm3/trunk/modules/core/pom.xml 2008-10-07 08:41:10 UTC (rev 2495)
@@ -325,8 +325,6 @@
<exclude>org/jbpm/perf/StateUpdateTest.java</exclude>
<!-- https://jira.jboss.org/jira/browse/JBPM-1724 -->
<exclude>org/jbpm/seam/SeamPageFlowTest.java</exclude>
- <!-- https://jira.jboss.org/jira/browse/JBPM-1771 -->
- <exclude>org/jbpm/job/executor/JobExecutorDbTest.java</exclude>
<!-- https://jira.jboss.org/jira/browse/JBPM-1772 -->
<exclude>org/jbpm/jpdl/exe/JoinDbTest.java</exclude>
<exclude>org/jbpm/graph/exe/SubProcessPlusConcurrencyDbTest.java</exclude>
Modified: jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java
===================================================================
--- jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java 2008-10-06 23:29:44 UTC (rev 2494)
+++ jbpm3/trunk/modules/core/src/test/java/org/jbpm/job/executor/JobExecutorDbTest.java 2008-10-07 08:41:10 UTC (rev 2495)
@@ -1,6 +1,8 @@
package org.jbpm.job.executor;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.List;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
@@ -20,46 +22,22 @@
public class JobExecutorDbTest extends AbstractJbpmTestCase
{
+ private static Log log = LogFactory.getLog(JobExecutorDbTest.class);
static int nbrOfConcurrentProcessExecutions = 20;
static int maxWaitTime = 60000;
- static Set collectedResults = Collections.synchronizedSet(new TreeSet());
+ static Set<String> collectedResults = Collections.synchronizedSet(new TreeSet<String>());
- protected static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance("org/jbpm/jbpm.test.cfg.xml");
+ static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.getInstance("org/jbpm/jbpm.test.cfg.xml");
- static
+ static List<Long> allocatedProcessIds = Collections.synchronizedList(new ArrayList<Long>());
+
{
jbpmConfiguration.getJobExecutor().nbrOfThreads = 5;
}
- protected JobExecutor jobExecutor;
+ private JobExecutor jobExecutor;
- public static class AutomaticActivity implements ActionHandler
- {
- private static final long serialVersionUID = 1L;
-
- public void execute(ExecutionContext executionContext) throws Exception
- {
- long id = executionContext.getProcessInstance().getId();
- String nodeName = executionContext.getNode().getName();
- collectedResults.add(id + nodeName);
- executionContext.leaveNode();
- }
- }
-
- public static class AsyncAction implements ActionHandler
- {
- private static final long serialVersionUID = 1L;
-
- public void execute(ExecutionContext executionContext) throws Exception
- {
- long id = executionContext.getProcessInstance().getId();
- Action action = executionContext.getAction();
- String actionName = action.getName();
- collectedResults.add(id + actionName);
- }
- }
-
public void testJobExecutor()
{
jbpmConfiguration.createSchema();
@@ -137,19 +115,20 @@
}
}
- public Set createExpectedResults()
+ public Set<String> createExpectedResults()
{
- Set expectedResults = new TreeSet();
- for (int i = 1; i < nbrOfConcurrentProcessExecutions + 1; i++)
+ Set<String> expectedResults = new TreeSet<String>();
+ for (int i = 0; i < nbrOfConcurrentProcessExecutions; i++)
{
- expectedResults.add(i + "a");
- expectedResults.add(i + "b");
- expectedResults.add(i + "c");
- expectedResults.add(i + "d");
- expectedResults.add(i + "e");
- expectedResults.add(i + "X");
- expectedResults.add(i + "Y");
- expectedResults.add(i + "Z");
+ String prefix = (i < 10 ? "0" : "");
+ expectedResults.add(prefix + i + "a");
+ expectedResults.add(prefix + i + "b");
+ expectedResults.add(prefix + i + "c");
+ expectedResults.add(prefix + i + "d");
+ expectedResults.add(prefix + i + "e");
+ expectedResults.add(prefix + i + "X");
+ expectedResults.add(prefix + i + "Y");
+ expectedResults.add(prefix + i + "Z");
}
return expectedResults;
}
@@ -266,5 +245,44 @@
}
}
- private static Log log = LogFactory.getLog(JobExecutorDbTest.class);
+ public static class AutomaticActivity implements ActionHandler
+ {
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ExecutionContext executionContext) throws Exception
+ {
+ Long id = executionContext.getProcessInstance().getId();
+ String procIndex = getProcessIndex(id);
+
+ String nodeName = executionContext.getNode().getName();
+ collectedResults.add(procIndex + nodeName);
+ executionContext.leaveNode();
+ }
+ }
+
+ public static class AsyncAction implements ActionHandler
+ {
+ private static final long serialVersionUID = 1L;
+
+ public void execute(ExecutionContext executionContext) throws Exception
+ {
+ Long id = executionContext.getProcessInstance().getId();
+ String procIndex = getProcessIndex(id);
+
+ Action action = executionContext.getAction();
+ String actionName = action.getName();
+ collectedResults.add(procIndex + actionName);
+ }
+ }
+
+ private static synchronized String getProcessIndex(Long id)
+ {
+ if (allocatedProcessIds.contains(id) == false)
+ allocatedProcessIds.add(id);
+
+ int procIndex = allocatedProcessIds.indexOf(id);
+ String prefix = (procIndex < 10 ? "0" : "");
+
+ return prefix + procIndex;
+ }
}
17 years, 6 months
JBoss JBPM SVN: r2494 - in jbpm3/branches/jpdl-3.2.2-SOA-4.2: jpdl/examples and 10 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2008-10-06 19:29:44 -0400 (Mon, 06 Oct 2008)
New Revision: 2494
Added:
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/main/java/org/jbpm/mail/MyAddressResolver.java
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/main/jpdl/
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/main/jpdl/Mail/
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/main/jpdl/Mail/processdefinition.xml
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/test/
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/test/java/
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/test/java/org/
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/test/java/org/jbpm/
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/test/java/org/jbpm/mail/
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/test/java/org/jbpm/mail/MailTest.java
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/test/java/org/jbpm/mail/test.mail.properties
Removed:
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/main/java/org/jbpm/mail/MailTest.java
Modified:
jbpm3/branches/jpdl-3.2.2-SOA-4.2/build/build.properties
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/example.base.build.xml
Log:
[SOA-483] Restructured the mail example so that the sample process is in the src/main directory and the test code is in src/test. This produces the expected test results.
Modified: jbpm3/branches/jpdl-3.2.2-SOA-4.2/build/build.properties
===================================================================
--- jbpm3/branches/jpdl-3.2.2-SOA-4.2/build/build.properties 2008-10-06 23:25:04 UTC (rev 2493)
+++ jbpm3/branches/jpdl-3.2.2-SOA-4.2/build/build.properties 2008-10-06 23:29:44 UTC (rev 2494)
@@ -20,7 +20,7 @@
jboss.version=4.3.0.GA
jboss.eap.version=4.3
jboss.eap.name=jboss-eap-${jboss.eap.version}
-jboss.eap.remote.file.name=${jboss.eap.name}.0.GA_CP01.zip
+jboss.eap.remote.file.name=${jboss.eap.name}.0.GA_CP02.zip
jboss.home=${software.installation.dir}/${jboss.eap.name}/jbossas
# the eclipse home property has to end with 'eclipse' since the folders in the eclipse
@@ -36,7 +36,7 @@
# REPOSITORY LOCATION PROPERTIES
local.repository=${user.home}/jbpm/repository
remote.repository=http://repository.jboss.org
-remote.jboss.repository=http://porkchop.redhat.com/devel/candidates/JBEAP4.3.0/20080429/zip
+remote.jboss.repository=http://porkchop.redhat.com/devel/candidates/JBEAP4.3.0/20080806/zip
docbook.support.dir=${local.repository}
# BROWSER PROPERTIES
Property changes on: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples
___________________________________________________________________
Name: svn:ignore
+ target
Modified: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/example.base.build.xml
===================================================================
--- jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/example.base.build.xml 2008-10-06 23:25:04 UTC (rev 2493)
+++ jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/example.base.build.xml 2008-10-06 23:29:44 UTC (rev 2494)
@@ -16,6 +16,7 @@
<include name="${lib.commons.logging.path}"/>
<include name="${lib.commons.collections.path}" />
<include name="${lib.dom4j.path}"/>
+ <include name="${lib.dumbster.path}"/>
<include name="${lib.hibernate.path}"/>
<include name="${lib.hsqldb.path}"/>
<include name="${lib.javamail.path}"/>
Deleted: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/main/java/org/jbpm/mail/MailTest.java
===================================================================
--- jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/main/java/org/jbpm/mail/MailTest.java 2008-10-06 23:25:04 UTC (rev 2493)
+++ jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/main/java/org/jbpm/mail/MailTest.java 2008-10-06 23:29:44 UTC (rev 2494)
@@ -1,68 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.mail;
-
-import org.jbpm.JbpmConfiguration;
-import org.jbpm.JbpmContext;
-import org.jbpm.graph.def.ProcessDefinition;
-import org.jbpm.graph.exe.ProcessInstance;
-
-public class MailTest {
-
- public static class MyAddressResolver implements AddressResolver {
- private static final long serialVersionUID = 1L;
- public Object resolveAddress(String actorId) {
- return actorId+"@dalton.com";
- }
- }
-
- public void testSimpleProcess() throws Exception {
- JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
- "<jbpm-configuration>" +
- " <bean name='jbpm.mail.address.resolver' class='"+MyAddressResolver.class.getName()+"' singleton='true' />" +
- "</jbpm-configuration>"
- );
-
- JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
- try {
- ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
- "<process-definition name='mailtest'>" +
- " <start-state name='start'>" +
- " <transition to='start toothpick line' />" +
- " </start-state>" +
- " <task-node name='start toothpick line'>" +
- " <task notify='yes'>" +
- " <assignment actor-id='grandma' />" +
- " </task>" +
- " <transition to='end' />" +
- " </task-node>" +
- " <end-state name='end' />" +
- "</process-definition>"
- );
- ProcessInstance processInstance = new ProcessInstance(processDefinition);
- processInstance.signal();
-
- } finally {
- jbpmContext.close();
- }
- }
-}
Added: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/main/java/org/jbpm/mail/MyAddressResolver.java
===================================================================
--- jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/main/java/org/jbpm/mail/MyAddressResolver.java (rev 0)
+++ jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/main/java/org/jbpm/mail/MyAddressResolver.java 2008-10-06 23:29:44 UTC (rev 2494)
@@ -0,0 +1,11 @@
+package org.jbpm.mail;
+
+public class MyAddressResolver implements AddressResolver {
+
+ private static final long serialVersionUID = 1L;
+
+ public Object resolveAddress(String actorId) {
+ return actorId + "@dalton.com";
+ }
+
+}
\ No newline at end of file
Added: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/main/jpdl/Mail/processdefinition.xml
===================================================================
--- jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/main/jpdl/Mail/processdefinition.xml (rev 0)
+++ jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/main/jpdl/Mail/processdefinition.xml 2008-10-06 23:29:44 UTC (rev 2494)
@@ -0,0 +1,12 @@
+<process-definition name='mailtest'>
+ <start-state name='start'>
+ <transition to='start toothpick line' />
+ </start-state>
+ <task-node name='start toothpick line'>
+ <task notify='yes'>
+ <assignment actor-id='grandma' />
+ </task>
+ <transition to='end' />
+ </task-node>
+ <end-state name='end' />
+</process-definition>
\ No newline at end of file
Copied: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/test/java/org/jbpm/mail/MailTest.java (from rev 2490, jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/main/java/org/jbpm/mail/MailTest.java)
===================================================================
--- jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/test/java/org/jbpm/mail/MailTest.java (rev 0)
+++ jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/test/java/org/jbpm/mail/MailTest.java 2008-10-06 23:29:44 UTC (rev 2494)
@@ -0,0 +1,68 @@
+/*
+ * 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.mail;
+
+import java.util.Iterator;
+
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+
+import com.dumbster.smtp.SimpleSmtpServer;
+import com.dumbster.smtp.SmtpMessage;
+
+import junit.framework.TestCase;
+
+public class MailTest extends TestCase {
+
+ private SimpleSmtpServer server;
+ private JbpmContext jbpmContext;
+
+ private static JbpmConfiguration jbpmConfiguration = JbpmConfiguration.parseXmlString(
+ "<jbpm-configuration>" +
+ " <string name='resource.mail.properties' value='org/jbpm/mail/test.mail.properties' />" +
+ " <bean name='jbpm.mail.address.resolver' class='" + MyAddressResolver.class.getName() + "' singleton='true' />" +
+ "</jbpm-configuration>"
+ );
+
+ protected void setUp() throws Exception {
+ server = SimpleSmtpServer.start(23583);
+ jbpmContext = jbpmConfiguration.createJbpmContext();
+ }
+
+ protected void tearDown() throws Exception {
+ jbpmContext.close();
+ server.stop();
+ }
+
+ public void testMailProcess() throws Exception {
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource("Mail/processdefinition.xml");
+ ProcessInstance processInstance = new ProcessInstance(processDefinition);
+ processInstance.signal();
+
+ assertEquals(1, server.getReceivedEmailSize());
+ Iterator emailIter = server.getReceivedEmail();
+ SmtpMessage email = (SmtpMessage) emailIter.next();
+ assertEquals("grandma(a)dalton.com", email.getHeaderValue("To"));
+ }
+}
Property changes on: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/test/java/org/jbpm/mail/MailTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Added: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/test/java/org/jbpm/mail/test.mail.properties
===================================================================
--- jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/test/java/org/jbpm/mail/test.mail.properties (rev 0)
+++ jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/src/test/java/org/jbpm/mail/test.mail.properties 2008-10-06 23:29:44 UTC (rev 2494)
@@ -0,0 +1,2 @@
+mail.smtp.host = localhost
+mail.smtp.port = 23583
\ No newline at end of file
17 years, 6 months
JBoss JBPM SVN: r2493 - in jbpm3/branches/jpdl-3.2.2-SOA-4.2: designer/jpdl/org.jbpm.gd.jpdl.build and 10 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2008-10-06 19:25:04 -0400 (Mon, 06 Oct 2008)
New Revision: 2493
Modified:
jbpm3/branches/jpdl-3.2.2-SOA-4.2/console/
jbpm3/branches/jpdl-3.2.2-SOA-4.2/designer/jpdl/org.jbpm.gd.jpdl.build/
jbpm3/branches/jpdl-3.2.2-SOA-4.2/enterprise/
jbpm3/branches/jpdl-3.2.2-SOA-4.2/identity/
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jboss/configuration/4.3.0.GA/
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jbpm4jsf/
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/db/
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/dist/
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail/
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/websale/
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar/
jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/userguide/
Log:
ignoring target directories from version control
Property changes on: jbpm3/branches/jpdl-3.2.2-SOA-4.2/console
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: jbpm3/branches/jpdl-3.2.2-SOA-4.2/designer/jpdl/org.jbpm.gd.jpdl.build
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: jbpm3/branches/jpdl-3.2.2-SOA-4.2/enterprise
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: jbpm3/branches/jpdl-3.2.2-SOA-4.2/identity
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jboss/configuration/4.3.0.GA
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jbpm4jsf
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/db
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/dist
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/mail
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/examples/websale
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/jar
___________________________________________________________________
Name: svn:ignore
+ target
Property changes on: jbpm3/branches/jpdl-3.2.2-SOA-4.2/jpdl/userguide
___________________________________________________________________
Name: svn:ignore
+ target
17 years, 6 months
JBoss JBPM SVN: r2492 - in jbpm3/trunk/modules/gwt-console: server/src/main/webapp and 2 other directories.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2008-10-06 15:52:30 -0400 (Mon, 06 Oct 2008)
New Revision: 2492
Modified:
jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java
jbpm3/trunk/modules/gwt-console/server/src/main/webapp/WEB-INF/jboss-web.xml
jbpm3/trunk/modules/gwt-console/server/src/main/webapp/WEB-INF/web.xml
jbpm3/trunk/modules/gwt-console/server/src/main/webapp/index.html
jbpm3/trunk/modules/gwt-console/war/src/main/webapp/WEB-INF/web.xml
Log:
Enforce BASIC auth for REST resources, re-using the jbpm-console JAAS domain
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java 2008-10-06 17:59:38 UTC (rev 2491)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/java/org/jboss/bpm/console/server/ProcessManagement.java 2008-10-06 19:52:30 UTC (rev 2492)
@@ -30,6 +30,8 @@
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.servlet.http.HttpServletRequest;
/**
* REST server module for accessing process related data.
@@ -41,8 +43,7 @@
{
private ProcessDAO processDAO;
-
-
+
public ProcessManagement()
{
this.processDAO = DAOFactory.createProcessDefinitionDAO();
@@ -51,16 +52,25 @@
@GET
@Path("definitions")
@Produces("application/json")
- public ProcessDefinitionWrapper getDefinitionsJSON()
+ public ProcessDefinitionWrapper getDefinitionsJSON(
+ @Context
+ HttpServletRequest request
+ )
{
+ System.out.println("Remote user: " + request.getRemoteUser());
return new ProcessDefinitionWrapper( processDAO.getAllProcessDefinitions() );
}
@GET
@Path("definitions/{id}/instances")
@Produces("application/json")
- public ProcessInstanceWrapper getInstancesJSON(@PathParam("id") long processId)
- {
+ public ProcessInstanceWrapper getInstancesJSON(
+ @PathParam("id")
+ long processId,
+ @Context
+ HttpServletRequest request)
+ {
+ System.out.println("Remote user: " + request.getRemoteUser());
return new ProcessInstanceWrapper( processDAO.getInstanceByProcessDefinitionId(processId) );
}
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/webapp/WEB-INF/jboss-web.xml
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/webapp/WEB-INF/jboss-web.xml 2008-10-06 17:59:38 UTC (rev 2491)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/webapp/WEB-INF/jboss-web.xml 2008-10-06 19:52:30 UTC (rev 2492)
@@ -6,7 +6,7 @@
<jboss-web>
- <!--security-domain>java:/jaas/jbpm-console</security-domain-->
+ <security-domain>java:/jaas/jbpm-console</security-domain>
<context-root>gwt-console-server</context-root>
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/webapp/WEB-INF/web.xml
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/webapp/WEB-INF/web.xml 2008-10-06 17:59:38 UTC (rev 2491)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/webapp/WEB-INF/web.xml 2008-10-06 19:52:30 UTC (rev 2492)
@@ -42,4 +42,27 @@
<url-pattern>/rs/*</url-pattern>
</servlet-mapping>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>Resteasy</web-resource-name>
+ <url-pattern>/rs/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>admin</role-name>
+ <role-name>user</role-name>
+ </auth-constraint>
+ </security-constraint>
+
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>GWT Console Server</realm-name>
+ </login-config>
+
+ <security-role>
+ <role-name>admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>user</role-name>
+ </security-role>
+
</web-app>
Modified: jbpm3/trunk/modules/gwt-console/server/src/main/webapp/index.html
===================================================================
--- jbpm3/trunk/modules/gwt-console/server/src/main/webapp/index.html 2008-10-06 17:59:38 UTC (rev 2491)
+++ jbpm3/trunk/modules/gwt-console/server/src/main/webapp/index.html 2008-10-06 19:52:30 UTC (rev 2492)
@@ -26,7 +26,7 @@
<tr>
<td>GET</td>
- <td><a href="/gwt-console-server/rs/process/1/instances">/rs/process/definitions/{id}/instances</a></td>
+ <td><a href="/gwt-console-server/rs/process/definitions/1/instances">/rs/process/definitions/{id}/instances</a></td>
<td>A list of process instances for a given process definition</td>
<td>application/json, text/html</td>
</tr>
Modified: jbpm3/trunk/modules/gwt-console/war/src/main/webapp/WEB-INF/web.xml
===================================================================
--- jbpm3/trunk/modules/gwt-console/war/src/main/webapp/WEB-INF/web.xml 2008-10-06 17:59:38 UTC (rev 2491)
+++ jbpm3/trunk/modules/gwt-console/war/src/main/webapp/WEB-INF/web.xml 2008-10-06 19:52:30 UTC (rev 2492)
@@ -1,19 +1,20 @@
<!DOCTYPE web-app PUBLIC
- "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
- "http://java.sun.com/dtd/web-app_2_3.dtd" >
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
- <display-name>Archetype Created Web Application</display-name>
- <servlet>
- <servlet-name>HttpServlet</servlet-name>
- <servlet-class>com.totsp.mavenplugin.gwt.sample.server.HttpServlet</servlet-class>
- </servlet>
- <servlet-mapping>
- <servlet-name>HttpServlet</servlet-name>
- <url-pattern>/HttpServlet</url-pattern>
- </servlet-mapping>
+ <display-name>Archetype Created Web Application</display-name>
+ <servlet>
+ <servlet-name>HttpServlet</servlet-name>
+ <servlet-class>com.totsp.mavenplugin.gwt.sample.server.HttpServlet</servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>HttpServlet</servlet-name>
+ <url-pattern>/HttpServlet</url-pattern>
+ </servlet-mapping>
- <welcome-file-list>
- <welcome-file>index.html</welcome-file>
- </welcome-file-list>
+ <welcome-file-list>
+ <welcome-file>index.html</welcome-file>
+ </welcome-file-list>
+
</web-app>
\ No newline at end of file
17 years, 7 months
JBoss JBPM SVN: r2491 - in projects/spec/trunk/modules: api/src/main/java/org/jbpm/api/model/builder and 7 other directories.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-10-06 13:59:38 -0400 (Mon, 06 Oct 2008)
New Revision: 2491
Added:
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/InputSet.java
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/OutputSet.java
projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/InputSetImpl.java
projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/OutputSetImpl.java
Modified:
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/PropertySupport.java
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/Task.java
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/builder/TaskBuilder.java
projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/Token.java
projects/spec/trunk/modules/cts/pom.xml
projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/node/NodeInputSetTest.java
projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/node/NodeOutputSetTest.java
projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/pattern/control/exclusivechoice/ExclusiveChoiceTest.java
projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java
projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/builder/TaskBuilderImpl.java
projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/DelegatingToken.java
projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/MutableToken.java
projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/TokenImpl.java
Log:
No excludes - all pass
Added: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/InputSet.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/InputSet.java (rev 0)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/InputSet.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -0,0 +1,34 @@
+/*
+ * 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.api.model;
+
+//$Id$
+
+/**
+ * An InputSet, which is used in the definition of common attributes for Activities and for attributes of a Process
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 21-Jul-2008
+ */
+public interface InputSet extends PropertySupport
+{
+}
Property changes on: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/InputSet.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/OutputSet.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/OutputSet.java (rev 0)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/OutputSet.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -0,0 +1,34 @@
+/*
+ * 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.api.model;
+
+//$Id$
+
+/**
+ * An OuputSet, which is used in the definition of common attributes for Activities and for attributes of a Process
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 21-Jul-2008
+ */
+public interface OutputSet extends PropertySupport
+{
+}
Property changes on: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/OutputSet.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/PropertySupport.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/PropertySupport.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/PropertySupport.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -23,6 +23,7 @@
//$Id$
+import java.io.Serializable;
import java.util.Set;
/**
@@ -31,7 +32,7 @@
* @author thomas.diesler(a)jboss.com
* @since 21-Jul-2008
*/
-public interface PropertySupport
+public interface PropertySupport extends Serializable
{
/**
* Get a Property with a given name.
Modified: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/Task.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/Task.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/Task.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -23,6 +23,8 @@
//$Id$
+import java.util.List;
+
/**
* A Task is an Atomic Activity that is included within a Process.
*
@@ -57,4 +59,30 @@
* Get the outgoing SequenceFlow
*/
SequenceFlow getOutFlow();
+
+ /**
+ * The InputSets attribute defines the data requirements for input to the Activity.
+ * Zero or more InputSets MAY be defined. Each Input set is sufficient to allow the
+ * Activity to be performed (if it has first been instantiated by the appropriate signal
+ * arriving from an incoming Sequence Flow)
+ */
+ List<InputSet> getInputSets();
+
+ /**
+ * The OutputSets attribute defines the data requirements for output from the
+ * activity. Zero or more OutputSets MAY be defined. At the completion of the
+ * activity, only one of the OutputSets may be produced--It is up to the
+ * implementation of the activity to determine which set will be produced. However,
+ * the IORules attribute MAY indicate a relationship between an OutputSet and an
+ * InputSet that started the activity.
+ */
+ List<OutputSet> getOutputSets();
+
+ /**
+ * The IORules attribute is a collection of expressions, each of which specifies the
+ * required relationship between one input and one output. That is, if the activity is
+ * instantiated with a specified input, that activity shall complete with the specified
+ * output.
+ */
+ List<Expression> getIORules();
}
\ No newline at end of file
Modified: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/builder/TaskBuilder.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/builder/TaskBuilder.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/model/builder/TaskBuilder.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -21,9 +21,11 @@
*/
package org.jbpm.api.model.builder;
-
//$Id$
+import org.jbpm.api.model.Message;
+import org.jbpm.api.model.Expression.ExpressionLanguage;
+
/**
* The TaskBuilder can be used to build a Task dynamically.
*
@@ -38,4 +40,29 @@
* The {@link Message} must be defined at {@link Process} level
*/
TaskBuilder addMessageRef(String msgName);
+
+ /**
+ * Add an InputSet
+ */
+ TaskBuilder addInputSet();
+
+ /**
+ * Add an Property Input
+ */
+ TaskBuilder addPropertyInput(String name);
+
+ /**
+ * Add an OutputSet
+ */
+ TaskBuilder addOutputSet();
+
+ /**
+ * Add an Property Output
+ */
+ TaskBuilder addPropertyOutput(String name, String value);
+
+ /**
+ * Add an IORule Expression
+ */
+ TaskBuilder addIORule(String body, ExpressionLanguage lang);
}
\ No newline at end of file
Modified: projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/Token.java
===================================================================
--- projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/Token.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/api/src/main/java/org/jbpm/api/runtime/Token.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -23,6 +23,8 @@
// $Id$
+import org.jbpm.api.model.InputSet;
+import org.jbpm.api.model.OutputSet;
import org.jbpm.api.model.SequenceFlow;
/**
@@ -65,6 +67,18 @@
SequenceFlow getFlow();
/**
+ * Get the active {@link InputSet}
+ * @return null if the Activity does not define one
+ */
+ InputSet getInputSet();
+
+ /**
+ * Get the active {@link OutputSet}
+ * @return null if the Activity does not define one
+ */
+ OutputSet getOutputSet();
+
+ /**
* Create a schallow copy of this Token.
* <p/>
* The content in the ExecutionContext will be copied by reference.
Modified: projects/spec/trunk/modules/cts/pom.xml
===================================================================
--- projects/spec/trunk/modules/cts/pom.xml 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/cts/pom.xml 2008-10-06 17:59:38 UTC (rev 2491)
@@ -70,8 +70,6 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
- <exclude>org/jbpm/test/cts/node/NodeInputSetTest.java</exclude>
- <exclude>org/jbpm/test/cts/node/NodeOutputSetTest.java</exclude>
</excludes>
</configuration>
</plugin>
Modified: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/node/NodeInputSetTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/node/NodeInputSetTest.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/node/NodeInputSetTest.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -32,6 +32,7 @@
import org.jbpm.api.model.builder.MessageBuilder;
import org.jbpm.api.model.builder.ProcessBuilder;
import org.jbpm.api.model.builder.ProcessBuilderService;
+import org.jbpm.api.model.builder.TaskBuilder;
import org.jbpm.api.runtime.BasicAttachments;
import org.jbpm.api.test.CTSTestCase;
@@ -85,8 +86,8 @@
{
ProcessBuilder procBuilder = ProcessBuilderService.locateProcessBuilder();
procBuilder.addProcess("ActivityInputSet").addStartEvent("Start").addSequenceFlow("TaskA");
- //TaskBuilder taskBuilder = procBuilder.addTask("TaskA");
- //taskBuilder.addInputSet().addPropertyInput("frog").addSequenceFlow("End");
+ TaskBuilder taskBuilder = procBuilder.addTask("TaskA");
+ taskBuilder.addInputSet().addPropertyInput("frog").addSequenceFlow("End");
procBuilder.addEndEvent("End", EventDetailType.Message).addMessageRef("EndMessage");
MessageBuilder msgBuilder = procBuilder.addProcessMessage("EndMessage");
msgBuilder.addToRef(getTestID()).addProperty("frog", null, true);
Modified: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/node/NodeOutputSetTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/node/NodeOutputSetTest.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/node/NodeOutputSetTest.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -32,6 +32,7 @@
import org.jbpm.api.model.builder.MessageBuilder;
import org.jbpm.api.model.builder.ProcessBuilder;
import org.jbpm.api.model.builder.ProcessBuilderService;
+import org.jbpm.api.model.builder.TaskBuilder;
import org.jbpm.api.test.CTSTestCase;
/**
@@ -64,8 +65,8 @@
{
ProcessBuilder procBuilder = ProcessBuilderService.locateProcessBuilder();
procBuilder.addProcess("ActivityInputSet").addStartEvent("Start").addSequenceFlow("TaskA");
- //TaskBuilder taskBuilder = procBuilder.addTask("TaskA");
- //taskBuilder.addOutputSet().addPropertyOutput("frog", "kermit").addSequenceFlow("End");
+ TaskBuilder taskBuilder = procBuilder.addTask("TaskA");
+ taskBuilder.addOutputSet().addPropertyOutput("frog", "kermit").addSequenceFlow("End");
procBuilder.addEndEvent("End", EventDetailType.Message).addMessageRef("EndMessage");
MessageBuilder msgBuilder = procBuilder.addProcessMessage("EndMessage");
msgBuilder.addToRef(getTestID()).addProperty("frog", null, true);
Modified: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/pattern/control/exclusivechoice/ExclusiveChoiceTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/pattern/control/exclusivechoice/ExclusiveChoiceTest.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/pattern/control/exclusivechoice/ExclusiveChoiceTest.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -87,7 +87,7 @@
try
{
proc.waitForEnd();
- fail("No gate defained for foo==10");
+ fail("No gate defined for foo==10");
}
catch (RuntimeException rte)
{
Added: projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/InputSetImpl.java
===================================================================
--- projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/InputSetImpl.java (rev 0)
+++ projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/InputSetImpl.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -0,0 +1,87 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.Transient;
+
+import org.jbpm.api.model.InputSet;
+import org.jbpm.api.model.Property;
+
+
+/**
+ * An InputSet, which is used in the definition of common attributes for Activities and for attributes of a Process
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public class InputSetImpl implements InputSet
+{
+ private static final long serialVersionUID = 1L;
+
+ @Transient
+ private Set<Property> properties = new HashSet<Property>();
+
+ @Override
+ public Property getProperty(String name)
+ {
+ for (Property prop : properties)
+ {
+ if (prop.getName().equals(name))
+ return prop;
+ }
+ return null;
+ }
+
+ @Override
+ public Set<String> getPropertyNames()
+ {
+ Set<String> names = new HashSet<String>();
+ for (Property prop : properties)
+ {
+ names.add(prop.getName());
+ }
+ return names;
+ }
+
+ @Override
+ public boolean removeProperty(String name)
+ {
+ return properties.remove(name);
+ }
+
+ @Override
+ public void addProperty(Property prop)
+ {
+ properties.add(prop);
+ }
+
+ @Override
+ public String toString()
+ {
+ return "InputSet" + getPropertyNames();
+ }
+}
Property changes on: projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/InputSetImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/OutputSetImpl.java
===================================================================
--- projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/OutputSetImpl.java (rev 0)
+++ projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/OutputSetImpl.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -0,0 +1,87 @@
+/*
+ * 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.ri.model;
+
+//$Id$
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.Transient;
+
+import org.jbpm.api.model.OutputSet;
+import org.jbpm.api.model.Property;
+
+
+/**
+ * An OutputSet, which is used in the definition of common attributes for Activities and for attributes of a Process
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 08-Jul-2008
+ */
+public class OutputSetImpl implements OutputSet
+{
+ private static final long serialVersionUID = 1L;
+
+ @Transient
+ private Set<Property> properties = new HashSet<Property>();
+
+ @Override
+ public Property getProperty(String name)
+ {
+ for (Property prop : properties)
+ {
+ if (prop.getName().equals(name))
+ return prop;
+ }
+ return null;
+ }
+
+ @Override
+ public Set<String> getPropertyNames()
+ {
+ Set<String> names = new HashSet<String>();
+ for (Property prop : properties)
+ {
+ names.add(prop.getName());
+ }
+ return names;
+ }
+
+ @Override
+ public boolean removeProperty(String name)
+ {
+ return properties.remove(name);
+ }
+
+ @Override
+ public void addProperty(Property prop)
+ {
+ properties.add(prop);
+ }
+
+ @Override
+ public String toString()
+ {
+ return "OutputSet" + getPropertyNames();
+ }
+}
Property changes on: projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/OutputSetImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java
===================================================================
--- projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/TaskImpl.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -23,6 +23,10 @@
//$Id$
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
import javax.management.ObjectName;
import javax.persistence.Entity;
import javax.persistence.EnumType;
@@ -31,18 +35,26 @@
import org.jbpm.api.Constants;
import org.jbpm.api.InvalidProcessException;
+import org.jbpm.api.NotImplementedException;
import org.jbpm.api.client.ProcessEngine;
+import org.jbpm.api.model.Expression;
+import org.jbpm.api.model.InputSet;
import org.jbpm.api.model.Node;
+import org.jbpm.api.model.OutputSet;
import org.jbpm.api.model.ProcessStructure;
+import org.jbpm.api.model.Property;
import org.jbpm.api.model.SequenceFlow;
import org.jbpm.api.model.Signal;
import org.jbpm.api.model.Task;
import org.jbpm.api.model.builder.ObjectNameFactory;
+import org.jbpm.api.runtime.ExecutionContext;
+import org.jbpm.api.runtime.ExecutionHandler;
import org.jbpm.api.runtime.SignalHandler;
import org.jbpm.api.runtime.Token;
import org.jbpm.api.service.SignalService;
import org.jbpm.ri.model.builder.SingleInFlowSupport;
import org.jbpm.ri.model.builder.SingleOutFlowSupport;
+import org.jbpm.ri.runtime.MutableToken;
/**
* A Task is an Atomic Activity that is included within a Process.
@@ -62,6 +74,15 @@
@Enumerated(EnumType.STRING)
protected TaskType taskType;
+ @Transient
+ private List<InputSet> inputSets = new ArrayList<InputSet>();
+
+ @Transient
+ private List<OutputSet> outputSets = new ArrayList<OutputSet>();
+
+ @Transient
+ private List<Expression> ioRules = new ArrayList<Expression>();
+
public TaskImpl(ProcessStructure procStruct, String name, TaskType taskType)
{
super(procStruct, name);
@@ -117,6 +138,176 @@
}
@Override
+ public List<InputSet> getInputSets()
+ {
+ return Collections.unmodifiableList(inputSets);
+ }
+
+ public void addInputSet(InputSet inputSet)
+ {
+ inputSets.add(inputSet);
+ }
+
+ @Override
+ public List<OutputSet> getOutputSets()
+ {
+ return Collections.unmodifiableList(outputSets);
+ }
+
+ public void addOutputSet(OutputSet outputSet)
+ {
+ outputSets.add(outputSet);
+ }
+
+ public List<Expression> getIORules()
+ {
+ return Collections.unmodifiableList(ioRules);
+ }
+
+ public void addIORule(Expression expr)
+ {
+ ioRules.add(expr);
+ }
+
+ @Override
+ protected ExecutionHandler getDefaultExecutionHandler()
+ {
+ final Node thisNode = this;
+ final ExecutionHandler superExecHandler = super.getDefaultExecutionHandler();
+ return new ExecutionHandler()
+ {
+ private static final long serialVersionUID = 1L;
+
+ public void execute(Token token)
+ {
+ MutableToken mutableToken = (MutableToken)token;
+ mutableToken.setOutputSet(getActiveOutputSet());
+ mutableToken.setInputSet(getActiveInputSet(token));
+ superExecHandler.execute(token);
+ processOutputSet(token);
+ postProcessInputSet(token);
+ }
+
+ @Override
+ public Node getNode()
+ {
+ return thisNode;
+ }
+
+ @Override
+ public void setNode(Node node)
+ {
+ }
+ };
+ }
+
+ /**
+ * Select and validate active inputSet
+ */
+ protected InputSet getActiveInputSet(Token token)
+ {
+ InputSetImpl inputSet = null;
+ ExecutionContext exContext = token.getExecutionContext();
+
+ // Find the InputSet that matches the data in the Token
+ if (inputSets.size() > 0)
+ {
+ for (InputSet auxSet : inputSets)
+ {
+ boolean allInputPropsInContext = true;
+ for (String propName : auxSet.getPropertyNames())
+ {
+ Object att = exContext.getAttachment(propName);
+ allInputPropsInContext &= (att != null);
+ }
+ if (allInputPropsInContext == true)
+ {
+ inputSet = new InputSetImpl();
+ for (String propName : auxSet.getPropertyNames())
+ {
+ Object value = exContext.getAttachment(propName);
+ inputSet.addProperty(new PropertyImpl(propName, value));
+ }
+ break;
+ }
+ }
+ if (inputSet == null)
+ {
+ log.warn("InputSets: " + inputSets);
+ throw new IllegalStateException("Cannot find matching inputSet for " + exContext + " in Activity: " + getName());
+ }
+ }
+
+ // Create an empty input set
+ if (inputSet == null)
+ inputSet = new InputSetImpl();
+
+ return inputSet;
+ }
+
+ /**
+ * Select the active outputSet
+ */
+ protected OutputSet getActiveOutputSet()
+ {
+ OutputSet outputSet = null;
+ if (outputSets.size() > 0)
+ {
+ if (outputSets.size() > 1)
+ throw new NotImplementedException("JBPM-1635", "IORules and multiple outputSets");
+
+ outputSet = new OutputSetImpl();
+ OutputSet firstOutputSet = outputSets.get(0);
+ for (String propName : firstOutputSet.getPropertyNames())
+ {
+ Property prop = firstOutputSet.getProperty(propName);
+ outputSet.addProperty(prop);
+ }
+ }
+
+ // Create an empty output set
+ if (outputSet == null)
+ outputSet = new OutputSetImpl();
+
+ return outputSet;
+ }
+
+ /**
+ * Transfer data from outputSet to Token
+ */
+ protected void processOutputSet(Token token)
+ {
+ ExecutionContext exContext = token.getExecutionContext();
+
+ // Add the outputSet properties to the Token
+ OutputSet outputSet = token.getOutputSet();
+ for (String propName : getActiveOutputSet().getPropertyNames())
+ {
+ Property outProp = outputSet.getProperty(propName);
+ if (outProp == null)
+ throw new IllegalStateException("Cannot find outputSet property '" + propName + "' in: " + this);
+
+ String name = outProp.getName();
+ Object value = outProp.getValue();
+ exContext.addAttachment(name, value);
+ }
+ }
+
+ /**
+ * Remove the inputSet properties
+ */
+ protected void postProcessInputSet(Token token)
+ {
+ // InputSet inputSet = token.getInputSet();
+ // ExecutionContext exContext = token.getExecutionContext();
+ // for (Property prop : inputSet.getProperties())
+ // {
+ // // TODO: define proper scope for token data
+ // exContext.removeAttachment(prop.getName());
+ // }
+ }
+
+ @Override
protected SignalHandler getDefaultSignalHandler()
{
final Node thisNode = this;
Modified: projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/builder/TaskBuilderImpl.java
===================================================================
--- projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/builder/TaskBuilderImpl.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/model/builder/TaskBuilderImpl.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -23,9 +23,15 @@
//$Id$
+import org.jbpm.api.model.Property;
import org.jbpm.api.model.Task;
+import org.jbpm.api.model.Expression.ExpressionLanguage;
import org.jbpm.api.model.builder.TaskBuilder;
+import org.jbpm.ri.model.ExpressionImpl;
+import org.jbpm.ri.model.InputSetImpl;
import org.jbpm.ri.model.MessageImpl;
+import org.jbpm.ri.model.OutputSetImpl;
+import org.jbpm.ri.model.PropertyImpl;
import org.jbpm.ri.model.ReceiveTaskImpl;
import org.jbpm.ri.model.SendTaskImpl;
import org.jbpm.ri.model.TaskImpl;
@@ -38,11 +44,15 @@
*/
public class TaskBuilderImpl extends ProcessBuilderImpl implements TaskBuilder
{
+ private InputSetImpl inputSet;
+ private OutputSetImpl outputSet;
+
public TaskBuilderImpl(ProcessBuilderImpl procBuilder)
{
super(procBuilder);
}
+ @Override
public TaskBuilder addMessageRef(String msgName)
{
TaskImpl taskImpl = getTask();
@@ -63,6 +73,46 @@
return this;
}
+ @Override
+ public TaskBuilder addInputSet()
+ {
+ inputSet = new InputSetImpl();
+ getTask().addInputSet(inputSet);
+ return this;
+ }
+
+ @Override
+ public TaskBuilder addPropertyInput(String name)
+ {
+ Property prop = new PropertyImpl(name, null);
+ inputSet.addProperty(prop);
+ return this;
+ }
+
+ @Override
+ public TaskBuilder addOutputSet()
+ {
+ outputSet = new OutputSetImpl();
+ getTask().addOutputSet(outputSet);
+ return this;
+ }
+
+ @Override
+ public TaskBuilder addPropertyOutput(String name, String value)
+ {
+ Property prop = new PropertyImpl(name, value);
+ outputSet.addProperty(prop);
+ return this;
+ }
+
+ @Override
+ public TaskBuilder addIORule(String body, ExpressionLanguage lang)
+ {
+ ExpressionImpl expr = new ExpressionImpl(lang, body);
+ getTask().addIORule(expr);
+ return this;
+ }
+
private TaskImpl getTask()
{
if (node instanceof TaskImpl == false)
Modified: projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/DelegatingToken.java
===================================================================
--- projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/DelegatingToken.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/DelegatingToken.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -23,7 +23,9 @@
//$Id$
+import org.jbpm.api.model.InputSet;
import org.jbpm.api.model.Node;
+import org.jbpm.api.model.OutputSet;
import org.jbpm.api.model.SequenceFlow;
import org.jbpm.api.runtime.ExecutionContext;
import org.jbpm.api.runtime.Token;
@@ -68,6 +70,16 @@
return delegateToken.getTokenID();
}
+ public InputSet getInputSet()
+ {
+ return delegateToken.getInputSet();
+ }
+
+ public OutputSet getOutputSet()
+ {
+ return delegateToken.getOutputSet();
+ }
+
public TokenStatus getTokenStatus()
{
return delegateToken.getTokenStatus();
@@ -88,6 +100,16 @@
delegateToken.setTokenStatus(status);
}
+ public void setInputSet(InputSet inputSet)
+ {
+ delegateToken.setInputSet(inputSet);
+ }
+
+ public void setOutputSet(OutputSet outputSet)
+ {
+ delegateToken.setOutputSet(outputSet);
+ }
+
public String toString()
{
Node node = getFlow().getTargetRef();
Modified: projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/MutableToken.java
===================================================================
--- projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/MutableToken.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/MutableToken.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -23,6 +23,8 @@
//$Id$
+import org.jbpm.api.model.InputSet;
+import org.jbpm.api.model.OutputSet;
import org.jbpm.api.model.SequenceFlow;
import org.jbpm.api.runtime.Token;
@@ -37,4 +39,8 @@
void setTokenStatus(TokenStatus status);
void setFlow(SequenceFlow flow);
+
+ void setOutputSet(OutputSet activeOutputSet);
+
+ void setInputSet(InputSet activeInputSet);
}
\ No newline at end of file
Modified: projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/TokenImpl.java
===================================================================
--- projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/TokenImpl.java 2008-10-06 17:09:29 UTC (rev 2490)
+++ projects/spec/trunk/modules/impl/src/main/java/org/jbpm/ri/runtime/TokenImpl.java 2008-10-06 17:59:38 UTC (rev 2491)
@@ -24,6 +24,8 @@
//$Id$
import org.jboss.util.id.UID;
+import org.jbpm.api.model.InputSet;
+import org.jbpm.api.model.OutputSet;
import org.jbpm.api.model.SequenceFlow;
import org.jbpm.api.runtime.Attachments;
import org.jbpm.api.runtime.BasicExecutionContext;
@@ -48,6 +50,8 @@
private String id;
private SequenceFlow flow;
private ExecutionContext context;
+ private InputSet inputSet;
+ private OutputSet outputSet;
private TokenStatus status;
/**
@@ -65,6 +69,28 @@
return id;
}
+ @Override
+ public InputSet getInputSet()
+ {
+ return inputSet;
+ }
+
+ public void setInputSet(InputSet inputSet)
+ {
+ this.inputSet = inputSet;
+ }
+
+ @Override
+ public OutputSet getOutputSet()
+ {
+ return outputSet;
+ }
+
+ public void setOutputSet(OutputSet outputSet)
+ {
+ this.outputSet = outputSet;
+ }
+
public TokenStatus getTokenStatus()
{
return status;
17 years, 7 months
JBoss JBPM SVN: r2490 - in projects/spec/trunk/modules/cts: src/test/java/org/jbpm/test/cts/gateway/exclusive and 4 other directories.
by do-not-reply@jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2008-10-06 13:09:29 -0400 (Mon, 06 Oct 2008)
New Revision: 2490
Modified:
projects/spec/trunk/modules/cts/pom.xml
projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/exclusive/ExclusiveGatewayMergeTest.java
projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/inclusive/InclusiveGatewayMergeTest.java
projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/parallel/ParallelGatewayMergeTest.java
projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/pattern/control/simplemerge/SimpleMergeTest.java
projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/pattern/control/synchronization/SynchronizationTest.java
Log:
Pass more gateway tests
Modified: projects/spec/trunk/modules/cts/pom.xml
===================================================================
--- projects/spec/trunk/modules/cts/pom.xml 2008-10-06 15:53:38 UTC (rev 2489)
+++ projects/spec/trunk/modules/cts/pom.xml 2008-10-06 17:09:29 UTC (rev 2490)
@@ -70,11 +70,8 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
- <exclude>org/jbpm/test/cts/gateway/exclusive/ExclusiveGatewayMergeTest.java</exclude>
<exclude>org/jbpm/test/cts/node/NodeInputSetTest.java</exclude>
<exclude>org/jbpm/test/cts/node/NodeOutputSetTest.java</exclude>
- <exclude>org/jbpm/test/pattern/control/simplemerge/SimpleMergeTest.java</exclude>
- <exclude>org/jbpm/test/pattern/control/synchronization/SynchronizationTest.java</exclude>
</excludes>
</configuration>
</plugin>
Modified: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/exclusive/ExclusiveGatewayMergeTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/exclusive/ExclusiveGatewayMergeTest.java 2008-10-06 15:53:38 UTC (rev 2489)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/exclusive/ExclusiveGatewayMergeTest.java 2008-10-06 17:09:29 UTC (rev 2490)
@@ -24,23 +24,14 @@
// $Id$
import java.io.IOException;
+import java.util.List;
-import org.jbpm.api.client.SignalListener;
-import org.jbpm.api.model.Message;
import org.jbpm.api.model.Process;
import org.jbpm.api.model.ProcessDefinition;
import org.jbpm.api.model.Signal;
-import org.jbpm.api.model.Assignment.AssignTime;
-import org.jbpm.api.model.Event.EventDetailType;
-import org.jbpm.api.model.Expression.ExpressionLanguage;
import org.jbpm.api.model.Gateway.GatewayType;
-import org.jbpm.api.model.Signal.SignalType;
-import org.jbpm.api.model.builder.EventBuilder;
-import org.jbpm.api.model.builder.MessageBuilder;
import org.jbpm.api.model.builder.ProcessBuilder;
import org.jbpm.api.model.builder.ProcessBuilderService;
-import org.jbpm.api.model.builder.TaskBuilder;
-import org.jbpm.api.service.SignalService;
import org.jbpm.api.test.CTSTestCase;
/**
@@ -53,163 +44,31 @@
*/
public class ExclusiveGatewayMergeTest extends CTSTestCase
{
- public void testGateA() throws Exception
+ public void testMerge() throws Exception
{
ProcessDefinition procDef = unregisterOnTearDown(getProcessDefinition());
Process proc = procDef.newInstance();
- // Add a signal listener that sends the other start trigger signal
- SignalService sigManager = SignalService.locateSignalService();
- MergeListener sigListener = new MergeListener(new Signal(getTestID(), SignalType.SYSTEM_START_TRIGGER, "B"));
- sigManager.addSignalListener(sigListener);
+ // Start the process
+ proc.startProcess();
- try
- {
- // Send start trigger signal
- proc.startProcess();
- sigManager.throwSignal(new Signal(getTestID(), SignalType.SYSTEM_START_TRIGGER, "A"));
+ // Wait for the process to end
+ proc.waitForEnd();
- // Wait for the process to end
- proc.waitForEnd();
- }
- finally
- {
- sigManager.removeSignalListener(sigListener);
- }
-
// Verify the result
- Message endMessage = getMessages().get(0);
- assertNotNull("EndMessage expected", endMessage);
- assertEquals("TaskA", endMessage.getProperty("taskValue").getValue());
+ List<Signal> endSignals = getSignals(Signal.SignalType.SYSTEM_END_EVENT_EXIT);
+ assertEquals(1, endSignals.size());
}
- public void testGateB() throws Exception
- {
- ProcessDefinition procDef = unregisterOnTearDown(getProcessDefinition());
- Process proc = procDef.newInstance();
-
- // Add a signal listener that sends the other start trigger signal
- SignalService sigManager = SignalService.locateSignalService();
- MergeListener sigListener = new MergeListener(new Signal(getTestID(), SignalType.SYSTEM_START_TRIGGER, "A"));
- sigManager.addSignalListener(sigListener);
-
- try
- {
- // Send start trigger signal
- proc.startProcess();
- sigManager.throwSignal(new Signal(getTestID(), SignalType.SYSTEM_START_TRIGGER, "B"));
-
- // Wait for the process to end
- proc.waitForEnd();
- }
- finally
- {
- sigManager.removeSignalListener(sigListener);
- }
-
- // Verify the result
- Message endMessage = getMessages().get(0);
- assertNotNull("EndMessage expected", endMessage);
- assertEquals("TaskB", endMessage.getProperty("taskValue").getValue());
- }
-
- public void testInvalidToken() throws Exception
- {
- ProcessDefinition procDef = unregisterOnTearDown(getProcessDefinition());
- Process proc = procDef.newInstance();
-
- // Add a signal listener that sends the other start trigger signal
- SignalService sigManager = SignalService.locateSignalService();
- MergeListener sigListener = new MergeListener(new Signal(getTestID(), SignalType.SYSTEM_START_TRIGGER, "A"));
- sigManager.addSignalListener(sigListener);
-
- try
- {
- // Send start trigger signal
- proc.startProcess();
- sigManager.throwSignal(new Signal(getTestID(), SignalType.SYSTEM_START_TRIGGER, "A"));
-
- try
- {
- proc.waitForEnd();
- fail("Expected: Unexpected token from: SequenceFlow[TaskA->Merge]");
- }
- catch (RuntimeException rte)
- {
- // expected
- }
- }
- finally
- {
- sigManager.removeSignalListener(sigListener);
- }
-
- // Add a signal listener that sends the other start trigger signal
- sigListener = new MergeListener(new Signal(getTestID(), SignalType.SYSTEM_START_TRIGGER, "B"));
- sigManager.addSignalListener(sigListener);
-
- try
- {
- // Send start trigger signal
- proc.startProcess();
- sigManager.throwSignal(new Signal(getTestID(), SignalType.SYSTEM_START_TRIGGER, "A"));
-
- // Wait for the process to end
- proc.waitForEnd();
- }
- finally
- {
- sigManager.removeSignalListener(sigListener);
- }
-
- // Verify the result
- Message endMessage = getMessages().get(0);
- assertNotNull("EndMessage expected", endMessage);
- assertEquals("TaskA", endMessage.getProperty("taskValue").getValue());
- }
-
public ProcessDefinition getProcessDefinition() throws IOException
{
ProcessBuilder procBuilder = ProcessBuilderService.locateProcessBuilder();
- EventBuilder eventBuilder = procBuilder.addProcess(getName()).addStartEvent("StartA", EventDetailType.Signal);
- eventBuilder.addSignalRef(SignalType.SYSTEM_START_TRIGGER, "A");
- TaskBuilder taskBuilder = procBuilder.addSequenceFlow("TaskA").addTask("TaskA");
- taskBuilder.addNodeAssignment(AssignTime.Start, ExpressionLanguage.MVEL, "'TaskA'", "taskValue");
- taskBuilder.addSequenceFlow("Merge");
- eventBuilder = procBuilder.addStartEvent("StartB", EventDetailType.Signal);
- eventBuilder.addSignalRef(SignalType.SYSTEM_START_TRIGGER, "B");
- taskBuilder = procBuilder.addSequenceFlow("TaskB").addTask("TaskB");
- taskBuilder.addNodeAssignment(AssignTime.Start, ExpressionLanguage.MVEL, "'TaskB'", "taskValue");
- taskBuilder.addSequenceFlow("Merge");
+ procBuilder.addProcess("ExclusiveGatewayMerge").addStartEvent("Start").addSequenceFlow("Split");
+ procBuilder.addGateway("Split", GatewayType.Inclusive).addSequenceFlow("TaskA").addSequenceFlow("TaskB");
+ procBuilder.addTask("TaskA").addSequenceFlow("Merge");
+ procBuilder.addTask("TaskB").addSequenceFlow("Merge");
procBuilder.addGateway("Merge", GatewayType.Exclusive).addSequenceFlow("End");
- procBuilder.addEndEvent("End", EventDetailType.Message).addMessageRef("EndMessage");
- MessageBuilder msgBuilder = procBuilder.addProcessMessage("EndMessage");
- msgBuilder.addToRef(getTestID()).addProperty("taskValue", null, true);
+ procBuilder.addEndEvent("End");
return procBuilder.getProcessDefinition();
}
-
- class MergeListener implements SignalListener
- {
- private Signal nextSignal;
-
- public MergeListener(Signal nextSignal)
- {
- this.nextSignal = nextSignal;
- }
-
- public boolean acceptSignal(Signal signal)
- {
- return signal.getSignalType() == SignalType.SYSTEM_GATEWAY_ENTER;
- }
-
- public void catchSignal(Signal signal)
- {
- if (nextSignal != null)
- {
- SignalService sigService = SignalService.locateSignalService();
- sigService.throwSignal(nextSignal);
- nextSignal = null;
- }
- }
- }
}
Modified: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/inclusive/InclusiveGatewayMergeTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/inclusive/InclusiveGatewayMergeTest.java 2008-10-06 15:53:38 UTC (rev 2489)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/inclusive/InclusiveGatewayMergeTest.java 2008-10-06 17:09:29 UTC (rev 2490)
@@ -43,12 +43,12 @@
*/
public class InclusiveGatewayMergeTest extends CTSTestCase
{
- public void testGateA() throws Exception
+ public void testSimpleMerge() throws Exception
{
ProcessDefinition procDef = unregisterOnTearDown(getProcessDefinition());
Process proc = procDef.newInstance();
- // Start the process and send start trigger signal
+ // Start the process
proc.startProcess();
// Wait for the process to end
Modified: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/parallel/ParallelGatewayMergeTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/parallel/ParallelGatewayMergeTest.java 2008-10-06 15:53:38 UTC (rev 2489)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/cts/gateway/parallel/ParallelGatewayMergeTest.java 2008-10-06 17:09:29 UTC (rev 2490)
@@ -52,7 +52,7 @@
ProcessDefinition procDef = unregisterOnTearDown(getProcessDefinition());
Process proc = procDef.newInstance();
- // Start the process and send start trigger signal
+ // Start the process
proc.startProcess();
// Wait for the process to end
Modified: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/pattern/control/simplemerge/SimpleMergeTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/pattern/control/simplemerge/SimpleMergeTest.java 2008-10-06 15:53:38 UTC (rev 2489)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/pattern/control/simplemerge/SimpleMergeTest.java 2008-10-06 17:09:29 UTC (rev 2490)
@@ -26,17 +26,12 @@
import java.io.IOException;
import java.util.List;
-import org.jbpm.api.client.SignalListener;
-import org.jbpm.api.model.Gateway;
import org.jbpm.api.model.Process;
import org.jbpm.api.model.ProcessDefinition;
import org.jbpm.api.model.Signal;
-import org.jbpm.api.model.Event.EventDetailType;
-import org.jbpm.api.model.Signal.SignalType;
-import org.jbpm.api.model.builder.EventBuilder;
+import org.jbpm.api.model.Gateway.GatewayType;
import org.jbpm.api.model.builder.ProcessBuilder;
import org.jbpm.api.model.builder.ProcessBuilderService;
-import org.jbpm.api.service.SignalService;
import org.jbpm.api.test.CTSTestCase;
/**
@@ -53,25 +48,12 @@
ProcessDefinition procDef = unregisterOnTearDown(getProcessDefinition());
Process proc = procDef.newInstance();
- // Add a signal listener that sends the other start trigger signal
- MergeListener sigListener = new MergeListener(procDef.getName(), new Signal(getTestID(), SignalType.SYSTEM_START_TRIGGER, "B"));
- SignalService sigManager = SignalService.locateSignalService();
- sigManager.addSignalListener(sigListener);
+ // Start the process
+ proc.startProcess();
- try
- {
- // Send start trigger signals
- proc.startProcess();
- sigManager.throwSignal(new Signal(getTestID(), SignalType.SYSTEM_START_TRIGGER, "A"));
+ // Wait for the process to end
+ proc.waitForEnd();
- // Wait for the process to end
- proc.waitForEnd();
- }
- finally
- {
- sigManager.removeSignalListener(sigListener);
- }
-
List<Signal> endSignals = getSignals(Signal.SignalType.SYSTEM_END_EVENT_EXIT);
assertEquals(2, endSignals.size());
}
@@ -79,37 +61,12 @@
public ProcessDefinition getProcessDefinition() throws IOException
{
ProcessBuilder procBuilder = ProcessBuilderService.locateProcessBuilder();
- EventBuilder eventBuilder = procBuilder.addProcess(getName()).addStartEvent("StartA", EventDetailType.Signal);
- eventBuilder.addSignalRef(SignalType.SYSTEM_START_TRIGGER, "A");
- eventBuilder = procBuilder.addSequenceFlow("Merge").addStartEvent("StartB", EventDetailType.Signal);
- eventBuilder.addSignalRef(SignalType.SYSTEM_START_TRIGGER, "B");
- procBuilder.addSequenceFlow("Merge").addGateway("Merge", Gateway.GatewayType.Inclusive).addSequenceFlow("End");
+ procBuilder.addProcess("ParallelGatewayMerge").addStartEvent("Start").addSequenceFlow("Split");
+ procBuilder.addGateway("Split", GatewayType.Inclusive).addSequenceFlow("TaskA").addSequenceFlow("TaskB");
+ procBuilder.addTask("TaskA").addSequenceFlow("Merge");
+ procBuilder.addTask("TaskB").addSequenceFlow("Merge");
+ procBuilder.addGateway("Merge", GatewayType.Inclusive).addSequenceFlow("End");
procBuilder.addEndEvent("End");
return procBuilder.getProcessDefinition();
}
-
- class MergeListener implements SignalListener
- {
- private Signal nextSignal;
-
- public MergeListener(String fromRef, Signal nextSignal)
- {
- this.nextSignal = nextSignal;
- }
-
- public boolean acceptSignal(Signal signal)
- {
- return signal.getSignalType() == SignalType.SYSTEM_GATEWAY_ENTER;
- }
-
- public void catchSignal(Signal signal)
- {
- if (nextSignal != null)
- {
- SignalService sigService = SignalService.locateSignalService();
- sigService.throwSignal(nextSignal);
- nextSignal = null;
- }
- }
- }
}
Modified: projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/pattern/control/synchronization/SynchronizationTest.java
===================================================================
--- projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/pattern/control/synchronization/SynchronizationTest.java 2008-10-06 15:53:38 UTC (rev 2489)
+++ projects/spec/trunk/modules/cts/src/test/java/org/jbpm/test/pattern/control/synchronization/SynchronizationTest.java 2008-10-06 17:09:29 UTC (rev 2490)
@@ -25,22 +25,16 @@
import java.io.IOException;
-import org.jbpm.api.client.SignalListener;
-import org.jbpm.api.model.Gateway;
import org.jbpm.api.model.Message;
import org.jbpm.api.model.Process;
import org.jbpm.api.model.ProcessDefinition;
-import org.jbpm.api.model.Signal;
import org.jbpm.api.model.Assignment.AssignTime;
import org.jbpm.api.model.Event.EventDetailType;
import org.jbpm.api.model.Expression.ExpressionLanguage;
-import org.jbpm.api.model.Signal.SignalType;
-import org.jbpm.api.model.builder.EventBuilder;
+import org.jbpm.api.model.Gateway.GatewayType;
import org.jbpm.api.model.builder.MessageBuilder;
import org.jbpm.api.model.builder.ProcessBuilder;
import org.jbpm.api.model.builder.ProcessBuilderService;
-import org.jbpm.api.model.builder.TaskBuilder;
-import org.jbpm.api.service.SignalService;
import org.jbpm.api.test.CTSTestCase;
/**
@@ -57,105 +51,13 @@
{
ProcessDefinition procDef = unregisterOnTearDown(getProcessDefinition());
Process proc = procDef.newInstance();
-
- // Add a signal listener that sends the other start trigger signal
- MergeListener sigListener = new MergeListener(new Signal(getTestID(), SignalType.SYSTEM_START_TRIGGER, "B"));
- SignalService sigManager = SignalService.locateSignalService();
- sigManager.addSignalListener(sigListener);
-
- try
- {
- // Start the process and send start trigger signal
- proc.startProcess();
- sigManager.throwSignal(new Signal(getTestID(), SignalType.SYSTEM_START_TRIGGER, "A"));
-
- // Wait for the process to end
- proc.waitForEnd();
- }
- finally
- {
- sigManager.removeSignalListener(sigListener);
- }
-
- // Verify the result
- Message endMessage = getMessages().get(0);
- assertEquals("TaskA", endMessage.getProperty("taskValueA").getValue());
- assertEquals("TaskB", endMessage.getProperty("taskValueB").getValue());
- }
-
- public void testMergeTimeout() throws Exception
- {
- ProcessDefinition procDef = unregisterOnTearDown(getProcessDefinition());
- Process proc = procDef.newInstance();
-
- // Start the process and send start trigger signal
+
+ // Start the process
proc.startProcess();
- SignalService sigService = SignalService.locateSignalService();
- sigService.throwSignal(new Signal(getTestID(), SignalType.SYSTEM_START_TRIGGER, "A"));
// Wait for the process to end
- try
- {
- proc.waitForEnd(1000);
- fail("timeout expected");
- }
- catch (RuntimeException rte)
- {
- // expected
- }
- }
+ proc.waitForEnd();
- public void testInvalidToken() throws Exception
- {
- ProcessDefinition procDef = unregisterOnTearDown(getProcessDefinition());
- Process proc = procDef.newInstance();
-
- // Add a signal listener that sends the other start trigger signal
- Signal startTrigger = new Signal(getTestID(), SignalType.SYSTEM_START_TRIGGER, "A");
- MergeListener sigListener = new MergeListener(startTrigger);
- SignalService sigManager = SignalService.locateSignalService();
- sigManager.addSignalListener(sigListener);
-
- try
- {
- // Start the process and send start trigger signal
- proc.startProcess();
- sigManager.throwSignal(new Signal(getTestID(), SignalType.SYSTEM_START_TRIGGER, "A"));
-
- try
- {
- proc.waitForEnd();
- fail("Expected: Unexpected token from: SequenceFlow[TaskA->Merge]");
- }
- catch (RuntimeException rte)
- {
- // expected
- }
- }
- finally
- {
- sigManager.removeSignalListener(sigListener);
- }
-
- // Add a signal listener that sends the other start trigger signal
- startTrigger = new Signal(getTestID(), SignalType.SYSTEM_START_TRIGGER, "B");
- sigListener = new MergeListener(startTrigger);
- sigManager.addSignalListener(sigListener);
-
- try
- {
- // Start the process and send start trigger signal
- proc.startProcess();
- sigManager.throwSignal(new Signal(getTestID(), SignalType.SYSTEM_START_TRIGGER, "A"));
-
- // Wait for the process to end
- proc.waitForEnd();
- }
- finally
- {
- sigManager.removeSignalListener(sigListener);
- }
-
// Verify the result
Message endMessage = getMessages().get(0);
assertEquals("TaskA", endMessage.getProperty("taskValueA").getValue());
@@ -165,45 +67,14 @@
public ProcessDefinition getProcessDefinition() throws IOException
{
ProcessBuilder procBuilder = ProcessBuilderService.locateProcessBuilder();
- EventBuilder eventBuilder = procBuilder.addProcess("Synchronization").addStartEvent("StartA", EventDetailType.Signal);
- eventBuilder.addSignalRef(SignalType.SYSTEM_START_TRIGGER, "A");
- TaskBuilder taskBuilder = procBuilder.addSequenceFlow("TaskA").addTask("TaskA");
- taskBuilder.addNodeAssignment(AssignTime.Start, ExpressionLanguage.MVEL, "'TaskA'", "taskValueA");
- taskBuilder.addSequenceFlow("Merge");
- eventBuilder = procBuilder.addStartEvent("StartB", EventDetailType.Signal);
- eventBuilder.addSignalRef(SignalType.SYSTEM_START_TRIGGER, "B");
- taskBuilder = procBuilder.addSequenceFlow("TaskB").addTask("TaskB");
- taskBuilder.addNodeAssignment(AssignTime.Start, ExpressionLanguage.MVEL, "'TaskB'", "taskValueB");
- taskBuilder.addSequenceFlow("Merge");
- procBuilder.addGateway("Merge", Gateway.GatewayType.Parallel).addSequenceFlow("End");
+ procBuilder.addProcess("ParallelGatewayMerge").addStartEvent("Start").addSequenceFlow("Split");
+ procBuilder.addGateway("Split", GatewayType.Parallel).addSequenceFlow("TaskA").addSequenceFlow("TaskB");
+ procBuilder.addTask("TaskA").addNodeAssignment(AssignTime.Start, ExpressionLanguage.MVEL, "'TaskA'", "taskValueA").addSequenceFlow("Merge");
+ procBuilder.addTask("TaskB").addNodeAssignment(AssignTime.Start, ExpressionLanguage.MVEL, "'TaskB'", "taskValueB").addSequenceFlow("Merge");
+ procBuilder.addGateway("Merge", GatewayType.Parallel).addSequenceFlow("End");
procBuilder.addEndEvent("End", EventDetailType.Message).addMessageRef("EndMessage");
MessageBuilder msgBuilder = procBuilder.addProcessMessage("EndMessage");
msgBuilder.addToRef(getTestID()).addProperty("taskValueA", null, true).addProperty("taskValueB", null, true);
return procBuilder.getProcessDefinition();
}
-
- public static class MergeListener implements SignalListener
- {
- private Signal nextSignal;
-
- public MergeListener(Signal nextSignal)
- {
- this.nextSignal = nextSignal;
- }
-
- public boolean acceptSignal(Signal signal)
- {
- return signal.getSignalType() == SignalType.SYSTEM_GATEWAY_ENTER;
- }
-
- public void catchSignal(Signal signal)
- {
- if (nextSignal != null)
- {
- SignalService sigService = SignalService.locateSignalService();
- sigService.throwSignal(nextSignal);
- nextSignal = null;
- }
- }
- }
}
17 years, 7 months