[jbpm-commits] JBoss JBPM SVN: r5708 - in jbpm4/trunk/modules: bpmn/src/main/java/org/jbpm/bpmn/flownodes and 18 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Oct 7 08:24:15 EDT 2009
Author: tom.baeyens at jboss.com
Date: 2009-10-07 08:24:14 -0400 (Wed, 07 Oct 2009)
New Revision: 5708
Added:
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluator.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluatorDescriptor.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExpressionCondition.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ExpressionDescriptor.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeActivityBehaviour.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeCondition.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeEventListener.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeReference.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/decision/
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/decision/DecisionTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskAssignmentHandlerExprTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskCandidatesTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskCompletionTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskOutcomesTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskReassignTest.java
Removed:
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/CustomActivity.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExpressionEvaluator.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/UserCodeReference.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ExpressionEvaluatorDescriptor.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/DecisionTest.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/mgmt/
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/taskactivity/
Modified:
jbpm4/trunk/modules/bpmn/pom.xml
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractGatewayBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ActivityResource.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/JavaServiceTaskActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ParallelGatewayActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskActivity.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BindingsParser.java
jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
jbpm4/trunk/modules/bpmn/src/test/java/org/jbpm/bpmn/flownodes/ScriptTaskTest.java
jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/decision/handler/ContentEvaluation.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/CustomBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionExpressionActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionHandlerActivity.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EventListenerBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskBinding.java
jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java
jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/AssignableDefinitionImpl.java
jbpm4/trunk/modules/test-cactus/src/test/java/org/jbpm/test/AllIntegrationTests.java
jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/eventlistener/EventListenerTest.java
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml
Log:
JBPM-2565 refactored usercode handling of event listeners, assignment handlers, decision handlers and decision conditions
Modified: jbpm4/trunk/modules/bpmn/pom.xml
===================================================================
--- jbpm4/trunk/modules/bpmn/pom.xml 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/bpmn/pom.xml 2009-10-07 12:24:14 UTC (rev 5708)
@@ -64,11 +64,13 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+ <!-- EXCLUDED THIS DEPENDENCY BECAUSE IT FAILED TO RESOLVE
+ IF YOU REINTRODUCE IT, MAKE SURE IT RESOLVES
<dependency>
<groupId>com.sun.script</groupId>
<artifactId>bsh-engine</artifactId>
<version>1.0.1</version>
- </dependency>
+ </dependency -->
</dependencies>
<!-- Plugins -->
@@ -79,6 +81,7 @@
<configuration>
<excludes>
<exclude>org/jbpm/test/xml/DbGenTest.java</exclude>
+ <exclude>org/jbpm/bpmn/flownodes/ScriptTaskTest.java</exclude>
</excludes>
</configuration>
</plugin>
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractGatewayBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractGatewayBinding.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/AbstractGatewayBinding.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -4,8 +4,6 @@
import org.jbpm.pvm.internal.wire.binding.ObjectBinding;
import org.jbpm.pvm.internal.wire.xml.WireParser;
import org.jbpm.pvm.internal.xml.Parse;
-import org.jbpm.pvm.internal.xml.Parser;
-
import org.w3c.dom.Element;
public abstract class AbstractGatewayBinding extends BpmnBinding {
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ActivityResource.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ActivityResource.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ActivityResource.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -1,7 +1,7 @@
package org.jbpm.bpmn.flownodes;
import org.jbpm.bpmn.common.Resource;
-import org.jbpm.pvm.internal.wire.descriptor.ExpressionEvaluatorDescriptor;
+import org.jbpm.bpmn.parser.ExpressionEvaluatorDescriptor;
public class ActivityResource {
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/JavaServiceTaskActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/JavaServiceTaskActivity.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/JavaServiceTaskActivity.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -26,7 +26,6 @@
import org.jbpm.api.JbpmException;
import org.jbpm.api.model.OpenExecution;
-import org.jbpm.pvm.internal.env.EnvironmentDefaults;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.script.ScriptManager;
import org.jbpm.pvm.internal.util.ReflectUtil;
@@ -62,7 +61,7 @@
invocationTarget = target;
} else if (targetExpression!=null) {
- ScriptManager scriptManager = EnvironmentDefaults.getScriptManager();
+ ScriptManager scriptManager = ScriptManager.getScriptManager();
invocationTarget = scriptManager.evaluateExpression(targetExpression, targetLanguage);
} else {
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ParallelGatewayActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ParallelGatewayActivity.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ParallelGatewayActivity.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -29,11 +29,9 @@
import org.jbpm.api.Execution;
import org.jbpm.api.JbpmException;
import org.jbpm.api.activity.ActivityExecution;
-import org.jbpm.bpmn.parser.BpmnParser;
import org.jbpm.internal.log.Log;
-import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.model.Activity;
-import org.jbpm.pvm.internal.model.Condition;
import org.jbpm.pvm.internal.model.ExecutionImpl;
import org.jbpm.pvm.internal.model.Transition;
@@ -90,7 +88,7 @@
} else if (Execution.STATE_ACTIVE_CONCURRENT.equals(execution.getState())) {
// force version increment in the parent execution
- Session session = Environment.getFromCurrent(Session.class);
+ Session session = EnvironmentImpl.getFromCurrent(Session.class);
session.lock(execution.getParent(), lockMode);
execution.setState(Execution.STATE_INACTIVE_JOIN);
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskActivity.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskActivity.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -22,11 +22,11 @@
package org.jbpm.bpmn.flownodes;
import org.jbpm.api.model.OpenExecution;
+import org.jbpm.bpmn.parser.ExpressionEvaluator;
+import org.jbpm.bpmn.parser.ExpressionEvaluatorDescriptor;
import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.model.ExpressionEvaluator;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.WireException;
-import org.jbpm.pvm.internal.wire.descriptor.ExpressionEvaluatorDescriptor;
public class ScriptTaskActivity extends BpmnAutomaticActivity {
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskBinding.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/ScriptTaskBinding.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -21,8 +21,8 @@
*/
package org.jbpm.bpmn.flownodes;
+import org.jbpm.bpmn.parser.ExpressionEvaluatorDescriptor;
import org.jbpm.pvm.internal.util.XmlUtil;
-import org.jbpm.pvm.internal.wire.descriptor.ExpressionEvaluatorDescriptor;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskActivity.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/TaskActivity.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -21,28 +21,10 @@
*/
package org.jbpm.bpmn.flownodes;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.jbpm.api.Execution;
-import org.jbpm.api.JbpmException;
import org.jbpm.api.activity.ActivityExecution;
-import org.jbpm.api.task.Task;
import org.jbpm.internal.log.Log;
-import org.jbpm.pvm.internal.env.Environment;
-import org.jbpm.pvm.internal.history.HistoryEvent;
-import org.jbpm.pvm.internal.history.events.TaskActivityStart;
-import org.jbpm.pvm.internal.model.Activity;
-import org.jbpm.pvm.internal.model.Condition;
import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.model.Transition;
-import org.jbpm.pvm.internal.session.DbSession;
-import org.jbpm.pvm.internal.task.ParticipationImpl;
-import org.jbpm.pvm.internal.task.SwimlaneDefinitionImpl;
-import org.jbpm.pvm.internal.task.SwimlaneImpl;
import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
-import org.jbpm.pvm.internal.task.TaskImpl;
/**
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskActivity.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskActivity.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskActivity.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -21,29 +21,21 @@
*/
package org.jbpm.bpmn.flownodes;
-import java.util.List;
import java.util.Map;
-import org.jbpm.api.JbpmException;
import org.jbpm.api.activity.ActivityExecution;
-import org.jbpm.api.task.Task;
+import org.jbpm.bpmn.parser.ExpressionEvaluator;
+import org.jbpm.bpmn.parser.ExpressionEvaluatorDescriptor;
import org.jbpm.internal.log.Log;
-import org.jbpm.pvm.internal.env.Environment;
+import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.history.HistoryEvent;
import org.jbpm.pvm.internal.history.events.TaskActivityStart;
import org.jbpm.pvm.internal.model.Activity;
-import org.jbpm.pvm.internal.model.Condition;
import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.model.ExpressionEvaluator;
-import org.jbpm.pvm.internal.model.Transition;
import org.jbpm.pvm.internal.session.DbSession;
-import org.jbpm.pvm.internal.task.ParticipationImpl;
-import org.jbpm.pvm.internal.task.SwimlaneDefinitionImpl;
-import org.jbpm.pvm.internal.task.SwimlaneImpl;
import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
import org.jbpm.pvm.internal.task.TaskImpl;
import org.jbpm.pvm.internal.wire.WireContext;
-import org.jbpm.pvm.internal.wire.descriptor.ExpressionEvaluatorDescriptor;
/**
* @author Tom Baeyens
@@ -61,7 +53,7 @@
}
public void execute(ExecutionImpl execution) {
- DbSession dbSession = Environment.getFromCurrent(DbSession.class);
+ DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
TaskImpl task = (TaskImpl) dbSession.createTask();
task.setTaskDefinition(taskDefinition);
task.setExecution(execution);
@@ -121,7 +113,7 @@
execution.fire(signalName, activity);
- DbSession taskDbSession = Environment.getFromCurrent(DbSession.class);
+ DbSession taskDbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
TaskImpl task = (TaskImpl) taskDbSession.findTaskByExecution(execution);
task.setSignalling(false);
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/flownodes/UserTaskBinding.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -21,8 +21,6 @@
*/
package org.jbpm.bpmn.flownodes;
-import java.util.List;
-
import org.jbpm.bpmn.model.BpmnProcessDefinition;
import org.jbpm.bpmn.parser.BpmnParser;
import org.jbpm.pvm.internal.model.ScopeElementImpl;
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BindingsParser.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BindingsParser.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BindingsParser.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -59,7 +59,8 @@
if (bindingClassName != null) {
try {
- Class< ? > bindingClass = ReflectUtil.loadClass(classLoader, bindingClassName);
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ Class< ? > bindingClass = Class.forName(bindingClassName, true, classLoader);
return (Binding) bindingClass.newInstance();
} catch (Exception e) {
parse.addProblem("couldn't instantiate activity binding " + bindingClassName, e);
Modified: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/BpmnParser.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -35,9 +35,7 @@
import org.jbpm.bpmn.flownodes.BpmnBinding;
import org.jbpm.bpmn.flownodes.ExclusiveGatewayActivity;
import org.jbpm.bpmn.model.BpmnProcessDefinition;
-
import org.jbpm.internal.log.Log;
-
import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.model.CompositeElementImpl;
import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
@@ -45,11 +43,9 @@
import org.jbpm.pvm.internal.model.TransitionImpl;
import org.jbpm.pvm.internal.model.VariableDefinitionImpl;
import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
-import org.jbpm.pvm.internal.util.ReflectUtil;
import org.jbpm.pvm.internal.util.TagBinding;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.binding.ObjectBinding;
-import org.jbpm.pvm.internal.wire.descriptor.ExpressionEvaluatorDescriptor;
import org.jbpm.pvm.internal.wire.xml.WireParser;
import org.jbpm.pvm.internal.xml.Bindings;
import org.jbpm.pvm.internal.xml.Parse;
@@ -149,7 +145,7 @@
setBindings(bindings);
for (String activityResource : DEFAULT_ACTIVITIES_RESOURCES) {
- Enumeration<URL> resourceUrls = ReflectUtil.getResources(null, activityResource);
+ Enumeration<URL> resourceUrls = getResources(activityResource);
if (resourceUrls.hasMoreElements()) {
while (resourceUrls.hasMoreElements()) {
URL resourceUrl = resourceUrls.nextElement();
@@ -168,6 +164,17 @@
}
}
+ protected Enumeration<URL> getResources(String resourceName) {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ Enumeration<URL> resourceUrls;
+ try {
+ resourceUrls = classLoader.getResources(resourceName);
+ } catch (Exception e) {
+ throw new JbpmException("couldn't get resource urls for "+resourceName, e);
+ }
+ return resourceUrls;
+ }
+
private void parseDataObjects(Element element, Parse parse, BpmnProcessDefinition processDefinition) {
List<VariableDefinitionImpl> variableDefinitions = new ArrayList<VariableDefinitionImpl>();
@@ -209,7 +216,7 @@
activity.setDescription(name);
log.debug("Parse Activity: " + name);
ActivityBehaviour activityBehaviour = (ActivityBehaviour) activityBinding.parse(nestedElement, parse, this);
- activity.setBehaviour(activityBehaviour);
+ activity.setActivityBehaviour(activityBehaviour);
} finally {
parse.contextStackPop();
}
@@ -233,7 +240,7 @@
try {
// If something went wrong parsing the activity, there is no behaviour and an exception is thrown in .getBehaviour()
- ActivityBehaviour a = compositeElement.findActivity(sourceRef).getBehaviour();
+ ActivityBehaviour a = compositeElement.findActivity(sourceRef).getActivityBehaviour();
if (a instanceof ExclusiveGatewayActivity) {
if (transitionId.equals(((ExclusiveGatewayActivity) a).getDefault())) {
compositeElement.findActivity(sourceRef).setDefaultOutgoingTransition(transition);
@@ -258,8 +265,10 @@
String lang = XmlUtil.attribute(conditionElement, "language");
// TODO: add looking up the default language in the document if lang
// is null.
- ExpressionEvaluatorDescriptor expressionDescriptor = new ExpressionEvaluatorDescriptor(expr, lang);
- transition.setConditionDescriptor(expressionDescriptor);
+
+// TODO refactor according to PVM updates. see package org.jbpm.pvm.internal.wire.usercode
+// ExpressionEvaluatorDescriptor expressionDescriptor = new ExpressionEvaluatorDescriptor(expr, lang);
+// transition.setConditionDescriptor(expressionDescriptor);
} else {
parse.addProblem("Type of the conditionExpression on sequenceFlow with id=" + transitionId + " is of onsupported type 'bpmn:tExpression'",
Copied: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluator.java (from rev 5705, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExpressionEvaluator.java)
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluator.java (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluator.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.bpmn.parser;
+
+import org.jbpm.api.model.OpenExecution;
+import org.jbpm.pvm.internal.model.Condition;
+import org.jbpm.pvm.internal.script.ScriptManager;
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExpressionEvaluator implements Condition {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String name;
+ protected String expr;
+ protected String lang;
+
+ public ExpressionEvaluator(String name, String expr, String lang) {
+ this.name = name;
+ this.expr = expr;
+ this.lang = lang;
+ }
+
+ public boolean evaluate(OpenExecution execution) {
+ return (Boolean) evaluateExpression(execution);
+ }
+
+ public Object evaluateExpression(OpenExecution execution) {
+ ScriptManager scriptManager = ScriptManager.getScriptManager();
+ return scriptManager.evaluateExpression(expr, lang);
+ }
+
+ public String getName() {
+ return name;
+ }
+}
Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluator.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluatorDescriptor.java (from rev 5705, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ExpressionEvaluatorDescriptor.java)
===================================================================
--- jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluatorDescriptor.java (rev 0)
+++ jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluatorDescriptor.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.bpmn.parser;
+
+import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.descriptor.AbstractDescriptor;
+
+
+/**
+ * @author Tom Baeyens
+ *
+ * @deprecated to be replaced by {@link UserCodeReference} see also package org.jbpm.pvm.internal.wire.usercode
+ */
+public class ExpressionEvaluatorDescriptor extends AbstractDescriptor {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String expr;
+ protected String lang;
+
+ public ExpressionEvaluatorDescriptor() {
+ }
+
+ public ExpressionEvaluatorDescriptor(String expr, String lang) {
+ this.expr = expr;
+ this.lang = lang;
+ }
+
+ public Object construct(WireContext wireContext) {
+ return new ExpressionEvaluator(getName(), expr, lang);
+ }
+
+}
Property changes on: jbpm4/trunk/modules/bpmn/src/main/java/org/jbpm/bpmn/parser/ExpressionEvaluatorDescriptor.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: jbpm4/trunk/modules/bpmn/src/test/java/org/jbpm/bpmn/flownodes/ScriptTaskTest.java
===================================================================
--- jbpm4/trunk/modules/bpmn/src/test/java/org/jbpm/bpmn/flownodes/ScriptTaskTest.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/bpmn/src/test/java/org/jbpm/bpmn/flownodes/ScriptTaskTest.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -21,24 +21,14 @@
*/
package org.jbpm.bpmn.flownodes;
-import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.dom4j.DocumentFactory;
import org.jbpm.api.ProcessInstance;
-import org.jbpm.api.TaskQuery;
-import org.jbpm.api.task.Task;
import org.jbpm.bpmn.parser.BpmnParser;
-import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.xml.Problem;
import org.jbpm.test.JbpmTestCase;
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
/**
* @author Tom Baeyens
Modified: jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/decision/handler/ContentEvaluation.java
===================================================================
--- jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/decision/handler/ContentEvaluation.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/examples/src/test/java/org/jbpm/examples/decision/handler/ContentEvaluation.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -26,6 +26,8 @@
public class ContentEvaluation implements DecisionHandler {
+ private static final long serialVersionUID = 1L;
+
public String decide(OpenExecution execution) {
String content = (String) execution.getVariable("content");
if (content.equals("you're great")) {
Deleted: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/CustomActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/CustomActivity.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/CustomActivity.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -1,54 +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.jpdl.internal.activity;
-
-import java.util.Map;
-
-import org.jbpm.api.activity.ActivityBehaviour;
-import org.jbpm.api.activity.ActivityExecution;
-import org.jbpm.api.activity.ExternalActivityBehaviour;
-import org.jbpm.pvm.internal.wire.UserCodeReference;
-
-
-/**
- * @author Tom Baeyens
- */
-public class CustomActivity extends JpdlExternalActivity {
-
- private static final long serialVersionUID = 1L;
-
- protected UserCodeReference customActivityReference;
-
- public void execute(ActivityExecution execution) throws Exception {
- ActivityBehaviour activityBehaviour = (ActivityBehaviour) customActivityReference.getObject(execution);
- activityBehaviour.execute(execution);
- }
-
- public void signal(ActivityExecution execution, String signalName, Map<String, ? > parameters) throws Exception {
- ExternalActivityBehaviour externalActivityBehaviour = (ExternalActivityBehaviour) customActivityReference.getObject(execution);
- externalActivityBehaviour.signal(execution, signalName, parameters);
- }
-
- public void setCustomActivityReference(UserCodeReference customActivityReference) {
- this.customActivityReference = customActivityReference;
- }
-}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/CustomBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/CustomBinding.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/CustomBinding.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -22,9 +22,10 @@
package org.jbpm.jpdl.internal.activity;
import org.jbpm.jpdl.internal.xml.JpdlParser;
-import org.jbpm.pvm.internal.wire.UserCodeReference;
import org.jbpm.pvm.internal.wire.binding.ObjectBinding;
import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.usercode.UserCodeActivityBehaviour;
+import org.jbpm.pvm.internal.wire.usercode.UserCodeReference;
import org.jbpm.pvm.internal.xml.Parse;
import org.w3c.dom.Element;
@@ -41,9 +42,9 @@
}
public Object parseJpdl(Element element, Parse parse, JpdlParser parser) {
- CustomActivity customActivity = new CustomActivity();
+ UserCodeActivityBehaviour userCodeActivityBehaviour = new UserCodeActivityBehaviour();
UserCodeReference customActivityReference = parser.parseUserCodeReference(element, parse);
- customActivity.setCustomActivityReference(customActivityReference);
- return customActivity;
+ userCodeActivityBehaviour.setCustomActivityReference(customActivityReference);
+ return userCodeActivityBehaviour;
}
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionBinding.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionBinding.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -27,11 +27,8 @@
import org.jbpm.pvm.internal.model.ActivityImpl;
import org.jbpm.pvm.internal.model.TransitionImpl;
import org.jbpm.pvm.internal.util.XmlUtil;
-import org.jbpm.pvm.internal.wire.binding.ObjectBinding;
-import org.jbpm.pvm.internal.wire.descriptor.ExpressionEvaluatorDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.ReferenceDescriptor;
-import org.jbpm.pvm.internal.wire.xml.WireParser;
+import org.jbpm.pvm.internal.wire.usercode.UserCodeCondition;
+import org.jbpm.pvm.internal.wire.usercode.UserCodeReference;
import org.jbpm.pvm.internal.xml.Parse;
import org.w3c.dom.Element;
@@ -41,9 +38,6 @@
*/
public class DecisionBinding extends JpdlBinding {
- static ObjectBinding objectBinding = new ObjectBinding();
- static WireParser wireParser = WireParser.getInstance();
-
public DecisionBinding() {
super("decision");
}
@@ -52,23 +46,16 @@
if (element.hasAttribute("expr")) {
DecisionExpressionActivity decisionExpressionActivity = new DecisionExpressionActivity();
String expr = element.getAttribute("expr");
- decisionExpressionActivity.setExpr(expr);
+ decisionExpressionActivity.setExpression(expr);
+ decisionExpressionActivity.setLanguage(XmlUtil.attribute(element, "lang"));
return decisionExpressionActivity;
}
- if (element.hasAttribute("handler-ref")) {
- String decisionHandlerName = element.getAttribute("handler-ref");
- DecisionHandlerActivity decisionHandlerActivity = new DecisionHandlerActivity();
- decisionHandlerActivity.setDecisionHandlerName(decisionHandlerName);
- return decisionHandlerActivity;
- }
-
Element handlerElement = XmlUtil.element(element, "handler");
if (handlerElement!=null) {
DecisionHandlerActivity decisionHandlerActivity = new DecisionHandlerActivity();
- ObjectDescriptor decisionHandlerDescriptor = (ObjectDescriptor)
- objectBinding.parse(handlerElement, parse, wireParser);
- decisionHandlerActivity.setDecisionHandlerDescriptor(decisionHandlerDescriptor);
+ UserCodeReference decisionHandlerReference = parser.parseUserCodeReference(handlerElement, parse);
+ decisionHandlerActivity.setDecisionHandlerReference(decisionHandlerReference);
return decisionHandlerActivity;
}
@@ -86,19 +73,21 @@
hasConditions = true;
if (conditionElement.hasAttribute("expr")) {
- String expr = conditionElement.getAttribute("expr");
- String lang = XmlUtil.attribute(conditionElement, "expr-lang");
- ExpressionEvaluatorDescriptor expressionDescriptor = new ExpressionEvaluatorDescriptor(expr, lang);
- transition.setConditionDescriptor(expressionDescriptor);
+ ExpressionCondition expressionCondition = new ExpressionCondition();
+ expressionCondition.setExpression(conditionElement.getAttribute("expr"));
+ expressionCondition.setLanguage(XmlUtil.attribute(conditionElement, "lang"));
+ transition.setCondition(expressionCondition);
- } else if (conditionElement.hasAttribute("ref")) {
- String expr = conditionElement.getAttribute("ref");
- ReferenceDescriptor refDescriptor = new ReferenceDescriptor(expr);
- transition.setConditionDescriptor(refDescriptor);
-
- } else if (ObjectBinding.isObjectDescriptor(conditionElement)) {
- ObjectDescriptor conditionDescriptor = (ObjectDescriptor) objectBinding.parse(conditionElement, parse, parser);
- transition.setConditionDescriptor(conditionDescriptor);
+ } else {
+ Element conditionHandlerElement = XmlUtil.element(conditionElement, "handler");
+ if (handlerElement!=null) {
+ UserCodeCondition userCodeCondition = new UserCodeCondition();
+
+ UserCodeReference conditionReference = parser.parseUserCodeReference(conditionHandlerElement, parse);
+ userCodeCondition.setConditionReference(conditionReference);
+
+ transition.setCondition(userCodeCondition);
+ }
}
}
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionExpressionActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionExpressionActivity.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionExpressionActivity.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -35,8 +35,8 @@
private static final long serialVersionUID = 1L;
- protected String expr;
- protected String lang;
+ protected String expression;
+ protected String language;
public void execute(ActivityExecution execution) {
execute((ExecutionImpl) execution);
@@ -47,17 +47,17 @@
String transitionName = null;
ScriptManager scriptManager = ScriptManager.getScriptManager();
- Object result = scriptManager.evaluateExpression(expr, lang);
+ Object result = scriptManager.evaluateExpression(expression, language);
if ( (result!=null)
&& (! (result instanceof String))
) {
- throw new JbpmException("expression '"+expr+"' in decision '"+activity.getName()+"' returned "+result.getClass().getName()+" instead of a transitionName (String): "+result);
+ throw new JbpmException("expression '"+expression+"' in decision '"+activity.getName()+"' returned "+result.getClass().getName()+" instead of a transitionName (String): "+result);
}
transitionName = (String) result;
Transition transition = activity.getOutgoingTransition(transitionName);
if (transition==null) {
- throw new JbpmException("expression '"+expr+"' in decision '"+activity.getName()+"' returned unexisting outgoing transition name: "+transitionName);
+ throw new JbpmException("expression '"+expression+"' in decision '"+activity.getName()+"' returned unexisting outgoing transition name: "+transitionName);
}
execution.historyDecision(transitionName);
@@ -65,10 +65,10 @@
execution.take(transition);
}
- public void setExpr(String expr) {
- this.expr = expr;
+ public void setExpression(String expr) {
+ this.expression = expr;
}
- public void setLang(String lang) {
- this.lang = lang;
+ public void setLanguage(String lang) {
+ this.language = lang;
}
}
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionHandlerActivity.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionHandlerActivity.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/DecisionHandlerActivity.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -22,16 +22,12 @@
package org.jbpm.jpdl.internal.activity;
import org.jbpm.api.JbpmException;
-import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.activity.ActivityExecution;
import org.jbpm.api.jpdl.DecisionHandler;
-import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.model.Activity;
import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
import org.jbpm.pvm.internal.model.Transition;
-import org.jbpm.pvm.internal.util.ReflectUtil;
-import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.usercode.UserCodeReference;
/**
* @author Tom Baeyens
@@ -40,9 +36,7 @@
private static final long serialVersionUID = 1L;
- protected String decisionHandlerName;
- protected Descriptor decisionHandlerDescriptor;
- protected DecisionHandler decisionHandler;
+ UserCodeReference decisionHandlerReference;
public void execute(ActivityExecution execution) {
execute((ExecutionImpl) execution);
@@ -53,26 +47,17 @@
String transitionName = null;
- DecisionHandler usedDecisionHandler = null;
- if (decisionHandlerDescriptor!=null) {
-
- usedDecisionHandler = getDecisionHandler(activity.getProcessDefinition());
-
- } else if (decisionHandlerName!=null) {
- EnvironmentImpl environment = EnvironmentImpl.getCurrent();
- Object object = environment.get(decisionHandlerName);
- if (object==null) {
- throw new JbpmException("decision handler for "+activity+" is null");
- }
- if (! (object instanceof DecisionHandler)) {
- throw new JbpmException("handler for decision is not a "+DecisionHandler.class.getName()+": "+object.getClass().getName());
- }
- usedDecisionHandler = (DecisionHandler) object;
- } else {
+ DecisionHandler decisionHandler = null;
+
+ if (decisionHandlerReference!=null) {
+ decisionHandler = (DecisionHandler) decisionHandlerReference.getObject(execution);
+ }
+
+ if (decisionHandler==null) {
throw new JbpmException("no decision handler specified");
}
- transitionName = usedDecisionHandler.decide(execution);
+ transitionName = decisionHandler.decide(execution);
Transition transition = activity.getOutgoingTransition(transitionName);
if (transition==null) {
@@ -84,22 +69,7 @@
execution.take(transition);
}
- public synchronized DecisionHandler getDecisionHandler(ProcessDefinition processDefinition) {
- if ( (decisionHandlerDescriptor!=null)
- && (decisionHandler==null)
- ) {
- decisionHandler = (DecisionHandler) ReflectUtil.instantiateUserCode(decisionHandlerDescriptor, (ProcessDefinitionImpl) processDefinition);
- }
- return decisionHandler;
+ public void setDecisionHandlerReference(UserCodeReference decisionHandlerReference) {
+ this.decisionHandlerReference = decisionHandlerReference;
}
-
- public void setDecisionHandlerName(String decisionHandlerName) {
- this.decisionHandlerName = decisionHandlerName;
- }
- public void setDecisionHandler(DecisionHandler decisionHandler) {
- this.decisionHandler = decisionHandler;
- }
- public void setDecisionHandlerDescriptor(Descriptor decisionHandlerDescriptor) {
- this.decisionHandlerDescriptor = decisionHandlerDescriptor;
- }
-}
+}
\ No newline at end of file
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EventListenerBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EventListenerBinding.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/EventListenerBinding.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -21,11 +21,9 @@
*/
package org.jbpm.jpdl.internal.activity;
-import org.jbpm.api.listener.EventListener;
import org.jbpm.jpdl.internal.xml.JpdlParser;
-import org.jbpm.pvm.internal.wire.Descriptor;
-import org.jbpm.pvm.internal.wire.JbpmClassNotFoundException;
-import org.jbpm.pvm.internal.wire.WireContext;
+import org.jbpm.pvm.internal.wire.usercode.UserCodeEventListener;
+import org.jbpm.pvm.internal.wire.usercode.UserCodeReference;
import org.jbpm.pvm.internal.xml.Parse;
import org.w3c.dom.Element;
@@ -40,14 +38,12 @@
}
public Object parseJpdl(Element element, Parse parse, JpdlParser parser) {
- Descriptor eventListenerDescriptor = JpdlParser.parseObjectDescriptor(element, parse);
- try {
- EventListener eventListener = (EventListener) WireContext.create(eventListenerDescriptor);
- return eventListener;
-
- } catch (JbpmClassNotFoundException e) {
- return eventListenerDescriptor;
- }
+ UserCodeEventListener userCodeEventListener = new UserCodeEventListener();
+
+ UserCodeReference eventListenerReference = parser.parseUserCodeReference(element, parse);
+ userCodeEventListener.setEventListenerReference(eventListenerReference);
+
+ return userCodeEventListener;
}
}
Added: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExpressionCondition.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExpressionCondition.java (rev 0)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExpressionCondition.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.jpdl.internal.activity;
+
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.model.OpenExecution;
+import org.jbpm.pvm.internal.model.Condition;
+import org.jbpm.pvm.internal.script.ScriptManager;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExpressionCondition implements Condition {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String expression;
+ protected String language;
+
+ public boolean evaluate(OpenExecution execution) {
+ ScriptManager scriptManager = ScriptManager.getScriptManager();
+ Object result = scriptManager.evaluateExpression(expression, language);
+ if (result instanceof Boolean) {
+ return ((Boolean) result).booleanValue();
+ }
+ throw new JbpmException("expression condition '"+expression+"' did not return a boolean: "+result);
+ }
+
+ public void setExpression(String expression) {
+ this.expression = expression;
+ }
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+}
Property changes on: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/ExpressionCondition.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskBinding.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskBinding.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/TaskBinding.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -42,7 +42,7 @@
TaskActivity taskActivity = new TaskActivity();
ScopeElementImpl scopeElement = parse.contextStackFind(ScopeElementImpl.class);
- TaskDefinitionImpl taskDefinition = JpdlParser.parseTaskDefinition(element, parse, scopeElement);
+ TaskDefinitionImpl taskDefinition = parser.parseTaskDefinition(element, parse, scopeElement);
taskActivity.setTaskDefinition(taskDefinition);
return taskActivity;
Modified: jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java
===================================================================
--- jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/xml/JpdlParser.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -35,7 +35,6 @@
import org.jbpm.api.activity.ActivityBehaviour;
import org.jbpm.api.listener.EventListener;
import org.jbpm.api.model.Event;
-import org.jbpm.api.task.AssignmentHandler;
import org.jbpm.internal.log.Log;
import org.jbpm.jpdl.internal.activity.JpdlBinding;
import org.jbpm.jpdl.internal.activity.MailListener;
@@ -66,12 +65,12 @@
import org.jbpm.pvm.internal.task.TaskDefinitionImpl;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
-import org.jbpm.pvm.internal.wire.UserCodeReference;
import org.jbpm.pvm.internal.wire.WireContext;
import org.jbpm.pvm.internal.wire.binding.MailTemplateBinding;
import org.jbpm.pvm.internal.wire.binding.ObjectBinding;
import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
import org.jbpm.pvm.internal.wire.operation.Operation;
+import org.jbpm.pvm.internal.wire.usercode.UserCodeReference;
import org.jbpm.pvm.internal.wire.xml.WireParser;
import org.jbpm.pvm.internal.xml.Bindings;
import org.jbpm.pvm.internal.xml.Parse;
@@ -116,9 +115,7 @@
public JpdlParser() {
initialize();
-
parseBindings();
-
setSchemaResources(SCHEMA_RESOURCES);
}
@@ -240,7 +237,7 @@
if (swimlaneName!=null) {
SwimlaneDefinitionImpl swimlaneDefinition =
processDefinition.createSwimlaneDefinition(swimlaneName);
- JpdlParser.parseAssignmentAttributes(swimlaneElement, swimlaneDefinition, parse);
+ parseAssignmentAttributes(swimlaneElement, swimlaneDefinition, parse);
}
}
@@ -358,7 +355,7 @@
}
}
- public static TimerDefinitionImpl parseTimerDefinition(Element timerElement, Parse parse, ScopeElementImpl scopeElement) {
+ public TimerDefinitionImpl parseTimerDefinition(Element timerElement, Parse parse, ScopeElementImpl scopeElement) {
TimerDefinitionImpl timerDefinition = scopeElement.createTimerDefinition();
String duedate = XmlUtil.attribute(timerElement, "duedate");
@@ -492,7 +489,7 @@
}
}
- public static void parseAssignmentAttributes(Element element, AssignableDefinitionImpl assignableDefinition, Parse parse) {
+ public void parseAssignmentAttributes(Element element, AssignableDefinitionImpl assignableDefinition, Parse parse) {
Element descriptionElement = XmlUtil.element(element, "description");
if (descriptionElement!=null) {
String description = XmlUtil.getContentText(descriptionElement);
@@ -501,9 +498,8 @@
Element assignmentHandlerElement = XmlUtil.element(element, "assignment-handler");
if (assignmentHandlerElement!=null) {
- ObjectDescriptor objectDescriptor = parseObjectDescriptor(assignmentHandlerElement, parse);
- AssignmentHandler assignmentHandler = (AssignmentHandler) WireContext.create(objectDescriptor);
- assignableDefinition.setAssignmentHandler(assignmentHandler);
+ UserCodeReference assignmentHandlerReference = parseUserCodeReference(assignmentHandlerElement, parse);
+ assignableDefinition.setAssignmentHandlerReference(assignmentHandlerReference);
}
String assigneeExpression = XmlUtil.attribute(element, "assignee");
@@ -525,7 +521,7 @@
assignableDefinition.setCandidateGroupsExpressionLanguage(candidateGroupsExpressionLanguage);
}
- public static TaskDefinitionImpl parseTaskDefinition(Element element, Parse parse, ScopeElementImpl scopeElement) {
+ public TaskDefinitionImpl parseTaskDefinition(Element element, Parse parse, ScopeElementImpl scopeElement) {
TaskDefinitionImpl taskDefinition = new TaskDefinitionImpl();
String taskName = XmlUtil.attribute(element, "name");
@@ -552,7 +548,7 @@
}
}
- JpdlParser.parseAssignmentAttributes(element, taskDefinition, parse);
+ parseAssignmentAttributes(element, taskDefinition, parse);
// parse notification mail producer
Element notificationElement = XmlUtil.element(element, "notification");
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExecutionImpl.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -75,6 +75,7 @@
import org.jbpm.pvm.internal.type.Variable;
import org.jbpm.pvm.internal.util.EqualsUtil;
import org.jbpm.pvm.internal.util.Priority;
+import org.jbpm.pvm.internal.wire.usercode.UserCodeReference;
/**
* @author Tom Baeyens
@@ -752,12 +753,15 @@
}
}
- AssignmentHandler assignmentHandler = assignableDefinition.getAssignmentHandler();
- if (assignmentHandler!=null) {
- try {
- assignmentHandler.assign(assignable, this);
- } catch (Exception e) {
- throw new JbpmException("assignment handler threw exception: " + e, e);
+ UserCodeReference assignmentHandlerReference = assignableDefinition.getAssignmentHandlerReference();
+ if (assignmentHandlerReference!=null) {
+ AssignmentHandler assignmentHandler = (AssignmentHandler) assignmentHandlerReference.getObject(processDefinition);
+ if (assignmentHandler!=null) {
+ try {
+ assignmentHandler.assign(assignable, this);
+ } catch (Exception e) {
+ throw new JbpmException("assignment handler threw exception: " + e, e);
+ }
}
}
}
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExpressionEvaluator.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExpressionEvaluator.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/ExpressionEvaluator.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -1,56 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.model;
-
-import org.jbpm.api.model.OpenExecution;
-import org.jbpm.pvm.internal.script.ScriptManager;
-
-/**
- * @author Tom Baeyens
- */
-public class ExpressionEvaluator implements Condition {
-
- private static final long serialVersionUID = 1L;
-
- protected String name;
- protected String expr;
- protected String lang;
-
- public ExpressionEvaluator(String name, String expr, String lang) {
- this.name = name;
- this.expr = expr;
- this.lang = lang;
- }
-
- public boolean evaluate(OpenExecution execution) {
- return (Boolean) evaluateExpression(execution);
- }
-
- public Object evaluateExpression(OpenExecution execution) {
- ScriptManager scriptManager = ScriptManager.getScriptManager();
- return scriptManager.evaluateExpression(expr, lang);
- }
-
- public String getName() {
- return name;
- }
-}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/model/TransitionImpl.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -24,8 +24,6 @@
import java.util.List;
import org.jbpm.api.model.Event;
-import org.jbpm.pvm.internal.wire.Descriptor;
-import org.jbpm.pvm.internal.wire.WireContext;
/**
@@ -38,8 +36,7 @@
protected ActivityImpl source;
protected Integer sourceIndex;
protected ActivityImpl destination;
- protected Descriptor conditionDescriptor;
- protected Descriptor waitConditionDescriptor;
+ protected Condition condition;
/* Use one of the ActivityImpl.createOutgoingTransition methods instead. */
TransitionImpl() {
@@ -111,20 +108,6 @@
}
}
- public Condition getCondition() {
- if (conditionDescriptor==null) {
- return null;
- }
- return (Condition) WireContext.create(conditionDescriptor);
- }
-
- public Condition getWaitCondition() {
- if (waitConditionDescriptor==null) {
- return null;
- }
- return (Condition) WireContext.create(waitConditionDescriptor);
- }
-
public ActivityImpl getSource() {
return source;
}
@@ -137,26 +120,16 @@
public void setDestination(ActivityImpl destination) {
this.destination = destination;
}
- /** see <a href="#conditions">Conditions</a> */
- public Descriptor getConditionDescriptor() {
- return conditionDescriptor;
- }
- /** see <a href="#conditions">Conditions</a> */
- public void setConditionDescriptor(Descriptor conditionDescriptor) {
- this.conditionDescriptor = conditionDescriptor;
- }
- /** see <a href="#waitconditions">Wait conditions</a> */
- public Descriptor getWaitConditionDescriptor() {
- return waitConditionDescriptor;
- }
- /** see <a href="#waitconditions">Wait conditions</a> */
- public void setWaitConditionDescriptor(Descriptor waitConditionDescriptor) {
- this.waitConditionDescriptor = waitConditionDescriptor;
- }
public Integer getSourceIndex() {
return sourceIndex;
}
public void setSourceIndex(Integer sourceIndex) {
this.sourceIndex = sourceIndex;
}
+ public Condition getCondition() {
+ return condition;
+ }
+ public void setCondition(Condition condition) {
+ this.condition = condition;
+ }
}
Modified: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/AssignableDefinitionImpl.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/AssignableDefinitionImpl.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/task/AssignableDefinitionImpl.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -21,9 +21,9 @@
*/
package org.jbpm.pvm.internal.task;
-import org.jbpm.api.task.AssignmentHandler;
import org.jbpm.pvm.internal.model.ProcessElementImpl;
import org.jbpm.pvm.internal.util.EqualsUtil;
+import org.jbpm.pvm.internal.wire.usercode.UserCodeReference;
/**
* @author Tom Baeyens
@@ -41,7 +41,7 @@
protected String candidateUsersExpressionLanguage;
protected String candidateGroupsExpression;
protected String candidateGroupsExpressionLanguage;
- protected AssignmentHandler assignmentHandler;
+ protected UserCodeReference assignmentHandlerReference;
// equals ///////////////////////////////////////////////////////////////////
// hack to support comparing hibernate proxies against the real objects
@@ -70,11 +70,11 @@
public void setAssigneeExpression(String assigneeExpression) {
this.assigneeExpression = assigneeExpression;
}
- public AssignmentHandler getAssignmentHandler() {
- return assignmentHandler;
+ public UserCodeReference getAssignmentHandlerReference() {
+ return assignmentHandlerReference;
}
- public void setAssignmentHandler(AssignmentHandler assignmentHandler) {
- this.assignmentHandler = assignmentHandler;
+ public void setAssignmentHandlerReference(UserCodeReference assignmentHandlerReference) {
+ this.assignmentHandlerReference = assignmentHandlerReference;
}
public String getAssigneeExpressionLanguage() {
return assigneeExpressionLanguage;
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/UserCodeReference.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/UserCodeReference.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/UserCodeReference.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -1,93 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.wire;
-
-import java.io.Serializable;
-
-import org.jbpm.api.Execution;
-import org.jbpm.pvm.internal.model.ActivityImpl;
-import org.jbpm.pvm.internal.model.ExecutionImpl;
-import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
-import org.jbpm.pvm.internal.model.TransitionImpl;
-import org.jbpm.pvm.internal.util.ReflectUtil;
-
-
-/**
- * @author Tom Baeyens
- */
-public class UserCodeReference implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- protected boolean isCached = true;
- protected Object cachedObject;
- protected Descriptor descriptor;
-
- public Object getObject(Execution execution) {
- return getObject(null, execution);
- }
-
- public Object getObject(ProcessDefinitionImpl processDefinition) {
- return getObject(processDefinition, null);
- }
-
- protected Object getObject(ProcessDefinitionImpl processDefinition, Execution execution) {
- if (cachedObject!=null) {
- return cachedObject;
- }
- if (descriptor!=null) {
- if (processDefinition==null) {
- processDefinition = getProcessDefinition(execution);
- }
-
- Object usedObject = ReflectUtil.instantiateUserCode(descriptor, processDefinition);
- if (isCached) {
- cachedObject = usedObject;
- }
- return usedObject;
- }
- return null;
- }
-
- protected ProcessDefinitionImpl getProcessDefinition(Execution execution) {
- ProcessDefinitionImpl processDefinition = null;
- ExecutionImpl executionImpl = (ExecutionImpl) execution;
- ActivityImpl activity = executionImpl.getActivity();
- TransitionImpl transition = executionImpl.getTransition();
- if (activity!=null) {
- processDefinition = activity.getProcessDefinition();
- }
- if ( (processDefinition==null)
- && (transition!=null)
- ) {
- processDefinition = transition.getProcessDefinition();
- }
- return processDefinition;
- }
-
- public void setCached(boolean isCached) {
- this.isCached = isCached;
- }
- public void setDescriptor(Descriptor descriptor) {
- this.descriptor = descriptor;
- }
-}
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ExpressionDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ExpressionDescriptor.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ExpressionDescriptor.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.descriptor;
+
+import org.jbpm.pvm.internal.script.ScriptManager;
+import org.jbpm.pvm.internal.wire.WireContext;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class ExpressionDescriptor extends AbstractDescriptor {
+
+ private static final long serialVersionUID = 1L;
+
+ protected String expression;
+ protected String language;
+
+ public Object construct(WireContext wireContext) {
+ ScriptManager scriptManager = ScriptManager.getScriptManager();
+ Object result = scriptManager.evaluateExpression(expression, language);
+ return result;
+ }
+
+ public void setExpression(String expression) {
+ this.expression = expression;
+ }
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ExpressionDescriptor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ExpressionEvaluatorDescriptor.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ExpressionEvaluatorDescriptor.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/descriptor/ExpressionEvaluatorDescriptor.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.pvm.internal.wire.descriptor;
-
-import org.jbpm.pvm.internal.model.ExpressionEvaluator;
-import org.jbpm.pvm.internal.wire.WireContext;
-
-
-/**
- * @author Tom Baeyens
- */
-public class ExpressionEvaluatorDescriptor extends AbstractDescriptor {
-
- private static final long serialVersionUID = 1L;
-
- protected String expr;
- protected String lang;
-
- public ExpressionEvaluatorDescriptor() {
- }
-
- public ExpressionEvaluatorDescriptor(String expr, String lang) {
- this.expr = expr;
- this.lang = lang;
- }
-
- public Object construct(WireContext wireContext) {
- return new ExpressionEvaluator(getName(), expr, lang);
- }
-
-}
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeActivityBehaviour.java (from rev 5706, jbpm4/trunk/modules/jpdl/src/main/java/org/jbpm/jpdl/internal/activity/CustomActivity.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeActivityBehaviour.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeActivityBehaviour.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.usercode;
+
+import java.util.Map;
+
+import org.jbpm.api.activity.ActivityBehaviour;
+import org.jbpm.api.activity.ActivityExecution;
+import org.jbpm.api.activity.ExternalActivityBehaviour;
+
+/**
+ * @author Tom Baeyens
+ */
+public class UserCodeActivityBehaviour implements ExternalActivityBehaviour {
+
+ private static final long serialVersionUID = 1L;
+
+ protected UserCodeReference customActivityReference;
+
+ public void execute(ActivityExecution execution) throws Exception {
+ ActivityBehaviour activityBehaviour = (ActivityBehaviour) customActivityReference.getObject(execution);
+ activityBehaviour.execute(execution);
+ }
+
+ public void signal(ActivityExecution execution, String signalName, Map<String, ? > parameters) throws Exception {
+ ExternalActivityBehaviour externalActivityBehaviour = (ExternalActivityBehaviour) customActivityReference.getObject(execution);
+ externalActivityBehaviour.signal(execution, signalName, parameters);
+ }
+
+ public void setCustomActivityReference(UserCodeReference customActivityReference) {
+ this.customActivityReference = customActivityReference;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeActivityBehaviour.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeCondition.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeCondition.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeCondition.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.usercode;
+
+import org.jbpm.api.model.OpenExecution;
+import org.jbpm.pvm.internal.model.Condition;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class UserCodeCondition implements Condition {
+
+ private static final long serialVersionUID = 1L;
+
+ protected UserCodeReference conditionReference;
+
+ public boolean evaluate(OpenExecution execution) {
+ Condition condition = (Condition) conditionReference.getObject(execution);
+ return condition.evaluate(execution);
+ }
+
+ public void setConditionReference(UserCodeReference conditionReference) {
+ this.conditionReference = conditionReference;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeCondition.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeEventListener.java
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeEventListener.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeEventListener.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.usercode;
+
+import org.jbpm.api.listener.EventListener;
+import org.jbpm.api.listener.EventListenerExecution;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class UserCodeEventListener implements EventListener {
+
+ private static final long serialVersionUID = 1L;
+
+ protected UserCodeReference eventListenerReference;
+
+ public void notify(EventListenerExecution execution) throws Exception {
+ EventListener eventListener = (EventListener) eventListenerReference.getObject(execution);
+ eventListener.notify(execution);
+ }
+
+ public void setEventListenerReference(UserCodeReference eventListenerReference) {
+ this.eventListenerReference = eventListenerReference;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeEventListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeReference.java (from rev 5706, jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/UserCodeReference.java)
===================================================================
--- jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeReference.java (rev 0)
+++ jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeReference.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.wire.usercode;
+
+import java.io.Serializable;
+
+import org.jbpm.api.Execution;
+import org.jbpm.pvm.internal.model.ActivityImpl;
+import org.jbpm.pvm.internal.model.ExecutionImpl;
+import org.jbpm.pvm.internal.model.ProcessDefinitionImpl;
+import org.jbpm.pvm.internal.model.TransitionImpl;
+import org.jbpm.pvm.internal.util.ReflectUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class UserCodeReference implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ protected boolean isCached = true;
+ protected Object cachedObject;
+ protected Descriptor descriptor;
+
+ public Object getObject(Execution execution) {
+ return getObject(null, execution);
+ }
+
+ public Object getObject(ProcessDefinitionImpl processDefinition) {
+ return getObject(processDefinition, null);
+ }
+
+ protected Object getObject(ProcessDefinitionImpl processDefinition, Execution execution) {
+ if (cachedObject!=null) {
+ return cachedObject;
+ }
+ if (descriptor!=null) {
+ if (processDefinition==null) {
+ processDefinition = getProcessDefinition(execution);
+ }
+
+ Object usedObject = ReflectUtil.instantiateUserCode(descriptor, processDefinition);
+ if (isCached) {
+ cachedObject = usedObject;
+ }
+ return usedObject;
+ }
+ return null;
+ }
+
+ protected ProcessDefinitionImpl getProcessDefinition(Execution execution) {
+ ProcessDefinitionImpl processDefinition = null;
+ ExecutionImpl executionImpl = (ExecutionImpl) execution;
+ ActivityImpl activity = executionImpl.getActivity();
+ TransitionImpl transition = executionImpl.getTransition();
+ if (activity!=null) {
+ processDefinition = activity.getProcessDefinition();
+ }
+ if ( (processDefinition==null)
+ && (transition!=null)
+ ) {
+ processDefinition = transition.getProcessDefinition();
+ }
+ return processDefinition;
+ }
+
+ public void setCached(boolean isCached) {
+ this.isCached = isCached;
+ }
+ public void setDescriptor(Descriptor descriptor) {
+ this.descriptor = descriptor;
+ }
+}
Property changes on: jbpm4/trunk/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/usercode/UserCodeReference.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/test-cactus/src/test/java/org/jbpm/test/AllIntegrationTests.java
===================================================================
--- jbpm4/trunk/modules/test-cactus/src/test/java/org/jbpm/test/AllIntegrationTests.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/test-cactus/src/test/java/org/jbpm/test/AllIntegrationTests.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -49,7 +49,7 @@
suite.addTestSuite(org.jbpm.examples.goup.multipleentries.MultipleEntriesTest.class);
suite.addTestSuite(org.jbpm.examples.goup.simple.GroupSimpleTest.class);
suite.addTestSuite(org.jbpm.examples.goup.timer.GroupTimerTest.class);
- suite.addTestSuite(org.jbpm.test.activities.DecisionTest.class);
+ suite.addTestSuite(org.jbpm.test.activity.decision.DecisionTest.class);
suite.addTestSuite(org.jbpm.test.activities.ForkJoinInSameTransactionTest.class);
suite.addTestSuite(org.jbpm.test.activities.ForkTest.class);
suite.addTestSuite(org.jbpm.test.activities.ForkToTaskTest.class);
@@ -107,10 +107,10 @@
suite.addTestSuite(org.jbpm.test.task.TaskQueryCandidatesTest.class);
suite.addTestSuite(org.jbpm.test.task.TaskQueryProcessTest.class);
suite.addTestSuite(org.jbpm.test.task.TaskVariablesTest.class);
- suite.addTestSuite(org.jbpm.test.taskactivity.TaskCandidatesTest.class);
- suite.addTestSuite(org.jbpm.test.taskactivity.TaskCompletionTest.class);
- suite.addTestSuite(org.jbpm.test.taskactivity.TaskOutcomesTest.class);
- suite.addTestSuite(org.jbpm.test.taskactivity.TaskReassignTest.class);
+ suite.addTestSuite(org.jbpm.test.activity.task.TaskCandidatesTest.class);
+ suite.addTestSuite(org.jbpm.test.activity.task.TaskCompletionTest.class);
+ suite.addTestSuite(org.jbpm.test.activity.task.TaskOutcomesTest.class);
+ suite.addTestSuite(org.jbpm.test.activity.task.TaskReassignTest.class);
suite.addTestSuite(org.jbpm.test.timer.TaskTimerTaskTest.class);
suite.addTestSuite(org.jbpm.test.timer.TimerTest.class);
suite.addTestSuite(org.jbpm.test.variables.BasicVariablesTest.class);
Deleted: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/DecisionTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/DecisionTest.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/DecisionTest.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -1,96 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.test.activities;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jbpm.api.Execution;
-import org.jbpm.api.ProcessInstance;
-import org.jbpm.test.JbpmTestCase;
-
-
-/**
- * @author Tom Baeyens
- */
-public class DecisionTest extends JbpmTestCase {
-
- public void testDecisionExpression() {
- deployJpdlXmlString(
- "<process name='Poolcar'>" +
- " <start>" +
- " <transition to='How far?' />" +
- " </start>" +
- " <decision name='How far?' expr='#{distance}'>" +
- " <transition name='far' to='Big car' />" +
- " <transition name='nearby' to='Small car' />" +
- " </decision>" +
- " <state name='Big car' />" +
- " <state name='Small car' />" +
- "</process>"
- );
-
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("distance", "far");
- ProcessInstance processInstance = executionService.startProcessInstanceByKey("Poolcar", variables);
- assertTrue(processInstance.isActive("Big car"));
-
- variables.put("distance", "nearby");
- processInstance = executionService.startProcessInstanceByKey("Poolcar", variables);
- assertTrue(processInstance.isActive("Small car"));
- }
-
- public void testDecisionWithConditions() {
- deployJpdlXmlString(
- "<process name='Poolcar'>" +
- " <start>" +
- " <transition to='How far?' />" +
- " </start>" +
- " <decision name='How far?'>" +
- " <transition to='Big car'>" +
- " <condition expr='#{distance > 10}' />" +
- " </transition>" +
- " <transition to='Small car'>" +
- " <condition expr='#{distance >= 3}' />" +
- " </transition>" +
- " <transition to='No car' />" +
- " </decision>" +
- " <state name='Big car' />" +
- " <state name='Small car' />" +
- " <state name='No car' />" +
- "</process>"
- );
-
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("distance", new Integer(69));
- ProcessInstance processInstance = executionService.startProcessInstanceByKey("Poolcar", variables);
- assertTrue(processInstance.isActive("Big car"));
-
- variables.put("distance", new Integer(6));
- processInstance = executionService.startProcessInstanceByKey("Poolcar", variables);
- assertTrue(processInstance.isActive("Small car"));
-
- variables.put("distance", new Integer(2));
- processInstance = executionService.startProcessInstanceByKey("Poolcar", variables);
- assertTrue(processInstance.isActive("No car"));
- }
-}
Copied: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/decision/DecisionTest.java (from rev 5705, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activities/DecisionTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/decision/DecisionTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/decision/DecisionTest.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activity.decision;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class DecisionTest extends JbpmTestCase {
+
+ public void testDecisionExpression() {
+ deployJpdlXmlString(
+ "<process name='Poolcar'>" +
+ " <start>" +
+ " <transition to='How far?' />" +
+ " </start>" +
+ " <decision name='How far?' expr='#{distance}'>" +
+ " <transition name='far' to='Big car' />" +
+ " <transition name='nearby' to='Small car' />" +
+ " </decision>" +
+ " <state name='Big car' />" +
+ " <state name='Small car' />" +
+ "</process>"
+ );
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("distance", "far");
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("Poolcar", variables);
+ assertTrue(processInstance.isActive("Big car"));
+
+ variables.put("distance", "nearby");
+ processInstance = executionService.startProcessInstanceByKey("Poolcar", variables);
+ assertTrue(processInstance.isActive("Small car"));
+ }
+
+ public void testDecisionWithConditions() {
+ deployJpdlXmlString(
+ "<process name='Poolcar'>" +
+ " <start>" +
+ " <transition to='How far?' />" +
+ " </start>" +
+ " <decision name='How far?'>" +
+ " <transition to='Big car'>" +
+ " <condition expr='#{distance > 10}' />" +
+ " </transition>" +
+ " <transition to='Small car'>" +
+ " <condition expr='#{distance >= 3}' />" +
+ " </transition>" +
+ " <transition to='No car' />" +
+ " </decision>" +
+ " <state name='Big car' />" +
+ " <state name='Small car' />" +
+ " <state name='No car' />" +
+ "</process>"
+ );
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("distance", new Integer(69));
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("Poolcar", variables);
+ assertTrue(processInstance.isActive("Big car"));
+
+ variables.put("distance", new Integer(6));
+ processInstance = executionService.startProcessInstanceByKey("Poolcar", variables);
+ assertTrue(processInstance.isActive("Small car"));
+
+ variables.put("distance", new Integer(2));
+ processInstance = executionService.startProcessInstanceByKey("Poolcar", variables);
+ assertTrue(processInstance.isActive("No car"));
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/decision/DecisionTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskAssignmentHandlerExprTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskAssignmentHandlerExprTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskAssignmentHandlerExprTest.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activity.task;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.model.OpenExecution;
+import org.jbpm.api.task.Assignable;
+import org.jbpm.api.task.AssignmentHandler;
+import org.jbpm.api.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskAssignmentHandlerExprTest extends JbpmTestCase {
+
+ public static class MyAssignmentHandler implements AssignmentHandler {
+ private static final long serialVersionUID = 1L;
+ public void assign(Assignable assignable, OpenExecution execution) throws Exception {
+ assignable.setAssignee("johndoe");
+ }
+ }
+
+ public void testTaskAssignmentHandlerExpr() {
+ deployJpdlXmlString(
+ "<process name='TaskAssignmentHandlerExpr'>" +
+ " <start>" +
+ " <transition to='review' />" +
+ " </start>" +
+ " <task name='review'>" +
+ " <assignment-handler expr='#{myassignmenthandler}' />" +
+ " <transition to='wait' />" +
+ " </task>" +
+ " <state name='wait'/>" +
+ "</process>"
+ );
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("myassignmenthandler", new MyAssignmentHandler());
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("TaskAssignmentHandlerExpr", variables);
+
+ // both johndoe and joesmoe will see the task in their *group* task list
+ List<Task> taskList = taskService.findPersonalTasks("johndoe");
+ assertEquals("Expected a single task being created", 1, taskList.size());
+ Task task = taskList.get(0);
+ assertEquals("review", task.getName());
+ }
+
+
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskAssignmentHandlerExprTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskCandidatesTest.java (from rev 5705, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/taskactivity/TaskCandidatesTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskCandidatesTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskCandidatesTest.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -0,0 +1,239 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activity.task;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskCandidatesTest extends JbpmTestCase {
+
+ public void testCommaSeparatedTaskCandidates() {
+ deployJpdlXmlString(
+ "<process name='TaskCandidates'>" +
+ " <start>" +
+ " <transition to='review' />" +
+ " </start>" +
+ " <task name='review' " +
+ " candidate-users='johndoe, joesmoe'>" +
+ " <transition to='wait' />" +
+ " </task>" +
+ " <state name='wait'/>" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("TaskCandidates");
+ String pid = processInstance.getId();
+
+ // both johndoe and joesmoe will see the task in their *group* task list
+ List<Task> taskList = taskService.findGroupTasks("johndoe");
+ assertEquals("Expected a single task being created", 1, taskList.size());
+ Task task = taskList.get(0);
+ assertEquals("review", task.getName());
+
+ taskList = taskService.findGroupTasks("joesmoe");
+ assertEquals("Expected a single task being created", 1, taskList.size());
+ task = taskList.get(0);
+ assertEquals("review", task.getName());
+
+ // johndoe and joesmoe will NOT see the task in their *assigned* task list
+
+ taskList = taskService.findPersonalTasks("johndoe");
+ assertEquals(0, taskList.size());
+
+ taskList = taskService.findPersonalTasks("joesmoe");
+ assertEquals(0, taskList.size());
+
+ // lets assume that johndoe takes the task
+ taskService.takeTask(task.getId(), "johndoe");
+
+ // johndoe's and joesmoe's group task list is now empty
+ taskList = taskService.findGroupTasks("johndoe");
+ assertEquals(0, taskList.size());
+
+ taskList = taskService.findGroupTasks("joesmoe");
+ assertEquals(0, taskList.size());
+
+ // johndoe's assigned task list has the task in it
+ taskList = taskService.findPersonalTasks("johndoe");
+ assertEquals("Expected a single task being created", 1, taskList.size());
+ task = taskList.get(0);
+ assertEquals("review", task.getName());
+ assertEquals("johndoe", task.getAssignee());
+
+ // joesmoe will not see the task in the assigned task list
+ taskList = taskService.findPersonalTasks("joesmoe");
+ assertEquals(0, taskList.size());
+
+ // now johndoe completes the task
+ taskService.completeTask(task.getId());
+
+ // verify that the task list is now empty
+ taskList = taskService.findPersonalTasks("johndoe");
+ assertEquals(0, taskList.size());
+
+ // verify that process moved to the next state
+ processInstance = executionService.findProcessInstanceById(pid);
+ assertTrue(processInstance.isActive("wait"));
+ }
+
+ public void testTaskCandidatesExpression() {
+ deployJpdlXmlString(
+ "<process name='TaskCandidates'>" +
+ " <start>" +
+ " <transition to='review' />" +
+ " </start>" +
+ " <task name='review' " +
+ " candidate-users='#{userone}, #{usertwo}'>" +
+ " <transition to='wait' />" +
+ " </task>" +
+ " <state name='wait'/>" +
+ "</process>"
+ );
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("userone", "johndoe");
+ variables.put("usertwo", "joesmoe");
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("TaskCandidates", variables);
+ String executionId = processInstance.getId();
+
+ // both johndoe and joesmoe will see the task in their *group* task list
+ List<Task> taskList = taskService.findGroupTasks("johndoe");
+ assertEquals("Expected a single task being created", 1, taskList.size());
+ Task task = taskList.get(0);
+ assertEquals("review", task.getName());
+
+ taskList = taskService.findGroupTasks("joesmoe");
+ assertEquals("Expected a single task being created", 1, taskList.size());
+ task = taskList.get(0);
+ assertEquals("review", task.getName());
+
+ // johndoe and joesmoe will NOT see the task in their *assigned* task list
+
+ taskList = taskService.findPersonalTasks("johndoe");
+ assertEquals(0, taskList.size());
+
+ taskList = taskService.findPersonalTasks("joesmoe");
+ assertEquals(0, taskList.size());
+
+ // lets assume that johndoe takes the task
+ taskService.takeTask(task.getId(), "johndoe");
+
+ // johndoe's and joesmoe's group task list is now empty
+ taskList = taskService.findGroupTasks("johndoe");
+ assertEquals(0, taskList.size());
+
+ taskList = taskService.findGroupTasks("joesmoe");
+ assertEquals(0, taskList.size());
+
+ // johndoe's assigned task list has the task in it
+ taskList = taskService.findPersonalTasks("johndoe");
+ assertEquals("Expected a single task being created", 1, taskList.size());
+ task = taskList.get(0);
+ assertEquals("review", task.getName());
+ assertEquals("johndoe", task.getAssignee());
+
+ // joesmoe will not see the task in the assigned task list
+ taskList = taskService.findPersonalTasks("joesmoe");
+ assertEquals(0, taskList.size());
+
+ // now johndoe completes the task
+ taskService.completeTask(task.getId());
+
+ // verify that the task list is now empty
+ taskList = taskService.findPersonalTasks("johndoe");
+ assertEquals(0, taskList.size());
+
+ // verify that process moved to the next state
+ processInstance = executionService.findProcessInstanceById(executionId);
+ assertTrue(processInstance.isActive("wait"));
+ }
+
+ public void testCandidatePutsTaskBackInGroup() {
+ deployJpdlXmlString(
+ "<process name='CandidatePutsTaskBackInGroup'>" +
+ " <start>" +
+ " <transition to='review' />" +
+ " </start>" +
+ " <task name='review' " +
+ " candidate-groups='sales-dept'>" +
+ " <transition to='wait' />" +
+ " </task>" +
+ " <state name='wait'/>" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("CandidatePutsTaskBackInGroup");
+ String pid = processInstance.getId();
+
+ Task task = taskService.createTaskQuery().processInstanceId(pid).uniqueResult();
+ assertNull(task.getAssignee());
+
+ taskService.takeTask(task.getId(), "johndoe");
+
+ task = taskService.createTaskQuery().processInstanceId(pid).uniqueResult();
+ assertEquals("johndoe", task.getAssignee());
+
+ taskService.assignTask(task.getId(), null);
+
+ task = taskService.getTask(task.getId());
+ assertNull(task.getAssignee());
+ }
+
+ public void testDoubleTake() {
+ deployJpdlXmlString(
+ "<process name='DoubleTake'>" +
+ " <start>" +
+ " <transition to='review' />" +
+ " </start>" +
+ " <task name='review' " +
+ " candidate-users='johndoe, joesmoe'>" +
+ " <transition to='wait' />" +
+ " </task>" +
+ " <state name='wait'/>" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("DoubleTake");
+ String pid = processInstance.getId();
+
+ // both johndoe and joesmoe will see the task in their *group* task list
+ String taskId = taskService.findGroupTasks("johndoe").get(0).getId();
+
+ taskService.takeTask(taskId, "johndoe");
+
+ try {
+ taskService.takeTask(taskId, "joesmoe");
+ } catch (JbpmException e) {
+ assertTextPresent("task already taken by johndoe", e.getMessage());
+ }
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskCandidatesTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskCompletionTest.java (from rev 5705, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/taskactivity/TaskCompletionTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskCompletionTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskCompletionTest.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -0,0 +1,169 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activity.task;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.history.HistoryTask;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * Testcase for the several ways of completing a task.
+ *
+ * @author jbarrez
+ */
+public class TaskCompletionTest extends JbpmTestCase {
+
+ private static final String PROCESS =
+ "<process name='taskCompletion'>" +
+ " <start>" +
+ " <transition to='theTask' />" +
+ " </start>" +
+ " <task name='theTask' assignee='johndoe'>" +
+ " <transition name='one' to='stateOne' />" +
+ " <transition name='two' to='stateTwo' />" +
+ " </task>" +
+ " <state name='stateOne'>" +
+ " <transition to='theEnd' />" +
+ " </state>" +
+ " <state name='stateTwo'>" +
+ " <transition to='theEnd' />" +
+ " </state>" +
+ " <end name='theEnd' />" +
+ "</process>";
+
+ public void testCompletionWithNoOutcome() {
+ Ids ids = deployAndStartProcessInstance();
+ taskService.completeTask(ids.taskId);
+ assertExecutionInOneOrMoreActivitiesActive(ids.processInstanceId, "stateOne", "stateTwo");
+ assertNoOpenTasks(ids.processInstanceId);
+ assertHistoryTaskCreated(ids.processInstanceId, null);
+ }
+
+ public void testCompletionWithNullOrEmptyId() {
+ try {
+ taskService.completeTask(null);
+ fail();
+ } catch (JbpmException e) {
+ // exception should be thrown
+ }
+ try {
+ taskService.completeTask("");
+ fail();
+ } catch (JbpmException e) {
+ // exception should be thrown
+ }
+ }
+
+ public void testCompletionWithInvalidTaskId() {
+ try {
+ taskService.completeTask(Long.toString(-123456789L));
+ fail();
+ } catch (JbpmException e) {
+ // exception should be thrown
+ }
+ }
+
+ public void testCompletionWithOutcome() {
+ Ids ids = deployAndStartProcessInstance();
+ taskService.completeTask(ids.taskId, "one");
+
+ assertActivityActive(ids.processInstanceId, "stateOne");
+ assertNotActivityActive(ids.processInstanceId, "stateTwo");
+
+ assertNoOpenTasks(ids.processInstanceId);
+ assertHistoryTaskCreated(ids.processInstanceId, "one");
+ }
+
+ // Test for JBPM-2425
+ public void testCompletionWithInvalidOutcome() {
+ Ids ids = deployAndStartProcessInstance();
+
+ try {
+ taskService.completeTask(ids.taskId, "doesn't exist");
+ fail();
+ } catch (JbpmException e) {
+ // exception should be thrown
+ }
+
+ // Task should still be open now (rollback in db)
+ assertNotNull("After completion with an invalid outcome, the task should remain unchanged",
+ taskService.createTaskQuery().processInstanceId(ids.processInstanceId).uniqueResult());
+ }
+
+ public void testCompletionWithVariables() {
+ Ids ids = deployAndStartProcessInstance();
+ Map<String, Object> vars = new HashMap<String, Object>();
+ vars.put("testVar", "testValue");
+ taskService.completeTask(ids.taskId, vars);
+
+ assertEquals("testValue", executionService.getVariable(ids.processInstanceId, "testVar"));
+ assertNoOpenTasks(ids.processInstanceId);
+ assertHistoryTaskCreated(ids.processInstanceId, null);
+ }
+
+ public void testCompletionWithOutcomeAndVariables() {
+ Ids ids = deployAndStartProcessInstance();
+ Map<String, Object> vars = new HashMap<String, Object>();
+ vars.put("testVar", "testValue");
+ taskService.completeTask(ids.taskId, "two",vars);
+
+ assertEquals("testValue", executionService.getVariable(ids.processInstanceId, "testVar"));
+ assertActivityActive(ids.processInstanceId, "stateTwo");
+
+ assertNoOpenTasks(ids.processInstanceId);
+ assertHistoryTaskCreated(ids.processInstanceId, "two");
+ }
+
+ /**
+ * Returns the process instance id and the taskId of the single task
+ * that is open after process start
+ */
+ private Ids deployAndStartProcessInstance() {
+ deployJpdlXmlString(PROCESS);
+ Ids result = new Ids();
+ result.processInstanceId = executionService.startProcessInstanceByKey("taskCompletion").getId();
+ result.taskId = taskService.createTaskQuery().processInstanceId(result.processInstanceId).uniqueResult().getId();
+ return result;
+ }
+
+ private void assertHistoryTaskCreated(String executionId, String historicalOutcome) {
+ HistoryTask historyTask = historyService.createHistoryTaskQuery()
+ .executionId(executionId)
+ .uniqueResult();
+ assertNotNull(historyTask);
+ if (historicalOutcome != null) {
+ assertEquals(historicalOutcome, historyTask.getOutcome());
+ }
+ }
+
+ /* Just a wrapper for two ids, since Java doesnt allow to return multiple values */
+ private class Ids {
+
+ private String processInstanceId;
+ private String taskId;
+
+ }
+
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskCompletionTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskOutcomesTest.java (from rev 5705, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/taskactivity/TaskOutcomesTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskOutcomesTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskOutcomesTest.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -0,0 +1,273 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activity.task;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jbpm.api.JbpmException;
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskOutcomesTest extends JbpmTestCase {
+
+ public void testTaskSingleUnnamedTransition() {
+ deployJpdlXmlString(
+ "<process name='UnnamedTransition'>" +
+ " <start>" +
+ " <transition to='review' />" +
+ " </start>" +
+ " <task name='review' " +
+ " assignee='johndoe'>" +
+ " <transition to='wait' />" +
+ " </task>" +
+ " <state name='wait'/>" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("UnnamedTransition");
+
+ Task task = taskService
+ .createTaskQuery()
+ .assignee("johndoe")
+ .uniqueResult();
+
+ taskService.completeTask(task.getId());
+
+ processInstance = executionService.findProcessInstanceById(processInstance.getId());
+
+ assertNotNull(processInstance.findActiveExecutionIn("wait"));
+ }
+
+ public void testTaskTakeSingleNamedTransition() {
+ deployJpdlXmlString(
+ "<process name='NamedTransition'>" +
+ " <start>" +
+ " <transition to='review' />" +
+ " </start>" +
+ " <task name='review' " +
+ " assignee='johndoe'>" +
+ " <transition name='theOneAndOnly' to='wait' />" +
+ " </task>" +
+ " <state name='wait'/>" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("NamedTransition");
+
+ Task task = taskService
+ .createTaskQuery()
+ .assignee("johndoe")
+ .uniqueResult();
+
+ taskService.completeTask(task.getId());
+
+ processInstance = executionService.findProcessInstanceById(processInstance.getId());
+
+ assertNotNull(processInstance.findActiveExecutionIn("wait"));
+ }
+
+ public void testTaskTakeSingleNamedTransitionWithMatchingOutcome() {
+ deployJpdlXmlString(
+ "<process name='MatchingOutdome'>" +
+ " <start>" +
+ " <transition to='review' />" +
+ " </start>" +
+ " <task name='review' " +
+ " assignee='johndoe'>" +
+ " <transition name='theOneAndOnly' to='wait' />" +
+ " </task>" +
+ " <state name='wait'/>" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("MatchingOutdome");
+
+ Task task = taskService
+ .createTaskQuery()
+ .assignee("johndoe")
+ .uniqueResult();
+
+ taskService.completeTask(task.getId(), "theOneAndOnly");
+
+ processInstance = executionService.findProcessInstanceById(processInstance.getId());
+
+ assertNotNull(processInstance.findActiveExecutionIn("wait"));
+ }
+
+ public void testTaskTakeSingleNamedTransitionWithUnmatchingOutcome() {
+ deployJpdlXmlString(
+ "<process name='UnmatchingOutcome'>" +
+ " <start>" +
+ " <transition to='review' />" +
+ " </start>" +
+ " <task name='review' " +
+ " assignee='johndoe'>" +
+ " <transition to='wait' />" +
+ " </task>" +
+ " <state name='wait'/>" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("UnmatchingOutcome");
+
+ Task task = taskService
+ .createTaskQuery()
+ .assignee("johndoe")
+ .uniqueResult();
+
+ try {
+ taskService.completeTask(task.getId(), "Refused");
+ fail();
+ } catch (JbpmException e) {
+ // exception should be thrown
+ }
+
+ }
+
+ public void testGetOutcomesNoTransition() {
+ deployJpdlXmlString(
+ "<process name='UnmatchingOutcome'>" +
+ " <start>" +
+ " <transition to='review' />" +
+ " </start>" +
+ " <task name='review' " +
+ " assignee='johndoe'>" +
+ " </task>" +
+ " <state name='wait'/>" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("UnmatchingOutcome");
+
+ Task task = taskService
+ .createTaskQuery()
+ .assignee("johndoe")
+ .uniqueResult();
+
+ Set<String> outcomes = taskService.getOutcomes(task.getId());
+
+ Set<String> expectedOutcomes = new HashSet<String>();
+ expectedOutcomes.add(Task.STATE_COMPLETED);
+
+ assertEquals(expectedOutcomes, outcomes);
+ }
+
+ public void testGetOutcomesSingleUnnamedTransition() {
+ deployJpdlXmlString(
+ "<process name='UnmatchingOutcome'>" +
+ " <start>" +
+ " <transition to='review' />" +
+ " </start>" +
+ " <task name='review' " +
+ " assignee='johndoe'>" +
+ " <transition to='wait' />" +
+ " </task>" +
+ " <state name='wait'/>" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("UnmatchingOutcome");
+
+ Task task = taskService
+ .createTaskQuery()
+ .assignee("johndoe")
+ .uniqueResult();
+
+ Set<String> outcomes = taskService.getOutcomes(task.getId());
+
+ Set<String> expectedOutcomes = new HashSet<String>();
+ expectedOutcomes.add(Task.STATE_COMPLETED);
+ expectedOutcomes.add(null);
+
+ assertEquals(expectedOutcomes, outcomes);
+ }
+
+ public void testGetOutcomesSingleNamedTransition() {
+ deployJpdlXmlString(
+ "<process name='UnmatchingOutcome'>" +
+ " <start>" +
+ " <transition to='review' />" +
+ " </start>" +
+ " <task name='review' " +
+ " assignee='johndoe'>" +
+ " <transition name='toedeloe' to='wait' />" +
+ " </task>" +
+ " <state name='wait'/>" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("UnmatchingOutcome");
+
+ Task task = taskService
+ .createTaskQuery()
+ .assignee("johndoe")
+ .uniqueResult();
+
+ Set<String> outcomes = taskService.getOutcomes(task.getId());
+
+ Set<String> expectedOutcomes = new HashSet<String>();
+ expectedOutcomes.add(Task.STATE_COMPLETED);
+ expectedOutcomes.add("toedeloe");
+
+ assertEquals(expectedOutcomes, outcomes);
+ }
+
+ public void testGetOutcomesMultipleTransitions() {
+ deployJpdlXmlString(
+ "<process name='UnmatchingOutcome'>" +
+ " <start>" +
+ " <transition to='review' />" +
+ " </start>" +
+ " <task name='review' " +
+ " assignee='johndoe'>" +
+ " <transition name='left' to='wait' />" +
+ " <transition name='right' to='wait' />" +
+ " <transition name='middle' to='wait' />" +
+ " </task>" +
+ " <state name='wait'/>" +
+ "</process>"
+ );
+
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("UnmatchingOutcome");
+
+ Task task = taskService
+ .createTaskQuery()
+ .assignee("johndoe")
+ .uniqueResult();
+
+ Set<String> outcomes = taskService.getOutcomes(task.getId());
+
+ Set<String> expectedOutcomes = new HashSet<String>();
+ expectedOutcomes.add(Task.STATE_COMPLETED);
+ expectedOutcomes.add("left");
+ expectedOutcomes.add("right");
+ expectedOutcomes.add("middle");
+
+ assertEquals(expectedOutcomes, outcomes);
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskOutcomesTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskReassignTest.java (from rev 5705, jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/taskactivity/TaskReassignTest.java)
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskReassignTest.java (rev 0)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskReassignTest.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.test.activity.task;
+
+import java.util.List;
+
+import org.jbpm.api.ProcessInstance;
+import org.jbpm.api.history.HistoryTask;
+import org.jbpm.api.task.Task;
+import org.jbpm.test.JbpmTestCase;
+
+/**
+ * @author Tom Baeyens
+ */
+public class TaskReassignTest extends JbpmTestCase {
+
+ public void testReassignHistory() {
+ deployJpdlXmlString(
+ "<process name='ReassignTest'>" +
+ " <start>" +
+ " <transition to='write email'/>" +
+ " </start>" +
+ " <task name='write email' assignee='shekharv'>" +
+ " <transition to='end'/>" +
+ " </task>" +
+ " <end name='end'/>" +
+ "</process>"
+ );
+
+ ProcessInstance pi = executionService.startProcessInstanceByKey("ReassignTest");
+
+ List<Task> tasks = taskService.findPersonalTasks("shekharv");
+ assertTrue(tasks.size() == 1);
+
+ String taskId = tasks.get(0).getId();
+
+ taskService.assignTask(taskId, "johndoe");
+
+ List<Task> tasksAfterReassignment = taskService.findPersonalTasks("shekharv");
+ assertTrue("shekharv should not have any tasks.", tasksAfterReassignment.size() == 0);
+
+ List<Task> tasksForNewAssignee = taskService.findPersonalTasks("johndoe");
+ assertTrue("johndoe should have 1 task.", tasksForNewAssignee.size() == 1);
+
+ assertEquals("johndoe", taskService.getTask(taskId).getAssignee());
+
+ taskService.completeTask(taskId);
+
+ HistoryTask historyTask = historyService
+ .createHistoryTaskQuery()
+ .taskId(taskId)
+ .uniqueResult();
+
+ assertEquals("John Doe completed the Task, but someone else got the credit", "johndoe", historyTask.getAssignee());
+ }
+}
Property changes on: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/task/TaskReassignTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/eventlistener/EventListenerTest.java
===================================================================
--- jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/eventlistener/EventListenerTest.java 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/eventlistener/EventListenerTest.java 2009-10-07 12:24:14 UTC (rev 5708)
@@ -242,31 +242,82 @@
assertEquals(expectedOrder, executionService.getVariable(processInstanceId, "order"));
}
-//
-// public void testProcessStartListenerExpr() {
-// deployJpdlXmlString(
-// "<process name='Insurance claim' key='ICL'>" +
-// " <on event='start'>" +
-// " <event-listener expr='#{processstartlistener}' />" +
-// " </on>" +
-// " <start>" +
-// " <transition to='a' />" +
-// " </start>" +
-// " <state name='a' />" +
-// "</process>"
-// );
-//
-// Map<String, Object> variables = new HashMap<String, Object>();
-// variables.put("processstartlistener", new ProcessStartListener());
-// String processInstanceId = executionService.startProcessInstanceByKey("ICL", variables).getId();
-//
-// assertEquals("true", executionService.getVariable(processInstanceId, "isInvoked"));
-//
-// executionService.setVariable(processInstanceId, "isInvoked", "false");
-//
-// executionService.signalExecutionById(processInstanceId);
-//
-// assertEquals("false", executionService.getVariable(processInstanceId, "isInvoked"));
-// }
-//
+
+ public void testProcessStartListenerExpr() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <on event='start'>" +
+ " <event-listener expr='#{processstartlistener}' />" +
+ " </on>" +
+ " <start>" +
+ " <transition to='a' />" +
+ " </start>" +
+ " <state name='a' />" +
+ "</process>"
+ );
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("processstartlistener", new ProcessStartListener());
+ String processInstanceId = executionService.startProcessInstanceByKey("ICL", variables).getId();
+
+ assertEquals("true", executionService.getVariable(processInstanceId, "isInvoked"));
+
+ executionService.setVariable(processInstanceId, "isInvoked", "false");
+
+ executionService.signalExecutionById(processInstanceId);
+
+ assertEquals("false", executionService.getVariable(processInstanceId, "isInvoked"));
+ }
+
+ public void testActivityStartListenerExpr() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <transition to='s' />" +
+ " </start>" +
+ " <state name='s'>" +
+ " <on event='start'>" +
+ " <event-listener expr='#{activitystartlistener}' />" +
+ " </on>" +
+ " <transition to='end' />" +
+ " </state>" +
+ " <state name='end' />" +
+ "</process>"
+ );
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("activitystartlistener", new ActivityStartListener());
+ String processInstanceId = executionService.startProcessInstanceByKey("ICL", variables).getId();
+
+ assertEquals("true", executionService.getVariable(processInstanceId, "isInvoked"));
+ }
+
+ public void testActivityEndListenerExpr() {
+ deployJpdlXmlString(
+ "<process name='Insurance claim' key='ICL'>" +
+ " <start>" +
+ " <transition to='s' />" +
+ " </start>" +
+ " <state name='s'>" +
+ " <on event='end'>" +
+ " <event-listener expr='#{activityendlistener}' />" +
+ " </on>" +
+ " <transition to='end' />" +
+ " </state>" +
+ " <state name='end' />" +
+ "</process>"
+ );
+
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.put("activityendlistener", new ActivityEndListener());
+ ProcessInstance processInstance = executionService.startProcessInstanceByKey("ICL", variables);
+ String processInstanceId = processInstance.getId();
+
+ assertNull(executionService.getVariable(processInstanceId, "isInvoked"));
+
+ executionService.signalExecutionById(processInstance.getId());
+
+ assertEquals("true", executionService.getVariable(processInstanceId, "isInvoked"));
+ }
+
}
Modified: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml 2009-10-07 00:32:13 UTC (rev 5707)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch06-Jpdl.xml 2009-10-07 12:24:14 UTC (rev 5708)
@@ -2,9 +2,13 @@
<title>jPDL</title>
<para>This chapter will explain the jPDL file format for describing
- process definitions. The schemadocs can also serve as a quick reference for this
- information.
+ process definitions.
</para>
+ <para>The jPDL schema file contains more attributes and elements then this
+ documentation. This documentation explains the stable and supported part of jPDL.
+ So use this documentation as a reference to know what attributes and elements
+ are stable and supported.
+ </para>
<para>An example jPDL process file looks like this:
</para>
<programlisting><?xml version="1.0" encoding="UTF-8"?>
@@ -436,30 +440,10 @@
<programlisting>public interface DecisionHandler {
String decide(OpenExecution execution);
}</programlisting>
- <para>The handler is specified as a sub element of the decision</para>
- <table><title><literal>decision.handler</literal> attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>class</literal></entry>
- <entry>classname</entry>
- <entry></entry>
- <entry><emphasis role="bold">required</emphasis></entry>
- <entry>fully qualified classname of the handler implementation class.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
+ <para>The handler is specified as a sub element of the decision.
+ The configuration attributes and content of a decision <literal>handler</literal>
+ element can be found in <xref linkend="usercode" />.
+ </para>
<para>Here's an example process of a decision using a DecisionHandler:</para>
<figure id="process.decision.handler">
<title>The decision handler example process</title>
@@ -2536,6 +2520,12 @@
</tgroup>
</table>
<table><title>event listener attributes:</title>
+ <para><literal>event-listener</literal> is user code so it can be configured
+ like described in <xref linkend="usercode" />.
+ </para>
+ <para>Any automatic activities (including event-listener) that are placed on
+ events can specify following additional attributes:
+ </para>
<tgroup cols="5" rowsep="1" colsep="1">
<thead>
<row>
More information about the jbpm-commits
mailing list