This is an automated email from the ASF dual-hosted git repository.

egonzalez pushed a commit to branch main
in repository 
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-runtimes.git


The following commit(s) were added to refs/heads/main by this push:
     new cc84426b6d [incubator-kie-issues-1152] Add support for collaborations 
(#3523)
cc84426b6d is described below

commit cc84426b6d1e3ab931041c087466fafe2ba0b464
Author: Enrique <[email protected]>
AuthorDate: Tue May 28 10:41:26 2024 +0200

    [incubator-kie-issues-1152] Add support for collaborations (#3523)
---
 .../org/jbpm/bpmn2/xml/BoundaryEventHandler.java   |   2 +
 .../bpmn2/xml/IntermediateCatchEventHandler.java   |   2 +
 .../java/org/jbpm/bpmn2/xml/ProcessHandler.java    |   8 +-
 .../java/org/jbpm/bpmn2/xml/StartEventHandler.java |   2 +
 .../xpath/XPATHReturnValueEvaluatorBuilder.java    |   3 +-
 .../jbpm/compiler/canonical/ActionNodeVisitor.java |   2 +-
 .../canonical/BoundaryEventNodeVisitor.java        |   6 +-
 .../jbpm/compiler/canonical/EventNodeVisitor.java  |   7 +-
 .../jbpm/compiler/canonical/ProcessVisitor.java    |  46 +++++++-
 .../jbpm/compiler/canonical/SplitNodeVisitor.java  |  52 +++++---
 .../ExpressionConstraintEvaluatorBuilder.java      |  41 -------
 .../builtin/FEELConstraintEvaluatorBuilder.java    |  11 +-
 .../builtin/JavaConstraintEvaluatorBuilder.java    |  11 +-
 ...der.java => JqReturnValueEvaluatorBuilder.java} |  22 ++--
 ...va => JsonpathReturnValueEvaluatorBuilder.java} |  22 ++--
 .../builtin/MVELConstraintEvaluatorBuilder.java    |  11 +-
 ...ilder.java => ReturnValueEvaluatorBuilder.java} |  12 +-
 ...ava => ReturnValueEvaluatorBuilderService.java} |  43 ++++---
 .../builtin/XPATHConstraintEvaluatorBuilder.java   |  12 +-
 .../canonical/node/SplitNodeVisitorBuilder.java    |   3 +-
 .../mvel/MVELReturnValueEvaluatorBuilder.java      |   3 +-
 ....canonical.builtin.ReturnValueEvaluatorBuilder} |   5 +-
 .../process/builder/dialect/java/javaInvokers.mvel |   8 +-
 .../CorrelationExpressionEvaluator.java            |  29 -----
 .../core/correlation/CorrelationManager.java       |  30 ++++-
 .../core/correlation/CorrelationProperties.java    |   8 +-
 .../jbpm/process/core/event/EventTypeFilter.java   |   2 +-
 .../core/event/MVELMessageExpressionEvaluator.java |  62 ----------
 .../process/instance/KogitoProcessContextImpl.java |  16 +++
 .../instance/LightProcessRuntimeContext.java       |   2 +-
 .../impl/AbstractReturnValueEvaluator.java         |  76 ++++++++++++
 .../EmtpyKogitoProcessContext.java}                |  43 ++++---
 .../impl/ExpressionReturnValueEvaluator.java       |  11 +-
 .../instance/impl/FeelReturnValueEvaluator.java    |  30 +----
 .../impl/MVELInterpretedReturnValueEvaluator.java  |  39 +++++-
 .../instance/impl/MVELReturnValueEvaluator.java    |  45 ++-----
 .../instance/impl/ReturnValueEvaluator.java        |  29 ++++-
 .../instance/impl/XPATHReturnValueEvaluator.java   | 131 +++++++++------------
 .../main/java/org/jbpm/ruleflow/core/Metadata.java |   1 +
 .../jbpm/ruleflow/core/RuleFlowProcessFactory.java |  28 +++++
 .../core/factory/AbstractEventNodeFactory.java     |   5 +
 .../core/factory/EventSubProcessNodeFactory.java   |   5 +
 .../ruleflow/core/factory/StartNodeFactory.java    |   7 ++
 .../kie/kogito/process/impl/AbstractProcess.java   |   1 +
 .../java/org/jbpm/bpmn2/CollaborationTest.java     | 106 +++++++++++++----
 .../src/main/bpmn/BPMN2-XpathExpression.bpmn2      | 114 ++++++++++++++++++
 46 files changed, 722 insertions(+), 432 deletions(-)

diff --git 
a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/BoundaryEventHandler.java 
b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/BoundaryEventHandler.java
index dbd45edfa2..d3ef36e0de 100755
--- a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/BoundaryEventHandler.java
+++ b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/BoundaryEventHandler.java
@@ -45,6 +45,7 @@ import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 
 import static org.jbpm.ruleflow.core.Metadata.EVENT_TYPE;
+import static org.jbpm.ruleflow.core.Metadata.MESSAGE_REF;
 
 public class BoundaryEventHandler extends AbstractNodeHandler {
 
@@ -408,6 +409,7 @@ public class BoundaryEventHandler extends 
AbstractNodeHandler {
                 eventNode.setMetaData("MessageType", message.getType());
                 eventNode.setMetaData("TriggerType", "ConsumeMessage");
                 eventNode.setMetaData("TriggerRef", message.getName());
+                eventNode.setMetaData(MESSAGE_REF, message.getId());
                 List<EventFilter> eventFilters = new ArrayList<>();
                 EventTypeFilter eventFilter = new EventTypeFilter();
                 eventFilter.setCorrelationManager(((RuleFlowProcess) 
parser.getMetaData().get("CurrentProcessDefinition")).getCorrelationManager());
diff --git 
a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/IntermediateCatchEventHandler.java
 
b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/IntermediateCatchEventHandler.java
index 267a7fa462..c8329b5b0f 100755
--- 
a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/IntermediateCatchEventHandler.java
+++ 
b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/IntermediateCatchEventHandler.java
@@ -55,6 +55,7 @@ import static 
org.jbpm.ruleflow.core.Metadata.EVENT_TYPE_MESSAGE;
 import static org.jbpm.ruleflow.core.Metadata.EVENT_TYPE_SIGNAL;
 import static org.jbpm.ruleflow.core.Metadata.EVENT_TYPE_TIMER;
 import static org.jbpm.ruleflow.core.Metadata.LINK_NAME;
+import static org.jbpm.ruleflow.core.Metadata.MESSAGE_REF;
 import static org.jbpm.ruleflow.core.Metadata.MESSAGE_TYPE;
 import static org.jbpm.ruleflow.core.Metadata.SIGNAL_TYPE;
 import static org.jbpm.ruleflow.core.Metadata.TRIGGER_REF;
@@ -240,6 +241,7 @@ public class IntermediateCatchEventHandler extends 
AbstractNodeHandler {
                 eventNode.setMetaData(MESSAGE_TYPE, message.getType());
                 eventNode.setMetaData(TRIGGER_TYPE, CONSUME_MESSAGE);
                 eventNode.setMetaData(TRIGGER_REF, message.getName());
+                eventNode.setMetaData(MESSAGE_REF, message.getId());
                 List<EventFilter> eventFilters = new ArrayList<>();
                 EventTypeFilter eventFilter = new EventTypeFilter();
                 eventFilter.setCorrelationManager(((RuleFlowProcess) 
parser.getMetaData().get("CurrentProcessDefinition")).getCorrelationManager());
diff --git 
a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/ProcessHandler.java 
b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/ProcessHandler.java
index 836248b6df..e9c8b060e5 100755
--- a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/ProcessHandler.java
+++ b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/ProcessHandler.java
@@ -59,9 +59,10 @@ import org.jbpm.process.core.context.variable.VariableScope;
 import org.jbpm.process.core.correlation.CorrelationManager;
 import org.jbpm.process.core.event.EventFilter;
 import org.jbpm.process.core.event.EventTypeFilter;
-import org.jbpm.process.core.event.MVELMessageExpressionEvaluator;
 import org.jbpm.process.core.timer.Timer;
 import org.jbpm.process.instance.impl.Action;
+import org.jbpm.process.instance.impl.MVELInterpretedReturnValueEvaluator;
+import org.jbpm.process.instance.impl.ReturnValueEvaluator;
 import org.jbpm.process.instance.impl.actions.CancelNodeInstanceAction;
 import 
org.jbpm.process.instance.impl.actions.ProcessInstanceCompensationAction;
 import org.jbpm.process.instance.impl.actions.SignalProcessInstanceAction;
@@ -240,7 +241,7 @@ public class ProcessHandler extends BaseAbstractHandler 
implements Handler {
                     correlationProperty.getMessageRefs().forEach(messageRef -> 
{
 
                         // for now only MVEL expressions
-                        MVELMessageExpressionEvaluator evaluator = new 
MVELMessageExpressionEvaluator(correlationProperty.getRetrievalExpression(messageRef).getScript());
+                        ReturnValueEvaluator evaluator = new 
MVELInterpretedReturnValueEvaluator(correlationProperty.getRetrievalExpression(messageRef).getScript());
                         
correlationManager.addMessagePropertyExpression(key.getId(), messageRef, 
correlationProperty.getId(), evaluator);
                     });
                 }
@@ -251,7 +252,8 @@ public class ProcessHandler extends BaseAbstractHandler 
implements Handler {
         for (CorrelationSubscription subscription : 
HandlerUtil.correlationSubscription(process).values()) {
             
correlationManager.subscribeTo(subscription.getCorrelationKeyRef());
             for (Map.Entry<String, Expression> binding : 
subscription.getPropertyExpressions().entrySet()) {
-                MVELMessageExpressionEvaluator evaluator = new 
MVELMessageExpressionEvaluator(binding.getValue().getScript());
+
+                ReturnValueEvaluator evaluator = new 
MVELInterpretedReturnValueEvaluator(binding.getValue().getScript());
                 
correlationManager.addProcessSubscriptionPropertyExpression(subscription.getCorrelationKeyRef(),
 binding.getKey(), evaluator);
             }
         }
diff --git 
a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/StartEventHandler.java 
b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/StartEventHandler.java
index 7334cd4019..b6b276cb92 100755
--- a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/StartEventHandler.java
+++ b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/StartEventHandler.java
@@ -50,6 +50,7 @@ import org.xml.sax.SAXException;
 import static org.jbpm.ruleflow.core.Metadata.EVENT_TYPE;
 import static org.jbpm.ruleflow.core.Metadata.EVENT_TYPE_MESSAGE;
 import static org.jbpm.ruleflow.core.Metadata.MAPPING_VARIABLE;
+import static org.jbpm.ruleflow.core.Metadata.MESSAGE_REF;
 import static org.jbpm.ruleflow.core.Metadata.MESSAGE_TYPE;
 import static org.jbpm.ruleflow.core.Metadata.TRIGGER_MAPPING;
 import static org.jbpm.ruleflow.core.Metadata.TRIGGER_MAPPING_INPUT;
@@ -138,6 +139,7 @@ public class StartEventHandler extends AbstractNodeHandler {
                 startNode.setMetaData(MESSAGE_TYPE, message.getType());
                 startNode.setMetaData(TRIGGER_TYPE, 
TriggerMetaData.TriggerType.ConsumeMessage.name());
                 startNode.setMetaData(TRIGGER_REF, message.getName());
+                startNode.setMetaData(MESSAGE_REF, message.getId());
 
                 addTriggerWithInMappings(startNode, "Message-" + 
message.getName(), message.getId(), ((RuleFlowProcess) 
parser.getMetaData().get("CurrentProcessDefinition")).getCorrelationManager());
             } else if ("timerEventDefinition".equals(nodeName)) {
diff --git 
a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xpath/XPATHReturnValueEvaluatorBuilder.java
 
b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xpath/XPATHReturnValueEvaluatorBuilder.java
index 704453aed2..3aaa04cbb7 100755
--- 
a/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xpath/XPATHReturnValueEvaluatorBuilder.java
+++ 
b/jbpm/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xpath/XPATHReturnValueEvaluatorBuilder.java
@@ -42,8 +42,7 @@ public class XPATHReturnValueEvaluatorBuilder
         String text = descr.getText();
 
         try {
-            XPATHReturnValueEvaluator expr = new 
XPATHReturnValueEvaluator(text,
-                    null);
+            XPATHReturnValueEvaluator expr = new 
XPATHReturnValueEvaluator(text);
 
             constraintNode.setEvaluator(expr);
 
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ActionNodeVisitor.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ActionNodeVisitor.java
index e77502776e..86ae851d3d 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ActionNodeVisitor.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ActionNodeVisitor.java
@@ -63,6 +63,7 @@ public class ActionNodeVisitor extends 
AbstractNodeVisitor<ActionNode> {
     public void visitNode(String factoryField, ActionNode node, BlockStmt 
body, VariableScope variableScope, ProcessMetaData metadata) {
         body.addStatement(getAssignedFactoryMethod(factoryField, 
ActionNodeFactory.class, getNodeId(node), getNodeKey(), 
getWorkflowElementConstructor(node.getId())))
                 .addStatement(getNameMethod(node, "Script"));
+        visitMetaData(node.getMetaData(), body, getNodeId(node));
 
         Optional<ExpressionSupplier> supplierAction = getAction(node, 
ExpressionSupplier.class);
         if (isIntermediateCompensation(node)) {
@@ -101,7 +102,6 @@ public class ActionNodeVisitor extends 
AbstractNodeVisitor<ActionNode> {
             body.addStatement(getFactoryMethod(getNodeId(node), METHOD_ACTION, 
lambda));
         }
         addNodeMappings(node, body, getNodeId(node));
-        visitMetaData(node.getMetaData(), body, getNodeId(node));
         body.addStatement(getDoneMethod(getNodeId(node)));
     }
 
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/BoundaryEventNodeVisitor.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/BoundaryEventNodeVisitor.java
index e42e95c719..ab0051d501 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/BoundaryEventNodeVisitor.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/BoundaryEventNodeVisitor.java
@@ -46,8 +46,9 @@ public class BoundaryEventNodeVisitor extends 
AbstractNodeVisitor<BoundaryEventN
 
     @Override
     public void visitNode(String factoryField, BoundaryEventNode node, 
BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
-        body.addStatement(getAssignedFactoryMethod(factoryField, 
BoundaryEventNodeFactory.class, getNodeId(node), getNodeKey(), 
getWorkflowElementConstructor(node.getId())))
-                .addStatement(getNameMethod(node, "BoundaryEvent"))
+        body.addStatement(getAssignedFactoryMethod(factoryField, 
BoundaryEventNodeFactory.class, getNodeId(node), getNodeKey(), 
getWorkflowElementConstructor(node.getId())));
+        visitMetaData(node.getMetaData(), body, getNodeId(node));
+        body.addStatement(getNameMethod(node, "BoundaryEvent"))
                 .addStatement(getFactoryMethod(getNodeId(node), 
METHOD_EVENT_TYPE, new StringLiteralExpr(node.getType())))
                 .addStatement(getFactoryMethod(getNodeId(node), 
METHOD_ATTACHED_TO, new StringLiteralExpr(node.getAttachedToNodeId())))
                 .addStatement(getFactoryMethod(getNodeId(node), METHOD_SCOPE, 
getOrNullExpr(node.getScope())));
@@ -70,7 +71,6 @@ public class BoundaryEventNodeVisitor extends 
AbstractNodeVisitor<BoundaryEventN
             body.addStatement(getFactoryMethod(getNodeId(node), 
METHOD_ADD_COMPENSATION_HANDLER, new 
StringLiteralExpr(node.getAttachedToNodeId())));
         }
         addNodeMappings(node, body, getNodeId(node));
-        visitMetaData(node.getMetaData(), body, getNodeId(node));
         body.addStatement(getDoneMethod(getNodeId(node)));
     }
 }
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventNodeVisitor.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventNodeVisitor.java
index 17db88370f..66051eb049 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventNodeVisitor.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventNodeVisitor.java
@@ -44,8 +44,9 @@ public class EventNodeVisitor extends 
AbstractNodeVisitor<EventNode> {
 
     @Override
     public void visitNode(String factoryField, EventNode node, BlockStmt body, 
VariableScope variableScope, ProcessMetaData metadata) {
-        body.addStatement(getAssignedFactoryMethod(factoryField, 
EventNodeFactory.class, getNodeId(node), getNodeKey(), 
getWorkflowElementConstructor(node.getId())))
-                .addStatement(getNameMethod(node, "Event"))
+        body.addStatement(getAssignedFactoryMethod(factoryField, 
EventNodeFactory.class, getNodeId(node), getNodeKey(), 
getWorkflowElementConstructor(node.getId())));
+        visitMetaData(node.getMetaData(), body, getNodeId(node));
+        body.addStatement(getNameMethod(node, "Event"))
                 .addStatement(getFactoryMethod(getNodeId(node), 
METHOD_EVENT_TYPE, new StringLiteralExpr(node.getType())));
 
         Variable variable = null;
@@ -72,7 +73,7 @@ public class EventNodeVisitor extends 
AbstractNodeVisitor<EventNode> {
             }
         }
         addNodeMappings(node, body, getNodeId(node));
-        visitMetaData(node.getMetaData(), body, getNodeId(node));
+
         body.addStatement(getDoneMethod(getNodeId(node)));
     }
 
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ProcessVisitor.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ProcessVisitor.java
index 223f9a8428..30316ea729 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ProcessVisitor.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ProcessVisitor.java
@@ -26,6 +26,7 @@ import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Stream;
 
+import org.jbpm.compiler.canonical.builtin.ReturnValueEvaluatorBuilderService;
 import org.jbpm.compiler.canonical.descriptors.ExpressionUtils;
 import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService;
 import org.jbpm.process.core.Context;
@@ -34,6 +35,11 @@ import org.jbpm.process.core.Work;
 import org.jbpm.process.core.context.exception.ActionExceptionHandler;
 import org.jbpm.process.core.context.exception.ExceptionScope;
 import org.jbpm.process.core.context.variable.VariableScope;
+import org.jbpm.process.core.correlation.Correlation;
+import org.jbpm.process.core.correlation.CorrelationManager;
+import org.jbpm.process.core.correlation.CorrelationProperties;
+import org.jbpm.process.core.correlation.Message;
+import org.jbpm.process.instance.impl.ReturnValueEvaluator;
 import org.jbpm.process.instance.impl.actions.SignalProcessInstanceAction;
 import org.jbpm.ruleflow.core.RuleFlowProcess;
 import org.jbpm.ruleflow.core.RuleFlowProcessFactory;
@@ -80,8 +86,11 @@ public class ProcessVisitor extends AbstractVisitor {
 
     private NodeVisitorBuilderService nodeVisitorService;
 
+    private ReturnValueEvaluatorBuilderService 
returnValueEvaluatorBuilderService;
+
     public ProcessVisitor(ClassLoader contextClassLoader) {
         nodeVisitorService = new NodeVisitorBuilderService(contextClassLoader);
+        returnValueEvaluatorBuilderService = 
ReturnValueEvaluatorBuilderService.instance(contextClassLoader);
     }
 
     public void visitProcess(WorkflowProcess process, MethodDeclaration 
processMethod, ProcessMetaData metadata) {
@@ -131,8 +140,9 @@ public class ProcessVisitor extends AbstractVisitor {
         ((org.jbpm.workflow.core.WorkflowProcess) 
process).getOutputValidator().ifPresent(
                 v -> body.addStatement(getFactoryMethod(FACTORY_FIELD_NAME, 
"outputValidator", ExpressionUtils.getLiteralExpr(v))));
 
-        visitCompensationScope(process, body);
         visitMetaData(process.getMetaData(), body, FACTORY_FIELD_NAME);
+        visitCollaboration(process, body);
+        visitCompensationScope(process, body);
         visitHeader(process, body);
 
         List<Node> processNodes = new ArrayList<>();
@@ -150,6 +160,40 @@ public class ProcessVisitor extends AbstractVisitor {
         body.addStatement(new ReturnStmt(getProcessMethod));
     }
 
+    private void visitCollaboration(WorkflowProcess process, BlockStmt body) {
+        RuleFlowProcess ruleFlowProcess = (RuleFlowProcess) process;
+        CorrelationManager correlationManager = 
ruleFlowProcess.getCorrelationManager();
+
+        for (String messageId : correlationManager.getMessagesId()) {
+            Message message = correlationManager.findMessageById(messageId);
+            body.addStatement(getFactoryMethod(FACTORY_FIELD_NAME, 
"newCorrelationMessage",
+                    new StringLiteralExpr(message.getMessageRef()), new 
StringLiteralExpr(message.getMessageName()), new 
StringLiteralExpr(message.getMessageType())));
+        }
+
+        for (String correlationId : correlationManager.getCorrelationsId()) {
+            Correlation correlation = 
correlationManager.findCorrelationById(correlationId);
+            body.addStatement(getFactoryMethod(FACTORY_FIELD_NAME, 
"newCorrelationKey",
+                    new StringLiteralExpr(correlation.getId()), new 
StringLiteralExpr(correlation.getName())));
+
+            for (String messageId : correlationManager.getMessagesId()) {
+                CorrelationProperties properties = 
correlation.getMessageCorrelationFor(messageId);
+                for (String propertyName : properties.names()) {
+                    ReturnValueEvaluator evaluator = 
properties.getExpressionFor(propertyName);
+                    Expression returnValueEvaluator = 
returnValueEvaluatorBuilderService.build(ruleFlowProcess, evaluator.dialect(), 
evaluator.expression());
+                    body.addStatement(getFactoryMethod(FACTORY_FIELD_NAME, 
"newCorrelationProperty",
+                            new StringLiteralExpr(correlation.getId()), new 
StringLiteralExpr(messageId), new StringLiteralExpr(propertyName), 
returnValueEvaluator));
+                }
+            }
+            CorrelationProperties subscriptions = 
correlation.getProcessSubscription();
+            for (String propertyName : subscriptions.names()) {
+                ReturnValueEvaluator evaluator = 
subscriptions.getExpressionFor(propertyName);
+                Expression returnValueEvaluator = 
returnValueEvaluatorBuilderService.build(ruleFlowProcess, evaluator.dialect(), 
evaluator.expression());
+                body.addStatement(getFactoryMethod(FACTORY_FIELD_NAME, 
"newCorrelationSubscription",
+                        new StringLiteralExpr(correlation.getId()), new 
StringLiteralExpr(propertyName), returnValueEvaluator));
+            }
+        }
+    }
+
     private void visitSubVariableScopes(org.kie.api.definition.process.Node[] 
nodes, BlockStmt body, Set<String> visitedVariables) {
         for (org.kie.api.definition.process.Node node : nodes) {
             if (node instanceof ContextContainer) {
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/SplitNodeVisitor.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/SplitNodeVisitor.java
index 346c044cdc..de434a17a7 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/SplitNodeVisitor.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/SplitNodeVisitor.java
@@ -20,9 +20,13 @@ package org.jbpm.compiler.canonical;
 
 import java.util.Collection;
 import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.function.Predicate;
 
-import org.jbpm.compiler.canonical.builtin.ConstraintEvaluatorBuilderService;
+import org.jbpm.compiler.canonical.builtin.ReturnValueEvaluatorBuilderService;
 import org.jbpm.process.core.context.variable.VariableScope;
+import org.jbpm.process.instance.impl.ReturnValueConstraintEvaluator;
+import org.jbpm.process.instance.impl.ReturnValueEvaluator;
 import org.jbpm.ruleflow.core.factory.SplitFactory;
 import org.jbpm.workflow.core.Constraint;
 import org.jbpm.workflow.core.impl.ConnectionRef;
@@ -39,6 +43,12 @@ import static 
org.jbpm.ruleflow.core.factory.SplitFactory.METHOD_TYPE;
 
 public class SplitNodeVisitor extends AbstractNodeVisitor<Split> {
 
+    ReturnValueEvaluatorBuilderService returnValueEvaluatorBuilderService;
+
+    public SplitNodeVisitor(ReturnValueEvaluatorBuilderService 
returnValueEvaluatorBuilderService) {
+        this.returnValueEvaluatorBuilderService = 
returnValueEvaluatorBuilderService;
+    }
+
     @Override
     protected String getNodeKey() {
         return "splitNode";
@@ -54,20 +64,34 @@ public class SplitNodeVisitor extends 
AbstractNodeVisitor<Split> {
 
         if (node.getType() == Split.TYPE_OR || node.getType() == 
Split.TYPE_XOR) {
             for (Entry<ConnectionRef, Collection<Constraint>> entry : 
node.getConstraints().entrySet()) {
-                if (entry.getValue() != null) {
-                    for (Constraint constraint : entry.getValue()) {
-                        if (constraint != null) {
-                            Expression returnValueEvaluator = 
ConstraintEvaluatorBuilderService.instance().build(node, constraint);
-                            
body.addStatement(getFactoryMethod(getNodeId(node), METHOD_CONSTRAINT,
-                                    
getWorkflowElementConstructor(entry.getKey().getNodeId()),
-                                    new 
StringLiteralExpr(getOrDefault(entry.getKey().getConnectionId(), "")),
-                                    new 
StringLiteralExpr(entry.getKey().getToType()),
-                                    new 
StringLiteralExpr(constraint.getDialect()),
-                                    returnValueEvaluator,
-                                    new 
IntegerLiteralExpr(constraint.getPriority()),
-                                    new 
BooleanLiteralExpr(constraint.isDefault())));
-                        }
+                if (entry.getValue() == null || entry.getValue().isEmpty()) {
+                    continue;
+                }
+
+                for (Constraint constraint : 
entry.getValue().stream().filter(Predicate.not(Objects::isNull)).toList()) {
+                    Expression returnValueEvaluator;
+                    if (constraint instanceof ReturnValueConstraintEvaluator) {
+                        ReturnValueEvaluator evaluator = 
((ReturnValueConstraintEvaluator) constraint).getReturnValueEvaluator();
+                        returnValueEvaluator = 
returnValueEvaluatorBuilderService.build(node,
+                                evaluator.dialect(),
+                                evaluator.expression(),
+                                evaluator.type(),
+                                evaluator.root());
+
+                    } else {
+                        returnValueEvaluator = 
returnValueEvaluatorBuilderService.build(node,
+                                constraint.getDialect(),
+                                constraint.getConstraint());
                     }
+                    body.addStatement(getFactoryMethod(getNodeId(node), 
METHOD_CONSTRAINT,
+                            
getWorkflowElementConstructor(entry.getKey().getNodeId()),
+                            new 
StringLiteralExpr(getOrDefault(entry.getKey().getConnectionId(), "")),
+                            new StringLiteralExpr(entry.getKey().getToType()),
+                            new StringLiteralExpr(constraint.getDialect()),
+                            returnValueEvaluator,
+                            new IntegerLiteralExpr(constraint.getPriority()),
+                            new BooleanLiteralExpr(constraint.isDefault())));
+
                 }
             }
         }
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ExpressionConstraintEvaluatorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ExpressionConstraintEvaluatorBuilder.java
deleted file mode 100644
index ccf09b757a..0000000000
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ExpressionConstraintEvaluatorBuilder.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jbpm.compiler.canonical.builtin;
-
-import java.util.function.Supplier;
-
-import org.jbpm.process.core.ContextResolver;
-import org.jbpm.process.instance.impl.ReturnValueConstraintEvaluator;
-import org.jbpm.workflow.core.Constraint;
-
-import com.github.javaparser.ast.expr.Expression;
-
-public class ExpressionConstraintEvaluatorBuilder implements 
ConstraintEvaluatorBuilder {
-
-    @Override
-    public boolean accept(Constraint constraint) {
-        return constraint instanceof ReturnValueConstraintEvaluator && 
((ReturnValueConstraintEvaluator) constraint).getReturnValueEvaluator() 
instanceof Supplier;
-    }
-
-    @Override
-    public Expression build(ContextResolver resolver, Constraint constraint) {
-        return ((Supplier<Expression>) ((ReturnValueConstraintEvaluator) 
constraint).getReturnValueEvaluator()).get();
-    }
-
-}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/FEELConstraintEvaluatorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/FEELConstraintEvaluatorBuilder.java
index 1f07e81469..33c5f95dfa 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/FEELConstraintEvaluatorBuilder.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/FEELConstraintEvaluatorBuilder.java
@@ -20,7 +20,6 @@ package org.jbpm.compiler.canonical.builtin;
 
 import org.jbpm.process.core.ContextResolver;
 import org.jbpm.process.instance.impl.FeelReturnValueEvaluator;
-import org.jbpm.workflow.core.Constraint;
 import org.kie.kogito.internal.utils.ConversionUtils;
 
 import com.github.javaparser.StaticJavaParser;
@@ -29,18 +28,18 @@ import com.github.javaparser.ast.expr.Expression;
 import com.github.javaparser.ast.expr.ObjectCreationExpr;
 import com.github.javaparser.ast.expr.StringLiteralExpr;
 
-public class FEELConstraintEvaluatorBuilder implements 
ConstraintEvaluatorBuilder {
+public class FEELConstraintEvaluatorBuilder implements 
ReturnValueEvaluatorBuilder {
 
     @Override
-    public boolean accept(Constraint constraint) {
-        return "FEEL".equals(constraint.getDialect());
+    public boolean accept(String dialect) {
+        return dialect.toLowerCase().contains("feel");
     }
 
     @Override
-    public Expression build(ContextResolver resolver, Constraint constraint) {
+    public Expression build(ContextResolver resolver, String expresssion, 
Class<?> type, String rootName) {
         return new ObjectCreationExpr(null,
                 
StaticJavaParser.parseClassOrInterfaceType(FeelReturnValueEvaluator.class.getName()),
-                new NodeList<>(new 
StringLiteralExpr(ConversionUtils.sanitizeString(constraint.getConstraint()))));
+                new NodeList<>(new 
StringLiteralExpr(ConversionUtils.sanitizeString(expresssion))));
     }
 
 }
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JavaConstraintEvaluatorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JavaConstraintEvaluatorBuilder.java
index f9f7a803d7..d85f3fe76b 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JavaConstraintEvaluatorBuilder.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JavaConstraintEvaluatorBuilder.java
@@ -25,7 +25,6 @@ import org.jbpm.compiler.canonical.AbstractNodeVisitor;
 import org.jbpm.process.core.ContextResolver;
 import org.jbpm.process.core.context.variable.Variable;
 import org.jbpm.process.core.context.variable.VariableScope;
-import org.jbpm.workflow.core.Constraint;
 
 import com.github.javaparser.StaticJavaParser;
 import com.github.javaparser.ast.body.Parameter;
@@ -35,21 +34,21 @@ import com.github.javaparser.ast.expr.NameExpr;
 import com.github.javaparser.ast.stmt.BlockStmt;
 import com.github.javaparser.ast.type.UnknownType;
 
-public class JavaConstraintEvaluatorBuilder implements 
ConstraintEvaluatorBuilder {
+public class JavaConstraintEvaluatorBuilder implements 
ReturnValueEvaluatorBuilder {
 
     @Override
-    public boolean accept(Constraint constraint) {
-        return constraint.getDialect().contains("java");
+    public boolean accept(String dialect) {
+        return dialect.toLowerCase().contains("java");
     }
 
     @Override
-    public Expression build(ContextResolver resolver, Constraint constraint) {
+    public Expression build(ContextResolver resolver, String expression, 
Class<?> type, String rootName) {
         BlockStmt actionBody = new BlockStmt();
         LambdaExpr lambda = new LambdaExpr(
                 new Parameter(new UnknownType(), KCONTEXT_VAR), // (kcontext) 
->
                 actionBody);
 
-        BlockStmt blockStmt = StaticJavaParser.parseBlock("{" + 
constraint.getConstraint() + "}");
+        BlockStmt blockStmt = StaticJavaParser.parseBlock("{" + expression + 
"}");
         Set<NameExpr> identifiers = new 
HashSet<>(blockStmt.findAll(NameExpr.class));
 
         for (NameExpr v : identifiers) {
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/MVELConstraintEvaluatorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JqReturnValueEvaluatorBuilder.java
similarity index 57%
copy from 
jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/MVELConstraintEvaluatorBuilder.java
copy to 
jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JqReturnValueEvaluatorBuilder.java
index 124c816873..bb4dae77be 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/MVELConstraintEvaluatorBuilder.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JqReturnValueEvaluatorBuilder.java
@@ -19,29 +19,33 @@
 package org.jbpm.compiler.canonical.builtin;
 
 import org.jbpm.process.core.ContextResolver;
-import org.jbpm.process.instance.impl.MVELInterpretedReturnValueEvaluator;
-import org.jbpm.workflow.core.Constraint;
+import org.jbpm.process.instance.impl.ExpressionReturnValueEvaluator;
 import org.kie.kogito.internal.utils.ConversionUtils;
 
 import com.github.javaparser.StaticJavaParser;
 import com.github.javaparser.ast.NodeList;
+import com.github.javaparser.ast.expr.ClassExpr;
 import com.github.javaparser.ast.expr.Expression;
 import com.github.javaparser.ast.expr.ObjectCreationExpr;
 import com.github.javaparser.ast.expr.StringLiteralExpr;
 
-public class MVELConstraintEvaluatorBuilder implements 
ConstraintEvaluatorBuilder {
+public class JqReturnValueEvaluatorBuilder implements 
ReturnValueEvaluatorBuilder {
 
     @Override
-    public boolean accept(Constraint constraint) {
-        return "mvel".equals(constraint.getDialect());
+    public boolean accept(String dialect) {
+        return dialect.toLowerCase().contains("jq");
     }
 
     @Override
-    public Expression build(ContextResolver resolver, Constraint constraint) {
+    public Expression build(ContextResolver resolver, String expression, 
Class<?> type, String rootName) {
+        NodeList<Expression> arguments = new NodeList<>();
+        arguments.add(new StringLiteralExpr("jq"));
+        arguments.add(new 
StringLiteralExpr(ConversionUtils.sanitizeString(expression)));
+        arguments.add(new StringLiteralExpr(rootName));
+        arguments.add(new 
ClassExpr(StaticJavaParser.parseClassOrInterfaceType(type.getName())));
+
+        return new ObjectCreationExpr(null, 
StaticJavaParser.parseClassOrInterfaceType(ExpressionReturnValueEvaluator.class.getName()),
 arguments);
 
-        return new ObjectCreationExpr(null,
-                
StaticJavaParser.parseClassOrInterfaceType(MVELInterpretedReturnValueEvaluator.class.getName()),
-                new NodeList<>(new 
StringLiteralExpr(ConversionUtils.sanitizeString(constraint.getConstraint()))));
     }
 
 }
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/MVELConstraintEvaluatorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JsonpathReturnValueEvaluatorBuilder.java
similarity index 57%
copy from 
jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/MVELConstraintEvaluatorBuilder.java
copy to 
jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JsonpathReturnValueEvaluatorBuilder.java
index 124c816873..c2035c64ba 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/MVELConstraintEvaluatorBuilder.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/JsonpathReturnValueEvaluatorBuilder.java
@@ -19,29 +19,33 @@
 package org.jbpm.compiler.canonical.builtin;
 
 import org.jbpm.process.core.ContextResolver;
-import org.jbpm.process.instance.impl.MVELInterpretedReturnValueEvaluator;
-import org.jbpm.workflow.core.Constraint;
+import org.jbpm.process.instance.impl.ExpressionReturnValueEvaluator;
 import org.kie.kogito.internal.utils.ConversionUtils;
 
 import com.github.javaparser.StaticJavaParser;
 import com.github.javaparser.ast.NodeList;
+import com.github.javaparser.ast.expr.ClassExpr;
 import com.github.javaparser.ast.expr.Expression;
 import com.github.javaparser.ast.expr.ObjectCreationExpr;
 import com.github.javaparser.ast.expr.StringLiteralExpr;
 
-public class MVELConstraintEvaluatorBuilder implements 
ConstraintEvaluatorBuilder {
+public class JsonpathReturnValueEvaluatorBuilder implements 
ReturnValueEvaluatorBuilder {
 
     @Override
-    public boolean accept(Constraint constraint) {
-        return "mvel".equals(constraint.getDialect());
+    public boolean accept(String dialect) {
+        return dialect.toLowerCase().contains("jsonpath");
     }
 
     @Override
-    public Expression build(ContextResolver resolver, Constraint constraint) {
+    public Expression build(ContextResolver resolver, String expression, 
Class<?> type, String rootName) {
+        NodeList<Expression> arguments = new NodeList<>();
+        arguments.add(new StringLiteralExpr("jsonpath"));
+        arguments.add(new 
StringLiteralExpr(ConversionUtils.sanitizeString(expression)));
+        arguments.add(new StringLiteralExpr(rootName));
+        arguments.add(new 
ClassExpr(StaticJavaParser.parseClassOrInterfaceType(type.getName())));
+
+        return new ObjectCreationExpr(null, 
StaticJavaParser.parseClassOrInterfaceType(ExpressionReturnValueEvaluator.class.getName()),
 arguments);
 
-        return new ObjectCreationExpr(null,
-                
StaticJavaParser.parseClassOrInterfaceType(MVELInterpretedReturnValueEvaluator.class.getName()),
-                new NodeList<>(new 
StringLiteralExpr(ConversionUtils.sanitizeString(constraint.getConstraint()))));
     }
 
 }
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/MVELConstraintEvaluatorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/MVELConstraintEvaluatorBuilder.java
index 124c816873..822327e36a 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/MVELConstraintEvaluatorBuilder.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/MVELConstraintEvaluatorBuilder.java
@@ -20,7 +20,6 @@ package org.jbpm.compiler.canonical.builtin;
 
 import org.jbpm.process.core.ContextResolver;
 import org.jbpm.process.instance.impl.MVELInterpretedReturnValueEvaluator;
-import org.jbpm.workflow.core.Constraint;
 import org.kie.kogito.internal.utils.ConversionUtils;
 
 import com.github.javaparser.StaticJavaParser;
@@ -29,19 +28,19 @@ import com.github.javaparser.ast.expr.Expression;
 import com.github.javaparser.ast.expr.ObjectCreationExpr;
 import com.github.javaparser.ast.expr.StringLiteralExpr;
 
-public class MVELConstraintEvaluatorBuilder implements 
ConstraintEvaluatorBuilder {
+public class MVELConstraintEvaluatorBuilder implements 
ReturnValueEvaluatorBuilder {
 
     @Override
-    public boolean accept(Constraint constraint) {
-        return "mvel".equals(constraint.getDialect());
+    public boolean accept(String dialect) {
+        return dialect.toLowerCase().contains("mvel");
     }
 
     @Override
-    public Expression build(ContextResolver resolver, Constraint constraint) {
+    public Expression build(ContextResolver resolver, String expression, 
Class<?> type, String rootName) {
 
         return new ObjectCreationExpr(null,
                 
StaticJavaParser.parseClassOrInterfaceType(MVELInterpretedReturnValueEvaluator.class.getName()),
-                new NodeList<>(new 
StringLiteralExpr(ConversionUtils.sanitizeString(constraint.getConstraint()))));
+                new NodeList<>(new 
StringLiteralExpr(ConversionUtils.sanitizeString(expression))));
     }
 
 }
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ConstraintEvaluatorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ReturnValueEvaluatorBuilder.java
similarity index 74%
rename from 
jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ConstraintEvaluatorBuilder.java
rename to 
jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ReturnValueEvaluatorBuilder.java
index 71f0c09a22..b07f793ec9 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ConstraintEvaluatorBuilder.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ReturnValueEvaluatorBuilder.java
@@ -19,15 +19,19 @@
 package org.jbpm.compiler.canonical.builtin;
 
 import org.jbpm.process.core.ContextResolver;
-import org.jbpm.workflow.core.Constraint;
 
 import com.github.javaparser.ast.expr.Expression;
 
-public interface ConstraintEvaluatorBuilder {
+public interface ReturnValueEvaluatorBuilder {
 
     String KCONTEXT_VAR = "kcontext";
 
-    boolean accept(Constraint constraint);
+    boolean accept(String constraint);
+
+    Expression build(ContextResolver resolver, String expression, Class<?> 
type, String rootName);
+
+    default Expression build(ContextResolver resolver, String expression) {
+        return this.build(resolver, expression, Object.class, null);
+    }
 
-    Expression build(ContextResolver resolver, 
org.jbpm.workflow.core.Constraint constraint);
 }
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ConstraintEvaluatorBuilderService.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ReturnValueEvaluatorBuilderService.java
similarity index 50%
rename from 
jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ConstraintEvaluatorBuilderService.java
rename to 
jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ReturnValueEvaluatorBuilderService.java
index 6216414cdc..7c4b999bf9 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ConstraintEvaluatorBuilderService.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/ReturnValueEvaluatorBuilderService.java
@@ -23,35 +23,46 @@ import java.util.ServiceLoader;
 
 import org.jbpm.process.core.ContextResolver;
 import org.jbpm.util.JbpmClassLoaderUtil;
-import org.jbpm.workflow.core.Constraint;
 
 import com.github.javaparser.ast.expr.Expression;
 
-public class ConstraintEvaluatorBuilderService {
+public class ReturnValueEvaluatorBuilderService {
 
-    private static ConstraintEvaluatorBuilderService INSTANCE;
-    private List<ConstraintEvaluatorBuilder> builders;
+    private static ReturnValueEvaluatorBuilderService INSTANCE;
+    private List<ReturnValueEvaluatorBuilder> builders;
 
-    public static ConstraintEvaluatorBuilderService instance() {
+    private ReturnValueEvaluatorBuilderService(ClassLoader contextClassLoader) 
{
+        builders = ServiceLoader.load(ReturnValueEvaluatorBuilder.class, 
contextClassLoader)
+                .stream()
+                .map(ServiceLoader.Provider::get)
+                .toList();
+    }
+
+    public static ReturnValueEvaluatorBuilderService instance() {
         if (INSTANCE == null) {
-            INSTANCE = new ConstraintEvaluatorBuilderService();
+            INSTANCE = instance(JbpmClassLoaderUtil.findClassLoader());
         }
         return INSTANCE;
     }
 
-    public ConstraintEvaluatorBuilderService() {
-        builders = ServiceLoader.load(ConstraintEvaluatorBuilder.class, 
JbpmClassLoaderUtil.findClassLoader())
-                .stream()
-                .map(ServiceLoader.Provider::get)
-                .toList();
+    public static ReturnValueEvaluatorBuilderService instance(ClassLoader 
contextClassLoader) {
+        return new ReturnValueEvaluatorBuilderService(contextClassLoader);
+    }
+
+    public ReturnValueEvaluatorBuilderService() {
+        this(JbpmClassLoaderUtil.findClassLoader());
+    }
+
+    public Expression build(ContextResolver resolver, String dialect, String 
expression) {
+        return build(resolver, dialect, expression, Object.class, null);
     }
 
-    public Expression build(ContextResolver resolver, Constraint constraint) {
-        for (ConstraintEvaluatorBuilder builder : builders) {
-            if (builder.accept(constraint)) {
-                return builder.build(resolver, constraint);
+    public Expression build(ContextResolver resolver, String dialect, String 
expression, Class<?> type, String root) {
+        for (ReturnValueEvaluatorBuilder builder : builders) {
+            if (builder.accept(dialect)) {
+                return builder.build(resolver, expression, type, root);
             }
         }
-        throw new IllegalArgumentException("No dialect found " + 
constraint.getDialect() + " for building constraint");
+        throw new IllegalArgumentException("No dialect found " + dialect + " 
for return expression evaluator building return value expression");
     }
 }
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/XPATHConstraintEvaluatorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/XPATHConstraintEvaluatorBuilder.java
index a2f3fac0c5..a6451f25ef 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/XPATHConstraintEvaluatorBuilder.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/builtin/XPATHConstraintEvaluatorBuilder.java
@@ -20,28 +20,26 @@ package org.jbpm.compiler.canonical.builtin;
 
 import org.jbpm.process.core.ContextResolver;
 import org.jbpm.process.instance.impl.XPATHReturnValueEvaluator;
-import org.jbpm.workflow.core.Constraint;
 import org.kie.kogito.internal.utils.ConversionUtils;
 
 import com.github.javaparser.StaticJavaParser;
 import com.github.javaparser.ast.NodeList;
 import com.github.javaparser.ast.expr.Expression;
-import com.github.javaparser.ast.expr.NullLiteralExpr;
 import com.github.javaparser.ast.expr.ObjectCreationExpr;
 import com.github.javaparser.ast.expr.StringLiteralExpr;
 
-public class XPATHConstraintEvaluatorBuilder implements 
ConstraintEvaluatorBuilder {
+public class XPATHConstraintEvaluatorBuilder implements 
ReturnValueEvaluatorBuilder {
 
     @Override
-    public boolean accept(Constraint constraint) {
-        return constraint.getDialect().toLowerCase().contains("xpath");
+    public boolean accept(String dialect) {
+        return dialect.toLowerCase().contains("xpath");
     }
 
     @Override
-    public Expression build(ContextResolver resolver, Constraint constraint) {
+    public Expression build(ContextResolver resolver, String expression, 
Class<?> type, String rootName) {
         return new ObjectCreationExpr(null,
                 
StaticJavaParser.parseClassOrInterfaceType(XPATHReturnValueEvaluator.class.getName()),
-                new NodeList<>(new 
StringLiteralExpr(ConversionUtils.sanitizeString(constraint.getConstraint())), 
new NullLiteralExpr()));
+                new NodeList<>(new 
StringLiteralExpr(ConversionUtils.sanitizeString(expression))));
     }
 
 }
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SplitNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SplitNodeVisitorBuilder.java
index 3d29c31d31..ca874e76af 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SplitNodeVisitorBuilder.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SplitNodeVisitorBuilder.java
@@ -20,6 +20,7 @@ package org.jbpm.compiler.canonical.node;
 
 import org.jbpm.compiler.canonical.AbstractNodeVisitor;
 import org.jbpm.compiler.canonical.SplitNodeVisitor;
+import org.jbpm.compiler.canonical.builtin.ReturnValueEvaluatorBuilderService;
 import org.jbpm.workflow.core.node.Split;
 import org.kie.api.definition.process.Node;
 
@@ -32,7 +33,7 @@ public class SplitNodeVisitorBuilder implements 
NodeVisitorBuilder {
 
     @Override
     public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
-        return new SplitNodeVisitor();
+        return new 
SplitNodeVisitor(ReturnValueEvaluatorBuilderService.instance(classLoader));
     }
 
 }
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/dialect/mvel/MVELReturnValueEvaluatorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/dialect/mvel/MVELReturnValueEvaluatorBuilder.java
index 9fe8582702..6ee7990f96 100755
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/dialect/mvel/MVELReturnValueEvaluatorBuilder.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/process/builder/dialect/mvel/MVELReturnValueEvaluatorBuilder.java
@@ -120,8 +120,7 @@ public class MVELReturnValueEvaluatorBuilder extends 
AbstractMVELBuilder
                 false,
                 MVELCompilationUnit.Scope.EXPRESSION);
 
-        MVELReturnValueEvaluator expr = new MVELReturnValueEvaluator(unit,
-                dialect.getId());
+        MVELReturnValueEvaluator expr = new MVELReturnValueEvaluator(unit);
 
         constraintNode.setEvaluator(expr);
 
diff --git 
a/jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.builtin.ConstraintEvaluatorBuilder
 
b/jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.builtin.ReturnValueEvaluatorBuilder
similarity index 65%
rename from 
jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.builtin.ConstraintEvaluatorBuilder
rename to 
jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.builtin.ReturnValueEvaluatorBuilder
index 2b3fc98021..425017a9b7 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.builtin.ConstraintEvaluatorBuilder
+++ 
b/jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.builtin.ReturnValueEvaluatorBuilder
@@ -1,5 +1,6 @@
-org.jbpm.compiler.canonical.builtin.ExpressionConstraintEvaluatorBuilder
 org.jbpm.compiler.canonical.builtin.FEELConstraintEvaluatorBuilder
 org.jbpm.compiler.canonical.builtin.JavaConstraintEvaluatorBuilder
 org.jbpm.compiler.canonical.builtin.XPATHConstraintEvaluatorBuilder
-org.jbpm.compiler.canonical.builtin.MVELConstraintEvaluatorBuilder
\ No newline at end of file
+org.jbpm.compiler.canonical.builtin.MVELConstraintEvaluatorBuilder
+org.jbpm.compiler.canonical.builtin.JsonpathReturnValueEvaluatorBuilder
+org.jbpm.compiler.canonical.builtin.JqReturnValueEvaluatorBuilder
\ No newline at end of file
diff --git 
a/jbpm/jbpm-flow-builder/src/main/resources/org/jbpm/process/builder/dialect/java/javaInvokers.mvel
 
b/jbpm/jbpm-flow-builder/src/main/resources/org/jbpm/process/builder/dialect/java/javaInvokers.mvel
index 3a6f256958..22c345478c 100755
--- 
a/jbpm/jbpm-flow-builder/src/main/resources/org/jbpm/process/builder/dialect/java/javaInvokers.mvel
+++ 
b/jbpm/jbpm-flow-builder/src/main/resources/org/jbpm/process/builder/dialect/java/javaInvokers.mvel
@@ -53,7 +53,8 @@ public class @{invokerClassName} implements 
org.jbpm.process.instance.impl.Retur
 {
     private static final long serialVersionUID  = 510l;
 
-    public Object 
evaluate(org.kie.kogito.internal.process.runtime.KogitoProcessContext 
processContext) throws Exception {
+    public Object 
evaluate(org.kie.kogito.internal.process.runtime.KogitoProcessContext 
processContext) {
+        try {
 
         @foreach{type : globalTypes, identifier : globals} @{type} 
@{identifier} = ( @{type} ) processContext.getKieRuntime().getGlobal( 
"@{identifier}" );
         @end{}
@@ -67,8 +68,11 @@ public class @{invokerClassName} implements 
org.jbpm.process.instance.impl.Retur
                @end{","}@if{variables != empty},@end{}
                @foreach{identifier : variables} @{identifier}
                @end{","} );
+           } catch(Exception e) {
+              return new RuntimeException(e);
+           }
     }
-    
+
     public String getMethodBytecode() {
         return null;
     }
diff --git 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationExpressionEvaluator.java
 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationExpressionEvaluator.java
deleted file mode 100644
index dc6dbafdea..0000000000
--- 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationExpressionEvaluator.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jbpm.process.core.correlation;
-
-import java.io.Serializable;
-import java.util.function.Function;
-
-public interface CorrelationExpressionEvaluator extends Serializable {
-
-    Object eval(Object event);
-
-    Object eval(Function<String, Object> resolver);
-}
\ No newline at end of file
diff --git 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationManager.java
 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationManager.java
index 7124c9d018..0237938fd3 100644
--- 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationManager.java
+++ 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationManager.java
@@ -21,8 +21,12 @@ package org.jbpm.process.core.correlation;
 import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 import java.util.function.Function;
 
+import org.jbpm.process.instance.impl.ReturnValueEvaluator;
+import org.jbpm.util.JbpmClassLoaderUtil;
+
 public class CorrelationManager implements Serializable {
 
     private static final long serialVersionUID = -1557112455565607001L;
@@ -35,6 +39,7 @@ public class CorrelationManager implements Serializable {
     public CorrelationManager() {
         this.correlations = new HashMap<>();
         this.messages = new HashMap<>();
+        this.classLoader = JbpmClassLoaderUtil.findClassLoader();
     }
 
     public void setClassLoader(ClassLoader classLoader) {
@@ -91,7 +96,7 @@ public class CorrelationManager implements Serializable {
         CorrelationInstance correlationInstance = new 
CorrelationInstance(correlation.getId(), correlation.getName());
         CorrelationProperties properties = 
correlation.getMessageCorrelationFor(messageRef);
         for (String name : properties.names()) {
-            CorrelationExpressionEvaluator evaluator = 
properties.getExpressionFor(name);
+            ReturnValueEvaluator evaluator = properties.getExpressionFor(name);
             Object val = evaluator.eval(event);
             if (val == null) {
                 throw new IllegalArgumentException("Message property evaluated 
to null is not possible: " + messageRef + " property " + name);
@@ -110,7 +115,7 @@ public class CorrelationManager implements Serializable {
         CorrelationProperties properties = 
correlation.getProcessSubscription();
 
         for (String name : properties.names()) {
-            CorrelationExpressionEvaluator evaluator = 
properties.getExpressionFor(name);
+            ReturnValueEvaluator evaluator = properties.getExpressionFor(name);
             Object val = evaluator.eval(resolver);
             if (val == null) {
                 throw new IllegalArgumentException("Process Subscription 
property evaluated to null is not possible: " + messageRef + " property " + 
name);
@@ -130,14 +135,31 @@ public class CorrelationManager implements Serializable {
         throw new IllegalArgumentException("Correlation for message ref " + 
messageRef + " does not exist");
     }
 
-    public void addMessagePropertyExpression(String correlationRef, String 
messageRef, String propertyName, CorrelationExpressionEvaluator expression) {
+    public void addMessagePropertyExpression(String correlationRef, String 
messageRef, String propertyName, ReturnValueEvaluator expression) {
         
correlations.get(correlationRef).getMessageCorrelationFor(messageRef).addProperty(propertyName,
 expression);
     }
 
-    public void addProcessSubscriptionPropertyExpression(String 
correlationRef, String propertyName, CorrelationExpressionEvaluator expression) 
{
+    public void addProcessSubscriptionPropertyExpression(String 
correlationRef, String propertyName, ReturnValueEvaluator expression) {
         if (!correlations.containsKey(correlationRef)) {
             return;
         }
         
correlations.get(correlationRef).getProcessSubscription().addProperty(propertyName,
 expression);
     }
+
+    public Set<String> getMessagesId() {
+        return messages.keySet();
+    }
+
+    public Message findMessageById(String messageId) {
+        return messages.get(messageId);
+    }
+
+    public Set<String> getCorrelationsId() {
+        return correlations.keySet();
+    }
+
+    public Correlation findCorrelationById(String correlationId) {
+        return correlations.get(correlationId);
+    }
+
 }
\ No newline at end of file
diff --git 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationProperties.java
 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationProperties.java
index 9fa437ff05..92d7774706 100644
--- 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationProperties.java
+++ 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/correlation/CorrelationProperties.java
@@ -23,17 +23,19 @@ import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.jbpm.process.instance.impl.ReturnValueEvaluator;
+
 public class CorrelationProperties implements Serializable {
 
     private static final long serialVersionUID = 4740957354662392843L;
 
-    private Map<String, CorrelationExpressionEvaluator> properties;
+    private Map<String, ReturnValueEvaluator> properties;
 
     public CorrelationProperties() {
         this.properties = new HashMap<>();
     }
 
-    public void addProperty(String name, CorrelationExpressionEvaluator 
expression) {
+    public void addProperty(String name, ReturnValueEvaluator expression) {
         properties.put(name, expression);
     }
 
@@ -45,7 +47,7 @@ public class CorrelationProperties implements Serializable {
         return properties.keySet();
     }
 
-    public CorrelationExpressionEvaluator getExpressionFor(String 
propertyName) {
+    public ReturnValueEvaluator getExpressionFor(String propertyName) {
         return properties.get(propertyName);
     }
 
diff --git 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/EventTypeFilter.java 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/EventTypeFilter.java
index 6177d6cbcc..01ee3388e2 100755
--- 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/EventTypeFilter.java
+++ 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/EventTypeFilter.java
@@ -61,7 +61,7 @@ public class EventTypeFilter implements EventFilter, 
Serializable {
 
     @Override
     public boolean acceptsEvent(String type, Object event, Function<String, 
Object> resolver) {
-        logger.info("This event is subscribed to a message ref {} {}", type, 
event);
+        logger.debug("This event is subscribed to a message type {} with 
payload {}", type, event);
         if (resolver == null) {
             return this.type != null && this.type.equals(type);
         }
diff --git 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/MVELMessageExpressionEvaluator.java
 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/MVELMessageExpressionEvaluator.java
deleted file mode 100644
index a16e9e920c..0000000000
--- 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/event/MVELMessageExpressionEvaluator.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.jbpm.process.core.event;
-
-import java.util.function.Function;
-
-import org.jbpm.process.core.correlation.CorrelationExpressionEvaluator;
-import org.mvel2.MVEL;
-import org.mvel2.integration.VariableResolver;
-import org.mvel2.integration.impl.ImmutableDefaultFactory;
-import org.mvel2.integration.impl.SimpleValueResolver;
-
-public class MVELMessageExpressionEvaluator implements 
CorrelationExpressionEvaluator {
-
-    private static final long serialVersionUID = 3516244528735842694L;
-
-    private String expression;
-
-    public MVELMessageExpressionEvaluator(String expression) {
-        this.expression = expression;
-    }
-
-    @Override
-    public Object eval(Object event) {
-        return MVEL.eval(expression, event);
-    }
-
-    @Override
-    public Object eval(Function<String, Object> resolver) {
-        ImmutableDefaultFactory factory = new ImmutableDefaultFactory() {
-            private static final long serialVersionUID = 1L;
-
-            @Override
-            public boolean isResolveable(String name) {
-                return resolver.apply("#{" + name + "}") != null;
-            };
-
-            @Override
-            public VariableResolver getVariableResolver(String name) {
-                return new SimpleValueResolver(resolver.apply("#{" + name + 
"}"));
-            };
-        };
-        return MVEL.eval(expression, factory);
-    }
-
-}
\ No newline at end of file
diff --git 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/KogitoProcessContextImpl.java
 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/KogitoProcessContextImpl.java
index d562db27a7..1b2bba1bda 100755
--- 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/KogitoProcessContextImpl.java
+++ 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/KogitoProcessContextImpl.java
@@ -22,6 +22,8 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.drools.core.process.AbstractProcessContext;
+import org.jbpm.process.core.ContextResolver;
+import org.jbpm.process.core.context.variable.VariableScope;
 import org.kie.api.runtime.KieRuntime;
 import org.kie.kogito.internal.process.runtime.KogitoNodeInstance;
 import org.kie.kogito.internal.process.runtime.KogitoProcessContext;
@@ -37,6 +39,20 @@ public class KogitoProcessContextImpl extends 
AbstractProcessContext implements
         contextData = new HashMap<>();
     }
 
+    public boolean isVariableResolvable(String variableId) {
+        if (contextData.containsKey(variableId)) {
+            return true;
+        }
+
+        KogitoNodeInstance nodeInstance = getNodeInstance();
+        if (nodeInstance instanceof ContextResolver) {
+            ContextResolver resolver = (ContextResolver) nodeInstance;
+            return resolver.resolveContext(VariableScope.VARIABLE_SCOPE, 
variableId) != null;
+        }
+
+        return nodeInstance.getVariable(variableId) != null;
+    }
+
     @Override
     public KogitoProcessInstance getProcessInstance() {
         return (KogitoProcessInstance) super.getProcessInstance();
diff --git 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/LightProcessRuntimeContext.java
 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/LightProcessRuntimeContext.java
index 2974923642..3fe0f58ebc 100644
--- 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/LightProcessRuntimeContext.java
+++ 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/LightProcessRuntimeContext.java
@@ -71,7 +71,7 @@ public class LightProcessRuntimeContext implements 
ProcessRuntimeContext {
 
     @Override
     public boolean isActive() {
-        return false;
+        return true;
     }
 
     @Override
diff --git 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/AbstractReturnValueEvaluator.java
 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/AbstractReturnValueEvaluator.java
new file mode 100644
index 0000000000..465a8452b3
--- /dev/null
+++ 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/AbstractReturnValueEvaluator.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.jbpm.process.instance.impl;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+public abstract class AbstractReturnValueEvaluator implements 
ReturnValueEvaluator, Externalizable {
+
+    protected String dialect;
+    protected String expression;
+    protected Class<?> type;
+    private String root;
+
+    public AbstractReturnValueEvaluator(String dialect, String expression) {
+        this(dialect, expression, Object.class, null);
+    }
+
+    public AbstractReturnValueEvaluator(String dialect, String expression, 
Class<?> type, String root) {
+        this.dialect = dialect;
+        this.expression = expression;
+        this.type = type;
+        this.root = root;
+    }
+
+    @Override
+    public String root() {
+        return root;
+    }
+
+    @Override
+    public Class<?> type() {
+        return type;
+    }
+
+    @Override
+    public String dialect() {
+        return dialect;
+    }
+
+    @Override
+    public String expression() {
+        return expression;
+    }
+
+    public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
+        this.expression = in.readUTF();
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeUTF(this.expression);
+    }
+
+    public String toString() {
+        return "[" + dialect + "] (" + this.expression + ")";
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/KogitoProcessContextImpl.java
 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/EmtpyKogitoProcessContext.java
old mode 100755
new mode 100644
similarity index 62%
copy from 
jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/KogitoProcessContextImpl.java
copy to 
jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/EmtpyKogitoProcessContext.java
index d562db27a7..3d1e3477e6
--- 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/KogitoProcessContextImpl.java
+++ 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/EmtpyKogitoProcessContext.java
@@ -16,49 +16,60 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.jbpm.process.instance;
 
-import java.util.HashMap;
+package org.jbpm.process.instance.impl;
+
+import java.util.Collections;
 import java.util.Map;
+import java.util.function.Function;
 
-import org.drools.core.process.AbstractProcessContext;
 import org.kie.api.runtime.KieRuntime;
 import org.kie.kogito.internal.process.runtime.KogitoNodeInstance;
 import org.kie.kogito.internal.process.runtime.KogitoProcessContext;
 import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
 import org.kie.kogito.internal.process.runtime.KogitoProcessRuntime;
 
-public class KogitoProcessContextImpl extends AbstractProcessContext 
implements KogitoProcessContext {
+public class EmtpyKogitoProcessContext implements KogitoProcessContext {
 
-    private Map<String, Object> contextData;
+    private Function<String, Object> resolver;
 
-    public KogitoProcessContextImpl(KieRuntime kruntime) {
-        super(kruntime);
-        contextData = new HashMap<>();
+    public EmtpyKogitoProcessContext(Function<String, Object> resolver) {
+        this.resolver = resolver;
     }
 
     @Override
     public KogitoProcessInstance getProcessInstance() {
-        return (KogitoProcessInstance) super.getProcessInstance();
+        throw new UnsupportedOperationException();
     }
 
     @Override
     public KogitoNodeInstance getNodeInstance() {
-        return (KogitoNodeInstance) super.getNodeInstance();
+        throw new UnsupportedOperationException();
     }
 
     @Override
-    public KogitoProcessRuntime getKogitoProcessRuntime() {
-        return InternalProcessRuntime.asKogitoProcessRuntime(getKieRuntime());
+    public Object getVariable(String variableName) {
+        return resolver.apply(variableName);
+    }
+
+    @Override
+    public void setVariable(String variableName, Object value) {
+        throw new UnsupportedOperationException();
     }
 
-    public void setContextData(Map<String, Object> contextData) {
-        this.contextData = contextData;
+    @Override
+    public KieRuntime getKieRuntime() {
+        throw new UnsupportedOperationException();
+    }
 
+    @Override
+    public KogitoProcessRuntime getKogitoProcessRuntime() {
+        throw new UnsupportedOperationException();
     }
 
     @Override
     public Map<String, Object> getContextData() {
-        return contextData;
+        return Collections.emptyMap();
     }
-}
+
+}
\ No newline at end of file
diff --git 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/ExpressionReturnValueEvaluator.java
 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/ExpressionReturnValueEvaluator.java
index 4b406140a6..e4c7ae03d4 100644
--- 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/ExpressionReturnValueEvaluator.java
+++ 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/ExpressionReturnValueEvaluator.java
@@ -22,23 +22,20 @@ import 
org.kie.kogito.internal.process.runtime.KogitoProcessContext;
 import org.kie.kogito.process.expr.Expression;
 import org.kie.kogito.process.expr.ExpressionHandlerFactory;
 
-public class ExpressionReturnValueEvaluator implements ReturnValueEvaluator {
+public class ExpressionReturnValueEvaluator extends 
AbstractReturnValueEvaluator {
     private Expression expression;
-    private String rootName;
-    private Class<?> returnType;
 
     public ExpressionReturnValueEvaluator(String lang, String expression, 
String rootName) {
         this(lang, expression, rootName, Boolean.class);
     }
 
     public ExpressionReturnValueEvaluator(String lang, String expression, 
String rootName, Class<?> returnType) {
+        super(lang, expression, returnType, rootName);
         this.expression = ExpressionHandlerFactory.get(lang, expression);
-        this.rootName = rootName;
-        this.returnType = returnType;
     }
 
     @Override
-    public Object evaluate(KogitoProcessContext processContext) throws 
Exception {
-        return expression.eval(processContext.getVariable(rootName), 
returnType, processContext);
+    public Object evaluate(KogitoProcessContext processContext) {
+        return expression.eval(processContext.getVariable(root()), type(), 
processContext);
     }
 }
diff --git 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/FeelReturnValueEvaluator.java
 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/FeelReturnValueEvaluator.java
index 608c0bd790..9f09d86ff1 100644
--- 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/FeelReturnValueEvaluator.java
+++ 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/FeelReturnValueEvaluator.java
@@ -18,10 +18,6 @@
  */
 package org.jbpm.process.instance.impl;
 
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -38,28 +34,17 @@ import org.kie.dmn.feel.lang.impl.FEELBuilder;
 import org.kie.dmn.feel.parser.feel11.profiles.KieExtendedFEELProfile;
 import org.kie.kogito.internal.process.runtime.KogitoProcessContext;
 
-public class FeelReturnValueEvaluator implements ReturnValueEvaluator, 
Externalizable {
-
-    private static final long serialVersionUID = 630l;
-
-    private String expr;
+public class FeelReturnValueEvaluator extends AbstractReturnValueEvaluator {
 
     public FeelReturnValueEvaluator() {
+        super("FEEL", "true()");
     }
 
     public FeelReturnValueEvaluator(String expr) {
-        this.expr = expr;
-    }
-
-    public void readExternal(ObjectInput in) throws IOException, 
ClassNotFoundException {
-        expr = in.readUTF();
+        super("FEEL", expr);
     }
 
-    public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeUTF(expr);
-    }
-
-    public Object evaluate(KogitoProcessContext context) throws Exception {
+    public Object evaluate(KogitoProcessContext context) {
         Map<String, Object> variables = new HashMap<>();
         variables.put("kcontext", context);
 
@@ -82,12 +67,12 @@ public class FeelReturnValueEvaluator implements 
ReturnValueEvaluator, Externali
         FeelErrorEvaluatorListener listener = new FeelErrorEvaluatorListener();
         feel.addListener(listener);
 
-        Object value = feel.evaluate(expr, variables);
+        Object value = feel.evaluate(expression(), variables);
 
         processErrorEvents(listener.getErrorEvents());
         if (!(value instanceof Boolean)) {
             throw new RuntimeException("Constraints must return boolean 
values: " +
-                    expr + " returns " + value +
+                    expression() + " returns " + value +
                     (value == null ? "" : " (type=" + value.getClass()));
         }
 
@@ -113,7 +98,4 @@ public class FeelReturnValueEvaluator implements 
ReturnValueEvaluator, Externali
         return messageBuilder.toString();
     }
 
-    public String toString() {
-        return this.expr;
-    }
 }
diff --git 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/MVELInterpretedReturnValueEvaluator.java
 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/MVELInterpretedReturnValueEvaluator.java
index fb57b53f96..5a969fbb5b 100644
--- 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/MVELInterpretedReturnValueEvaluator.java
+++ 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/MVELInterpretedReturnValueEvaluator.java
@@ -18,24 +18,51 @@
  */
 package org.jbpm.process.instance.impl;
 
+import java.util.function.Function;
+
+import org.jbpm.process.instance.KogitoProcessContextImpl;
 import org.kie.kogito.internal.process.runtime.KogitoProcessContext;
 import org.mvel2.MVEL;
 import org.mvel2.integration.VariableResolver;
 import org.mvel2.integration.impl.ImmutableDefaultFactory;
 import org.mvel2.integration.impl.SimpleValueResolver;
 
-public class MVELInterpretedReturnValueEvaluator implements 
ReturnValueEvaluator {
-
-    private String expr;
+public class MVELInterpretedReturnValueEvaluator extends 
AbstractReturnValueEvaluator {
 
     public MVELInterpretedReturnValueEvaluator(String expression) {
-        this.expr = expression;
+        super("mvel", expression);
+    }
+
+    @Override
+    public Object eval(Object event) {
+        return MVEL.eval(expression, event);
+    }
+
+    @Override
+    public Object eval(Function<String, Object> resolver) {
+        ImmutableDefaultFactory factory = new ImmutableDefaultFactory() {
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public boolean isResolveable(String name) {
+                return resolver.apply("#{" + name + "}") != null;
+            };
+
+            @Override
+            public VariableResolver getVariableResolver(String name) {
+                return new SimpleValueResolver(resolver.apply("#{" + name + 
"}"));
+            };
+        };
+        return MVEL.eval(expression, factory);
     }
 
-    public Object evaluate(KogitoProcessContext context) throws Exception {
-        Object value = MVEL.eval(this.expr, new ImmutableDefaultFactory() {
+    public Object evaluate(KogitoProcessContext context) {
+        Object value = MVEL.eval(this.expression(), new 
ImmutableDefaultFactory() {
             @Override
             public boolean isResolveable(String name) {
+                if (context instanceof KogitoProcessContextImpl) {
+                    return ((KogitoProcessContextImpl) 
context).isVariableResolvable(name);
+                }
                 return context.getVariable(name) != null;
             };
 
diff --git 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/MVELReturnValueEvaluator.java
 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/MVELReturnValueEvaluator.java
index 40fa4b912e..48950a5ce4 100755
--- 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/MVELReturnValueEvaluator.java
+++ 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/MVELReturnValueEvaluator.java
@@ -18,7 +18,6 @@
  */
 package org.jbpm.process.instance.impl;
 
-import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
@@ -36,51 +35,35 @@ import org.kie.api.definition.KiePackage;
 import org.kie.kogito.internal.process.runtime.KogitoProcessContext;
 import org.mvel2.integration.VariableResolverFactory;
 
-public class MVELReturnValueEvaluator
-        implements
-        ReturnValueEvaluator,
-        MVELCompileable,
-        Externalizable {
-    private static final long serialVersionUID = 510l;
+public class MVELReturnValueEvaluator extends AbstractReturnValueEvaluator 
implements MVELCompileable {
 
     private MVELCompilationUnit unit;
-    private String id;
 
-    private Serializable expr;
+    private Serializable compiledExpression;
 
-    public MVELReturnValueEvaluator() {
-    }
-
-    public MVELReturnValueEvaluator(final MVELCompilationUnit unit,
-            final String id) {
+    public MVELReturnValueEvaluator(MVELCompilationUnit unit) {
+        super("MVEL", unit.getExpression());
         this.unit = unit;
-        this.id = id;
     }
 
     public void readExternal(ObjectInput in) throws IOException,
             ClassNotFoundException {
-        id = in.readUTF();
         unit = (MVELCompilationUnit) in.readObject();
     }
 
     public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeUTF(id);
         out.writeObject(unit);
     }
 
     public void compile(MVELDialectRuntimeData data) {
-        expr = unit.getCompiledExpression(data);
+        compiledExpression = unit.getCompiledExpression(data);
     }
 
     public void compile(MVELDialectRuntimeData data, RuleImpl rule) {
-        expr = unit.getCompiledExpression(data);
-    }
-
-    public String getDialect() {
-        return this.id;
+        compiledExpression = unit.getCompiledExpression(data);
     }
 
-    public Object evaluate(KogitoProcessContext context) throws Exception {
+    public Object evaluate(KogitoProcessContext context) {
         int length = unit.getOtherIdentifiers().length;
         Object[] vars = new Object[length];
         if (unit.getOtherIdentifiers() != null) {
@@ -103,13 +86,11 @@ public class MVELReturnValueEvaluator
         // do we have any functions for this namespace?
         KiePackage pkg = 
context.getKieRuntime().getKieBase().getKiePackage("MAIN");
         if (pkg instanceof KnowledgePackageImpl) {
-            MVELDialectRuntimeData data = (MVELDialectRuntimeData) 
((KnowledgePackageImpl) pkg).getDialectRuntimeRegistry().getDialectData(id);
+            MVELDialectRuntimeData data = (MVELDialectRuntimeData) 
((KnowledgePackageImpl) 
pkg).getDialectRuntimeRegistry().getDialectData(dialect());
             factory.setNextFactory(data.getFunctionFactory());
         }
 
-        Object value = 
MVELProcessHelper.evaluator().executeExpression(this.expr,
-                null,
-                factory);
+        Object value = 
MVELProcessHelper.evaluator().executeExpression(compiledExpression, null, 
factory);
 
         if (!(value instanceof Boolean)) {
             throw new RuntimeException("Constraints must return boolean 
values: " +
@@ -120,12 +101,4 @@ public class MVELReturnValueEvaluator
 
     }
 
-    public Serializable getCompExpr() {
-        return expr;
-    }
-
-    public String toString() {
-        return this.unit.getExpression();
-    }
-
 }
diff --git 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/ReturnValueEvaluator.java
 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/ReturnValueEvaluator.java
index 351503fec9..0ee01b45b9 100755
--- 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/ReturnValueEvaluator.java
+++ 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/ReturnValueEvaluator.java
@@ -18,9 +18,36 @@
  */
 package org.jbpm.process.instance.impl;
 
+import java.util.function.Function;
+
 import org.kie.kogito.internal.process.runtime.KogitoProcessContext;
 
 public interface ReturnValueEvaluator {
 
-    Object evaluate(KogitoProcessContext processContext) throws Exception;
+    default Class<?> type() {
+        return Object.class;
+    }
+
+    default String dialect() {
+        return "functional";
+    }
+
+    default String expression() {
+        return "functional";
+    }
+
+    Object evaluate(KogitoProcessContext processContext);
+
+    default Object eval(Object event) {
+        return this.eval(name -> "value".equals(name) ? event : null);
+    }
+
+    default Object eval(Function<String, Object> resolver) {
+        return this.evaluate(new EmtpyKogitoProcessContext(resolver));
+    }
+
+    default String root() {
+        return null;
+    }
+
 }
diff --git 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/XPATHReturnValueEvaluator.java
 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/XPATHReturnValueEvaluator.java
index d40c9601a2..3c9fa372d6 100755
--- 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/XPATHReturnValueEvaluator.java
+++ 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/impl/XPATHReturnValueEvaluator.java
@@ -18,10 +18,6 @@
  */
 package org.jbpm.process.instance.impl;
 
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
@@ -40,97 +36,76 @@ import javax.xml.xpath.XPathVariableResolver;
 
 import org.kie.kogito.internal.process.runtime.KogitoProcessContext;
 
-public class XPATHReturnValueEvaluator
-        implements
-        ReturnValueEvaluator,
-        Externalizable {
-    private static final long serialVersionUID = 510l;
-
-    private String expression;
-    private String id;
+public class XPATHReturnValueEvaluator extends AbstractReturnValueEvaluator {
 
     public XPATHReturnValueEvaluator() {
+        super("XPath", "true()");
     }
 
-    public XPATHReturnValueEvaluator(final String expression,
-            final String id) {
-        this.expression = expression;
-        this.id = id;
-    }
-
-    public void readExternal(ObjectInput in) throws IOException,
-            ClassNotFoundException {
-        expression = (String) in.readObject();
-    }
-
-    public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject(expression);
-    }
-
-    public String getDialect() {
-        return this.id;
+    public XPATHReturnValueEvaluator(final String expression) {
+        super("XPath", expression);
     }
 
-    public Object evaluate(final KogitoProcessContext context) throws 
Exception {
-        XPathFactory factory = XPathFactory.newInstance();
-        XPath xpathEvaluator = factory.newXPath();
-        xpathEvaluator.setXPathFunctionResolver(
-                new XPathFunctionResolver() {
-                    public XPathFunction resolveFunction(QName functionName, 
int arity) {
-                        String localName = functionName.getLocalPart();
-                        if ("getVariable".equals(localName)) {
-                            return new GetVariableData();
-                        } else {
-                            throw new IllegalArgumentException("Unknown BPMN 
function: " + functionName);
+    public Object evaluate(final KogitoProcessContext context) {
+        try {
+            XPathFactory factory = XPathFactory.newInstance();
+            XPath xpathEvaluator = factory.newXPath();
+            xpathEvaluator.setXPathFunctionResolver(
+                    new XPathFunctionResolver() {
+                        public XPathFunction resolveFunction(QName 
functionName, int arity) {
+                            String localName = functionName.getLocalPart();
+                            if ("getVariable".equals(localName)) {
+                                return new GetVariableData();
+                            } else {
+                                throw new IllegalArgumentException("Unknown 
BPMN function: " + functionName);
+                            }
                         }
-                    }
 
-                    class GetVariableData implements XPathFunction {
-                        public Object evaluate(List args) throws 
XPathFunctionException {
-                            String varname = (String) args.get(0);
-                            return context.getVariable(varname);
+                        class GetVariableData implements XPathFunction {
+                            public Object evaluate(List args) throws 
XPathFunctionException {
+                                String varname = (String) args.get(0);
+                                return context.getVariable(varname);
+                            }
                         }
-                    }
-                });
-        xpathEvaluator.setXPathVariableResolver(new XPathVariableResolver() {
-
-            public Object resolveVariable(QName variableName) {
-                return context.getVariable(variableName.getLocalPart());
-            }
-        });
+                    });
+            xpathEvaluator.setXPathVariableResolver(new 
XPathVariableResolver() {
 
-        xpathEvaluator.setNamespaceContext(new NamespaceContext() {
-            private static final String DROOLS_NAMESPACE_URI = 
"http://www.jboss.org/drools";;
-            private String[] prefixes = { "drools", "bpmn2" };
+                public Object resolveVariable(QName variableName) {
+                    return context.getVariable(variableName.getLocalPart());
+                }
+            });
 
-            @Override
-            public Iterator getPrefixes(String namespaceURI) {
-                return Arrays.asList(prefixes).iterator();
-            }
+            xpathEvaluator.setNamespaceContext(new NamespaceContext() {
+                private static final String DROOLS_NAMESPACE_URI = 
"http://www.jboss.org/drools";;
+                private String[] prefixes = { "drools", "bpmn2" };
 
-            @Override
-            public String getPrefix(String namespaceURI) {
-                if (DROOLS_NAMESPACE_URI.equalsIgnoreCase(namespaceURI)) {
-                    return "bpmn2";
+                @Override
+                public Iterator getPrefixes(String namespaceURI) {
+                    return Arrays.asList(prefixes).iterator();
                 }
-                return null;
-            }
 
-            @Override
-            public String getNamespaceURI(String prefix) {
-                if ("bpmn2".equalsIgnoreCase(prefix)) {
-                    return DROOLS_NAMESPACE_URI;
+                @Override
+                public String getPrefix(String namespaceURI) {
+                    if (DROOLS_NAMESPACE_URI.equalsIgnoreCase(namespaceURI)) {
+                        return "bpmn2";
+                    }
+                    return null;
                 }
-                return null;
-            }
-        });
 
-        DocumentBuilder builder = 
DocumentBuilderFactory.newInstance().newDocumentBuilder();
-        return xpathEvaluator.evaluate(this.expression, builder.newDocument(), 
XPathConstants.BOOLEAN);
-    }
+                @Override
+                public String getNamespaceURI(String prefix) {
+                    if ("bpmn2".equalsIgnoreCase(prefix)) {
+                        return DROOLS_NAMESPACE_URI;
+                    }
+                    return null;
+                }
+            });
 
-    public String toString() {
-        return this.expression;
+            DocumentBuilder builder = 
DocumentBuilderFactory.newInstance().newDocumentBuilder();
+            return xpathEvaluator.evaluate(this.expression, 
builder.newDocument(), XPathConstants.BOOLEAN);
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
     }
 
 }
diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/Metadata.java 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/Metadata.java
index e7b8e0bac2..5b9f6a1428 100644
--- a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/Metadata.java
+++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/Metadata.java
@@ -26,6 +26,7 @@ public class Metadata {
     public static final String TRIGGER_REF = "TriggerRef";
     public static final String REF = "Ref";
     public static final String MESSAGE_TYPE = "MessageType";
+    public static final String MESSAGE_REF = "MessageRef";
     public static final String SIGNAL_TYPE = "SignalType";
     public static final String PRODUCE_MESSAGE = "ProduceMessage";
     public static final String CONSUME_MESSAGE = "ConsumeMessage";
diff --git 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcessFactory.java
 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcessFactory.java
index a0acf5d140..ccfdb3d993 100755
--- 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcessFactory.java
+++ 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/RuleFlowProcessFactory.java
@@ -38,6 +38,7 @@ import org.jbpm.process.core.event.EventTypeFilter;
 import org.jbpm.process.core.timer.Timer;
 import org.jbpm.process.core.validation.ProcessValidationError;
 import org.jbpm.process.instance.impl.Action;
+import org.jbpm.process.instance.impl.ReturnValueEvaluator;
 import org.jbpm.process.instance.impl.actions.CancelNodeInstanceAction;
 import org.jbpm.process.instance.impl.actions.SignalProcessInstanceAction;
 import org.jbpm.ruleflow.core.validation.RuleFlowProcessValidator;
@@ -243,6 +244,33 @@ public class RuleFlowProcessFactory extends 
RuleFlowNodeContainerFactory<RuleFlo
         return this;
     }
 
+    public RuleFlowProcessFactory newCorrelationMessage(String messageId, 
String messageName, String messageType) {
+        RuleFlowProcess process = getRuleFlowProcess();
+        process.getCorrelationManager().newMessage(messageId, messageName, 
messageType);
+        return this;
+    }
+
+    public RuleFlowProcessFactory newCorrelationKey(String correlationKey, 
String correlationName) {
+        RuleFlowProcess process = getRuleFlowProcess();
+        process.getCorrelationManager().newCorrelation(correlationKey, 
correlationName);
+        return this;
+    }
+
+    public RuleFlowProcessFactory newCorrelationProperty(String 
correlationKeyId, String messageId, String propertyId, ReturnValueEvaluator 
evaluator) {
+        RuleFlowProcess process = getRuleFlowProcess();
+        
process.getCorrelationManager().addMessagePropertyExpression(correlationKeyId, 
messageId, propertyId, evaluator);
+        return this;
+    }
+
+    public RuleFlowProcessFactory newCorrelationSubscription(String 
correlationKeyId, String propertyId, ReturnValueEvaluator evaluator) {
+        RuleFlowProcess process = getRuleFlowProcess();
+        if (!process.getCorrelationManager().isSubscribe(correlationKeyId)) {
+            process.getCorrelationManager().subscribeTo(correlationKeyId);
+        }
+        
process.getCorrelationManager().addProcessSubscriptionPropertyExpression(correlationKeyId,
 propertyId, evaluator);
+        return this;
+    }
+
     public RuleFlowProcessFactory link() {
         RuleFlowProcess process = getRuleFlowProcess();
         linkBoundaryEvents(process);
diff --git 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/AbstractEventNodeFactory.java
 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/AbstractEventNodeFactory.java
index d2dd920998..ead0080ae2 100644
--- 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/AbstractEventNodeFactory.java
+++ 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/AbstractEventNodeFactory.java
@@ -21,11 +21,14 @@ package org.jbpm.ruleflow.core.factory;
 import org.jbpm.process.core.event.EventFilter;
 import org.jbpm.process.core.event.EventTypeFilter;
 import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory;
+import org.jbpm.ruleflow.core.RuleFlowProcess;
 import org.jbpm.workflow.core.Node;
 import org.jbpm.workflow.core.NodeContainer;
 import org.jbpm.workflow.core.node.EventNode;
 import org.kie.api.definition.process.WorkflowElementIdentifier;
 
+import static org.jbpm.ruleflow.core.Metadata.MESSAGE_REF;
+
 public abstract class AbstractEventNodeFactory<T extends 
AbstractEventNodeFactory<T, P>, P extends RuleFlowNodeContainerFactory<P, ?>> 
extends ExtendedNodeFactory<T, P> {
 
     protected AbstractEventNodeFactory(P nodeContainerFactory, NodeContainer 
nodeContainer, Node node, WorkflowElementIdentifier id) {
@@ -54,6 +57,8 @@ public abstract class AbstractEventNodeFactory<T extends 
AbstractEventNodeFactor
     public T eventType(String eventType) {
         EventTypeFilter filter = new EventTypeFilter();
         filter.setType(eventType);
+        filter.setCorrelationManager(((RuleFlowProcess) 
getEventNode().getProcess()).getCorrelationManager());
+        filter.setMessageRef((String) 
getNode().getMetaData().get(MESSAGE_REF));
         return eventFilter(filter);
     }
 
diff --git 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/EventSubProcessNodeFactory.java
 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/EventSubProcessNodeFactory.java
index 1244b34993..46aad92e26 100644
--- 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/EventSubProcessNodeFactory.java
+++ 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/EventSubProcessNodeFactory.java
@@ -20,10 +20,13 @@ package org.jbpm.ruleflow.core.factory;
 
 import org.jbpm.process.core.event.EventTypeFilter;
 import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory;
+import org.jbpm.ruleflow.core.RuleFlowProcess;
 import org.jbpm.workflow.core.NodeContainer;
 import org.jbpm.workflow.core.node.EventSubProcessNode;
 import org.kie.api.definition.process.WorkflowElementIdentifier;
 
+import static org.jbpm.ruleflow.core.Metadata.MESSAGE_REF;
+
 public class EventSubProcessNodeFactory<T extends 
RuleFlowNodeContainerFactory<T, ?>> extends 
AbstractCompositeNodeFactory<EventSubProcessNodeFactory<T>, T> {
 
     public static final String METHOD_KEEP_ACTIVE = "keepActive";
@@ -41,6 +44,8 @@ public class EventSubProcessNodeFactory<T extends 
RuleFlowNodeContainerFactory<T
     public EventSubProcessNodeFactory<T> event(String event) {
         EventTypeFilter filter = new EventTypeFilter();
         filter.setType(event);
+        filter.setCorrelationManager(((RuleFlowProcess) 
getCompositeNode().getProcess()).getCorrelationManager());
+        filter.setMessageRef((String) 
getNode().getMetaData().get(MESSAGE_REF));
         ((EventSubProcessNode) getCompositeNode()).addEvent(filter);
         return this;
     }
diff --git 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/StartNodeFactory.java
 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/StartNodeFactory.java
index 27954c9d1f..3aa38c4b33 100755
--- 
a/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/StartNodeFactory.java
+++ 
b/jbpm/jbpm-flow/src/main/java/org/jbpm/ruleflow/core/factory/StartNodeFactory.java
@@ -23,12 +23,15 @@ import java.util.List;
 import org.jbpm.process.core.event.EventTypeFilter;
 import org.jbpm.process.core.timer.Timer;
 import org.jbpm.ruleflow.core.RuleFlowNodeContainerFactory;
+import org.jbpm.ruleflow.core.RuleFlowProcess;
 import org.jbpm.workflow.core.NodeContainer;
 import org.jbpm.workflow.core.impl.DataAssociation;
 import org.jbpm.workflow.core.node.EventTrigger;
 import org.jbpm.workflow.core.node.StartNode;
 import org.kie.api.definition.process.WorkflowElementIdentifier;
 
+import static org.jbpm.ruleflow.core.Metadata.MESSAGE_REF;
+
 public class StartNodeFactory<T extends RuleFlowNodeContainerFactory<T, ?>> 
extends NodeFactory<StartNodeFactory<T>, T> {
 
     public static final String METHOD_INTERRUPTING = "interrupting";
@@ -51,7 +54,9 @@ public class StartNodeFactory<T extends 
RuleFlowNodeContainerFactory<T, ?>> exte
     public StartNodeFactory<T> trigger(String triggerEventType, 
List<DataAssociation> dataAssociations) {
         EventTrigger trigger = new EventTrigger();
         EventTypeFilter eventFilter = new EventTypeFilter();
+        eventFilter.setCorrelationManager(((RuleFlowProcess) 
getStartNode().getProcess()).getCorrelationManager());
         eventFilter.setType(triggerEventType);
+        eventFilter.setMessageRef((String) 
getNode().getMetaData().get(MESSAGE_REF));
         trigger.addEventFilter(eventFilter);
         dataAssociations.forEach(trigger::addInAssociation);
         getStartNode().addTrigger(trigger);
@@ -65,6 +70,8 @@ public class StartNodeFactory<T extends 
RuleFlowNodeContainerFactory<T, ?>> exte
     public StartNodeFactory<T> trigger(String triggerEventType, String source, 
String target) {
         EventTrigger trigger = new EventTrigger();
         EventTypeFilter eventFilter = new EventTypeFilter();
+        eventFilter.setCorrelationManager(((RuleFlowProcess) 
getStartNode().getProcess()).getCorrelationManager());
+        eventFilter.setMessageRef((String) 
getNode().getMetaData().get(MESSAGE_REF));
         eventFilter.setType(triggerEventType);
         trigger.addEventFilter(eventFilter);
         if (source != null) {
diff --git 
a/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/AbstractProcess.java 
b/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/AbstractProcess.java
index 355431254c..3881821765 100644
--- 
a/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/AbstractProcess.java
+++ 
b/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/AbstractProcess.java
@@ -170,6 +170,7 @@ public abstract class AbstractProcess<T extends Model> 
implements Process<T>, Pr
 
     @Override
     public <S> void send(Signal<S> signal) {
+        getProcessRuntime().signalEvent(signal.channel(), signal.payload());
         try (Stream<ProcessInstance<T>> stream = instances.stream()) {
             stream.forEach(pi -> pi.send(signal));
         }
diff --git 
a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/CollaborationTest.java 
b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/CollaborationTest.java
index b924be42f1..fb88b9b55b 100644
--- a/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/CollaborationTest.java
+++ b/jbpm/jbpm-tests/src/test/java/org/jbpm/bpmn2/CollaborationTest.java
@@ -18,11 +18,23 @@
  */
 package org.jbpm.bpmn2;
 
-import java.util.Collections;
+import java.util.ArrayList;
+import java.util.List;
 
+import org.jbpm.bpmn2.collaboration.CollaborationBoundaryMessageModel;
+import org.jbpm.bpmn2.collaboration.CollaborationBoundaryMessageProcess;
+import org.jbpm.bpmn2.collaboration.CollaborationIntermediateMessageModel;
+import org.jbpm.bpmn2.collaboration.CollaborationIntermediateMessageProcess;
+import org.jbpm.bpmn2.collaboration.CollaborationStartMessageModel;
+import org.jbpm.bpmn2.collaboration.CollaborationStartMessageProcess;
 import org.jbpm.process.instance.impl.demo.DoNothingWorkItemHandler;
+import org.jbpm.test.utils.ProcessTestHelper;
 import org.junit.jupiter.api.Test;
-import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
+import org.kie.api.event.process.ProcessStartedEvent;
+import org.kie.api.runtime.process.ProcessInstance;
+import org.kie.kogito.Application;
+import org.kie.kogito.internal.process.event.DefaultKogitoProcessEventListener;
+import org.kie.kogito.process.impl.Sig;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@@ -31,49 +43,91 @@ public class CollaborationTest extends JbpmBpmn2TestCase {
 
     @Test
     public void testBoundaryMessageCollaboration() throws Exception {
-        kruntime = 
createKogitoProcessRuntime("org/jbpm/bpmn2/collaboration/BPMN2-CollaborationBoundaryMessage.bpmn2");
-        kruntime.getKogitoWorkItemManager().registerWorkItemHandler("Human 
Task", new DoNothingWorkItemHandler());
-        KogitoProcessInstance pid = 
kruntime.startProcess("CollaborationBoundaryMessage", 
Collections.singletonMap("MessageId", "2"));
-        kruntime.signalEvent("Message-collaboration", new Message("1", 
"example"), pid.getStringId());
-        assertProcessInstanceActive(pid);
-        kruntime.signalEvent("Message-collaboration", new Message("2", 
"example"), pid.getStringId());
-        assertProcessInstanceCompleted(pid);
+        Application application = ProcessTestHelper.newApplication();
+        ProcessTestHelper.registerHandler(application, "Human Task", new 
DoNothingWorkItemHandler());
+        org.kie.kogito.process.Process<CollaborationBoundaryMessageModel> 
processDefinition = CollaborationBoundaryMessageProcess.newProcess(application);
+        CollaborationBoundaryMessageModel variables = 
processDefinition.createModel();
+        variables.setMessageId("2");
+        
org.kie.kogito.process.ProcessInstance<CollaborationBoundaryMessageModel> 
processInstance = processDefinition.createInstance(variables);
+        processInstance.start();
+        processInstance.send(Sig.of("Message-collaboration", new Message("1", 
"example")));
+
+        
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+        processInstance.send(Sig.of("Message-collaboration", new Message("2", 
"example")));
+        
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
+
     }
 
     @Test
     public void testStartMessageCollaboration() throws Exception {
-        kruntime = 
createKogitoProcessRuntime("org/jbpm/bpmn2/collaboration/BPMN2-CollaborationStartMessage.bpmn2");
-        kruntime.signalEvent("Message-collaboration", new Message("1", 
"example"));
-        
assertThat(getNumberOfProcessInstances("CollaborationStartMessage")).isEqualTo(1);
+        final List<String> processInstanceId = new ArrayList<>();
+        Application application = ProcessTestHelper.newApplication();
+        ProcessTestHelper.registerProcessEventListener(application, new 
DefaultKogitoProcessEventListener() {
+            @Override
+            public void beforeProcessStarted(ProcessStartedEvent event) {
+                processInstanceId.add(event.getProcessInstance().getId());
+            }
+        });
+        ProcessTestHelper.registerHandler(application, "Human Task", new 
DoNothingWorkItemHandler());
+        org.kie.kogito.process.Process<CollaborationStartMessageModel> 
processDefinition = CollaborationStartMessageProcess.newProcess(application);
+
+        processDefinition.send(Sig.of("collaboration", new Message("1", 
"example")));
+
+        assertThat(processInstanceId).hasSize(1);
+
     }
 
     @Test
     public void testStartMessageCollaborationNoMatch() throws Exception {
-        kruntime = 
createKogitoProcessRuntime("org/jbpm/bpmn2/collaboration/BPMN2-CollaborationStartMessage.bpmn2");
+        final List<String> processInstanceId = new ArrayList<>();
+        Application application = ProcessTestHelper.newApplication();
+        ProcessTestHelper.registerProcessEventListener(application, new 
DefaultKogitoProcessEventListener() {
+            @Override
+            public void beforeProcessStarted(ProcessStartedEvent event) {
+                processInstanceId.add(event.getProcessInstance().getId());
+            }
+        });
+        ProcessTestHelper.registerHandler(application, "Human Task", new 
DoNothingWorkItemHandler());
+        org.kie.kogito.process.Process<CollaborationStartMessageModel> 
processDefinition = CollaborationStartMessageProcess.newProcess(application);
+
+        processDefinition.send(Sig.of("Message-collaboration", new 
Message("2", "example")));
+
+        assertThat(processInstanceId).hasSize(0);
 
-        kruntime.signalEvent("Message-collaboration", new Message("2", 
"example"));
-        
assertThat(getNumberOfProcessInstances("CollaborationStartMessage")).isZero();
     }
 
     @Test
     public void testIntermediateMessageCollaboration() throws Exception {
-        kruntime = 
createKogitoProcessRuntime("org/jbpm/bpmn2/collaboration/BPMN2-CollaborationIntermediateMessage.bpmn2");
-        KogitoProcessInstance pid = 
kruntime.startProcess("CollaborationIntermediateMessage", 
Collections.singletonMap("MessageId", "2"));
-        kruntime.signalEvent("Message-collaboration", new Message("1", 
"example"), pid.getStringId());
-        assertProcessInstanceActive(pid);
-        kruntime.signalEvent("Message-collaboration", new Message("2", 
"example"), pid.getStringId());
-        assertProcessInstanceCompleted(pid);
+        Application application = ProcessTestHelper.newApplication();
+        ProcessTestHelper.registerHandler(application, "Human Task", new 
DoNothingWorkItemHandler());
+        org.kie.kogito.process.Process<CollaborationIntermediateMessageModel> 
processDefinition = 
CollaborationIntermediateMessageProcess.newProcess(application);
+        CollaborationIntermediateMessageModel variables = 
processDefinition.createModel();
+        variables.setMessageId("2");
+        
org.kie.kogito.process.ProcessInstance<CollaborationIntermediateMessageModel> 
processInstance = processDefinition.createInstance(variables);
+        processInstance.start();
+        processInstance.send(Sig.of("Message-collaboration", new Message("1", 
"example")));
+
+        
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+        processInstance.send(Sig.of("Message-collaboration", new Message("2", 
"example")));
+        
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
+
     }
 
     @Test
     public void testInvalidIntermediateMessageCollaboration() throws Exception 
{
-        kruntime = 
createKogitoProcessRuntime("org/jbpm/bpmn2/collaboration/BPMN2-CollaborationIntermediateMessage.bpmn2");
+        Application application = ProcessTestHelper.newApplication();
+        ProcessTestHelper.registerHandler(application, "Human Task", new 
DoNothingWorkItemHandler());
+        org.kie.kogito.process.Process<CollaborationIntermediateMessageModel> 
processDefinition = 
CollaborationIntermediateMessageProcess.newProcess(application);
+        CollaborationIntermediateMessageModel variables = 
processDefinition.createModel();
+        variables.setMessageId("2");
+        
org.kie.kogito.process.ProcessInstance<CollaborationIntermediateMessageModel> 
processInstance = processDefinition.createInstance(variables);
+        processInstance.start();
 
-        KogitoProcessInstance pid = 
kruntime.startProcess("CollaborationIntermediateMessage", 
Collections.singletonMap("MessageId", "2"));
         
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
-            kruntime.signalEvent("Message-collaboration", new Message(null, 
"example"), pid.getStringId());
+            processInstance.send(Sig.of("Message-collaboration", new 
Message(null, "example")));
         });
-
-        assertProcessInstanceActive(pid);
+        
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_ACTIVE);
+        processInstance.send(Sig.of("Message-collaboration", new Message("2", 
"example")));
+        
assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
     }
 }
diff --git 
a/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-XpathExpression.bpmn2
 
b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-XpathExpression.bpmn2
new file mode 100755
index 0000000000..93d72711cf
--- /dev/null
+++ 
b/jbpm/jbpm-tools/jbpm-tools-maven-plugin/src/test/resources/unit/project/src/main/bpmn/BPMN2-XpathExpression.bpmn2
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?> 
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~   http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<definitions id="Definition"
+             targetNamespace=""
+             typeLanguage="http://www.java.com/javaTypes";
+             expressionLanguage="http://www.mvel.org/2.0";
+             xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL";
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+             xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL 
BPMN20.xsd"
+             xmlns:g="http://www.jboss.org/drools/flow/gpd";
+             xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI";
+             xmlns:dc="http://www.omg.org/spec/DD/20100524/DC";
+             xmlns:di="http://www.omg.org/spec/DD/20100524/DI";
+             xmlns:tns="http://www.jboss.org/drools";>
+
+  <itemDefinition id="_instanceMetadataItem" 
structureRef="org.w3c.dom.Document" />
+
+  <process processType="Private" isExecutable="true" id="XPathProcess" 
name="XPathProcess" tns:packageName="org.jbpm.bpmn2.activity">
+
+    <!-- process variables -->
+    <property id="instanceMetadata" itemSubjectRef="_instanceMetadataItem"/>
+
+    <!-- nodes -->
+    <startEvent id="_1" name="" />
+    <exclusiveGateway id="_2" name="" gatewayDirection="Diverging" />
+    <scriptTask id="_3" name="Task1" >
+      <script>System.out.println("Task 1");</script>
+    </scriptTask>
+    <scriptTask id="_4" name="Task2" >
+      <script>System.out.println("Task 2");</script>
+    </scriptTask>
+    <exclusiveGateway id="_5" name="" gatewayDirection="Converging" />
+    <endEvent id="_6" name="" />
+
+    <!-- connections -->
+    <sequenceFlow id="_1-_2" sourceRef="_1" targetRef="_2" />
+    <sequenceFlow id="_2-_3" sourceRef="_2" targetRef="_3" >
+      <conditionExpression xsi:type="tFormalExpression" 
language="http://www.w3.org/1999/XPath"; 
>count($instanceMetadata/instanceMetadata/user[@approved='true']) = 
1</conditionExpression>
+    </sequenceFlow>
+    <sequenceFlow id="_2-_4" sourceRef="_2" targetRef="_4" >
+      <conditionExpression xsi:type="tFormalExpression" 
language="http://www.w3.org/1999/XPath"; 
>count($instanceMetadata/instanceMetadata/user[@approved='false']) = 
1</conditionExpression>
+    </sequenceFlow>
+    <sequenceFlow id="_3-_5" sourceRef="_3" targetRef="_5" />
+    <sequenceFlow id="_4-_5" sourceRef="_4" targetRef="_5" />
+    <sequenceFlow id="_5-_6" sourceRef="_5" targetRef="_6" />
+
+  </process>
+
+  <bpmndi:BPMNDiagram>
+    <bpmndi:BPMNPlane bpmnElement="XPathProcess" >
+      <bpmndi:BPMNShape bpmnElement="_1" >
+        <dc:Bounds x="16" y="56" width="48" height="48" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape bpmnElement="_2" >
+        <dc:Bounds x="96" y="56" width="48" height="48" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape bpmnElement="_3" >
+        <dc:Bounds x="176" y="16" width="80" height="48" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape bpmnElement="_4" >
+        <dc:Bounds x="176" y="96" width="80" height="48" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape bpmnElement="_5" >
+        <dc:Bounds x="288" y="56" width="48" height="48" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNShape bpmnElement="_6" >
+        <dc:Bounds x="368" y="56" width="48" height="48" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge bpmnElement="_1-_2" >
+        <di:waypoint x="40" y="80" />
+        <di:waypoint x="120" y="80" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge bpmnElement="_2-_3" >
+        <di:waypoint x="120" y="80" />
+        <di:waypoint x="216" y="40" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge bpmnElement="_2-_4" >
+        <di:waypoint x="120" y="80" />
+        <di:waypoint x="216" y="120" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge bpmnElement="_3-_5" >
+        <di:waypoint x="216" y="40" />
+        <di:waypoint x="312" y="80" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge bpmnElement="_4-_5" >
+        <di:waypoint x="216" y="120" />
+        <di:waypoint x="312" y="80" />
+      </bpmndi:BPMNEdge>
+      <bpmndi:BPMNEdge bpmnElement="_5-_6" >
+        <di:waypoint x="312" y="80" />
+        <di:waypoint x="392" y="80" />
+      </bpmndi:BPMNEdge>
+    </bpmndi:BPMNPlane>
+  </bpmndi:BPMNDiagram>
+
+</definitions>
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to