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 0c5b65ff83 [incubator-kie-issues-1111] Add capability to extends for 
code generation (#3507)
0c5b65ff83 is described below

commit 0c5b65ff839df8fe209b2d90d8ab90e99cdf0f5b
Author: Enrique <[email protected]>
AuthorDate: Mon May 20 12:21:02 2024 +0200

    [incubator-kie-issues-1111] Add capability to extends for code generation 
(#3507)
    
    * [incubator-kie-issues-1111] Add capability to extends for code generation
    
    * class loader corrections
---
 .../canonical/AbstractCompositeNodeVisitor.java    | 11 ++--
 .../canonical/CompositeContextNodeVisitor.java     |  7 +--
 .../compiler/canonical/DynamicNodeVisitor.java     |  7 +--
 .../canonical/EventSubProcessNodeVisitor.java      |  7 +--
 .../compiler/canonical/ForEachNodeVisitor.java     |  6 +-
 .../compiler/canonical/HumanTaskNodeVisitor.java   |  4 +-
 .../jbpm/compiler/canonical/ProcessVisitor.java    | 66 +++++-----------------
 .../jbpm/compiler/canonical/StateNodeVisitor.java  |  6 +-
 .../canonical/node/ActionNodeVisitorBuilder.java   | 38 +++++++++++++
 .../node/BoundaryEventNodeVisitorBuilder.java      | 38 +++++++++++++
 .../node/CatchLinkNodeVisitorBuilder.java          | 38 +++++++++++++
 .../node/CompositeContextNodeVisitorBuilder.java   | 38 +++++++++++++
 .../canonical/node/DynamicNodeVisitorBuilder.java  | 38 +++++++++++++
 .../canonical/node/EndNodeVisitorBuilder.java      | 38 +++++++++++++
 .../canonical/node/EventNodeVisitorBuilder.java    | 38 +++++++++++++
 .../node/EventSubProcessNodeVisitorBuilder.java    | 38 +++++++++++++
 .../canonical/node/FaultNodeVisitorBuilder.java    | 38 +++++++++++++
 .../canonical/node/ForEachNodeVisitorBuilder.java  | 38 +++++++++++++
 .../node/HumanTaskNodeVisitorBuilder.java          | 38 +++++++++++++
 .../canonical/node/JoinNodeVisitorBuilder.java     | 38 +++++++++++++
 .../node/MilestoneNodeVisitorBuilder.java          | 38 +++++++++++++
 .../canonical/node/NodeVisitorBuilder.java         | 28 +++++++++
 .../canonical/node/NodeVisitorBuilderService.java  | 51 +++++++++++++++++
 .../canonical/node/RuleSetNodeVisitorBuilder.java  | 38 +++++++++++++
 .../canonical/node/SplitNodeVisitorBuilder.java    | 38 +++++++++++++
 .../canonical/node/StartNodeVisitorBuilder.java    | 38 +++++++++++++
 .../canonical/node/StateNodeVisitorBuilder.java    | 38 +++++++++++++
 .../node/SubProcessNodeVisitorBuilder.java         | 38 +++++++++++++
 .../node/ThrowLinkNodeVisitorBuilder.java          | 38 +++++++++++++
 .../canonical/node/TimerNodeVisitorBuilder.java    | 38 +++++++++++++
 .../canonical/node/WorkItemNodeVisitorBuilder.java | 38 +++++++++++++
 ...jbpm.compiler.canonical.node.NodeVisitorBuilder | 21 +++++++
 32 files changed, 934 insertions(+), 78 deletions(-)

diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractCompositeNodeVisitor.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractCompositeNodeVisitor.java
index 96b9d205f5..b9143a9d76 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractCompositeNodeVisitor.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/AbstractCompositeNodeVisitor.java
@@ -18,8 +18,7 @@
  */
 package org.jbpm.compiler.canonical;
 
-import java.util.Map;
-
+import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService;
 import org.jbpm.process.core.context.variable.VariableScope;
 import org.jbpm.workflow.core.node.CompositeContextNode;
 import org.kie.api.definition.process.Node;
@@ -28,15 +27,15 @@ import com.github.javaparser.ast.stmt.BlockStmt;
 
 public abstract class AbstractCompositeNodeVisitor<T extends 
CompositeContextNode> extends AbstractNodeVisitor<T> {
 
-    protected Map<Class<?>, AbstractNodeVisitor<? extends Node>> nodesVisitors;
+    protected NodeVisitorBuilderService nodevisitorService;
 
-    public AbstractCompositeNodeVisitor(Map<Class<?>, AbstractNodeVisitor<? 
extends Node>> nodesVisitors) {
-        this.nodesVisitors = nodesVisitors;
+    public AbstractCompositeNodeVisitor(NodeVisitorBuilderService 
nodevisitorService) {
+        this.nodevisitorService = nodevisitorService;
     }
 
     protected <U extends Node> void visitNodes(String factoryField, U[] nodes, 
BlockStmt body, VariableScope variableScope, ProcessMetaData metadata) {
         for (U node : nodes) {
-            AbstractNodeVisitor<U> visitor = (AbstractNodeVisitor<U>) 
nodesVisitors.get(node.getClass());
+            AbstractNodeVisitor<U> visitor = (AbstractNodeVisitor<U>) 
nodevisitorService.findNodeVisitor(node.getClass());
             if (visitor == null) {
                 continue;
             }
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/CompositeContextNodeVisitor.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/CompositeContextNodeVisitor.java
index 12d7946aef..7bb9c149d8 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/CompositeContextNodeVisitor.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/CompositeContextNodeVisitor.java
@@ -19,13 +19,12 @@
 package org.jbpm.compiler.canonical;
 
 import java.util.HashSet;
-import java.util.Map;
 import java.util.stream.Stream;
 
+import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService;
 import org.jbpm.process.core.context.variable.VariableScope;
 import org.jbpm.ruleflow.core.factory.CompositeContextNodeFactory;
 import org.jbpm.workflow.core.node.CompositeContextNode;
-import org.kie.api.definition.process.Node;
 
 import com.github.javaparser.ast.expr.BooleanLiteralExpr;
 import com.github.javaparser.ast.expr.MethodCallExpr;
@@ -34,8 +33,8 @@ import com.github.javaparser.ast.stmt.BlockStmt;
 
 public class CompositeContextNodeVisitor<T extends CompositeContextNode> 
extends AbstractCompositeNodeVisitor<T> {
 
-    public CompositeContextNodeVisitor(Map<Class<?>, AbstractNodeVisitor<? 
extends Node>> nodesVisitors) {
-        super(nodesVisitors);
+    public CompositeContextNodeVisitor(NodeVisitorBuilderService 
nodeVisitorService) {
+        super(nodeVisitorService);
     }
 
     @Override
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/DynamicNodeVisitor.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/DynamicNodeVisitor.java
index 26c802d494..6535aa5466 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/DynamicNodeVisitor.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/DynamicNodeVisitor.java
@@ -20,13 +20,12 @@ package org.jbpm.compiler.canonical;
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Map;
 import java.util.stream.Stream;
 
+import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService;
 import org.jbpm.process.core.context.variable.VariableScope;
 import org.jbpm.ruleflow.core.factory.DynamicNodeFactory;
 import org.jbpm.workflow.core.node.DynamicNode;
-import org.kie.api.definition.process.Node;
 
 import com.github.javaparser.ast.expr.MethodCallExpr;
 
@@ -36,8 +35,8 @@ import static 
org.jbpm.ruleflow.core.factory.DynamicNodeFactory.METHOD_LANGUAGE;
 
 public class DynamicNodeVisitor extends 
CompositeContextNodeVisitor<DynamicNode> {
 
-    public DynamicNodeVisitor(Map<Class<?>, AbstractNodeVisitor<? extends 
Node>> nodesVisitors) {
-        super(nodesVisitors);
+    public DynamicNodeVisitor(NodeVisitorBuilderService nodeVisitorService) {
+        super(nodeVisitorService);
     }
 
     @Override
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventSubProcessNodeVisitor.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventSubProcessNodeVisitor.java
index 815f637039..ef9c441e44 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventSubProcessNodeVisitor.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/EventSubProcessNodeVisitor.java
@@ -20,13 +20,12 @@ package org.jbpm.compiler.canonical;
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Map;
 import java.util.stream.Stream;
 
+import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService;
 import org.jbpm.process.core.context.variable.VariableScope;
 import org.jbpm.ruleflow.core.factory.EventSubProcessNodeFactory;
 import org.jbpm.workflow.core.node.EventSubProcessNode;
-import org.kie.api.definition.process.Node;
 
 import com.github.javaparser.ast.expr.BooleanLiteralExpr;
 import com.github.javaparser.ast.expr.MethodCallExpr;
@@ -37,8 +36,8 @@ import static 
org.jbpm.ruleflow.core.factory.EventSubProcessNodeFactory.METHOD_K
 
 public class EventSubProcessNodeVisitor extends 
CompositeContextNodeVisitor<EventSubProcessNode> {
 
-    public EventSubProcessNodeVisitor(Map<Class<?>, AbstractNodeVisitor<? 
extends Node>> nodesVisitors) {
-        super(nodesVisitors);
+    public EventSubProcessNodeVisitor(NodeVisitorBuilderService 
nodeVisitorService) {
+        super(nodeVisitorService);
     }
 
     @Override
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ForEachNodeVisitor.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ForEachNodeVisitor.java
index bb9bf76a41..45e4ffdaa6 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ForEachNodeVisitor.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/ForEachNodeVisitor.java
@@ -21,8 +21,8 @@ package org.jbpm.compiler.canonical;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-import java.util.Map;
 
+import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService;
 import org.jbpm.process.core.context.variable.VariableScope;
 import org.jbpm.ruleflow.core.factory.ForEachNodeFactory;
 import org.jbpm.workflow.core.Node;
@@ -45,8 +45,8 @@ import static 
org.jbpm.ruleflow.core.factory.ForEachNodeFactory.METHOD_SEQUENTIA
 
 public class ForEachNodeVisitor extends 
AbstractCompositeNodeVisitor<ForEachNode> {
 
-    public ForEachNodeVisitor(Map<Class<?>, AbstractNodeVisitor<? extends 
org.kie.api.definition.process.Node>> nodesVisitors) {
-        super(nodesVisitors);
+    public ForEachNodeVisitor(NodeVisitorBuilderService nodeVisitorService) {
+        super(nodeVisitorService);
     }
 
     @Override
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/HumanTaskNodeVisitor.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/HumanTaskNodeVisitor.java
index 2c2849dc00..474c55cc5e 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/HumanTaskNodeVisitor.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/HumanTaskNodeVisitor.java
@@ -27,8 +27,8 @@ import com.github.javaparser.ast.stmt.BlockStmt;
 
 public class HumanTaskNodeVisitor extends WorkItemNodeVisitor<HumanTaskNode> {
 
-    public HumanTaskNodeVisitor() {
-        super(null);
+    public HumanTaskNodeVisitor(ClassLoader classLoader) {
+        super(classLoader);
     }
 
     @Override
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 355ab77aa4..223f9a8428 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
@@ -19,7 +19,6 @@
 package org.jbpm.compiler.canonical;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -28,6 +27,7 @@ import java.util.Set;
 import java.util.stream.Stream;
 
 import org.jbpm.compiler.canonical.descriptors.ExpressionUtils;
+import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService;
 import org.jbpm.process.core.Context;
 import org.jbpm.process.core.ContextContainer;
 import org.jbpm.process.core.Work;
@@ -40,27 +40,7 @@ import org.jbpm.ruleflow.core.RuleFlowProcessFactory;
 import org.jbpm.workflow.core.Node;
 import org.jbpm.workflow.core.NodeContainer;
 import org.jbpm.workflow.core.impl.ConnectionImpl;
-import org.jbpm.workflow.core.node.ActionNode;
-import org.jbpm.workflow.core.node.BoundaryEventNode;
-import org.jbpm.workflow.core.node.CatchLinkNode;
-import org.jbpm.workflow.core.node.CompositeContextNode;
 import org.jbpm.workflow.core.node.CompositeNode;
-import org.jbpm.workflow.core.node.DynamicNode;
-import org.jbpm.workflow.core.node.EndNode;
-import org.jbpm.workflow.core.node.EventNode;
-import org.jbpm.workflow.core.node.EventSubProcessNode;
-import org.jbpm.workflow.core.node.FaultNode;
-import org.jbpm.workflow.core.node.ForEachNode;
-import org.jbpm.workflow.core.node.HumanTaskNode;
-import org.jbpm.workflow.core.node.Join;
-import org.jbpm.workflow.core.node.MilestoneNode;
-import org.jbpm.workflow.core.node.RuleSetNode;
-import org.jbpm.workflow.core.node.Split;
-import org.jbpm.workflow.core.node.StartNode;
-import org.jbpm.workflow.core.node.StateNode;
-import org.jbpm.workflow.core.node.SubProcessNode;
-import org.jbpm.workflow.core.node.ThrowLinkNode;
-import org.jbpm.workflow.core.node.TimerNode;
 import org.jbpm.workflow.core.node.WorkItemNode;
 import org.kie.api.definition.process.Connection;
 import org.kie.api.definition.process.Process;
@@ -98,30 +78,10 @@ public class ProcessVisitor extends AbstractVisitor {
 
     public static final String DEFAULT_VERSION = "1.0";
 
-    private Map<Class<?>, AbstractNodeVisitor<? extends 
org.kie.api.definition.process.Node>> nodesVisitors = new HashMap<>();
+    private NodeVisitorBuilderService nodeVisitorService;
 
     public ProcessVisitor(ClassLoader contextClassLoader) {
-        this.nodesVisitors.put(StartNode.class, new StartNodeVisitor());
-        this.nodesVisitors.put(ActionNode.class, new ActionNodeVisitor());
-        this.nodesVisitors.put(EndNode.class, new EndNodeVisitor());
-        this.nodesVisitors.put(HumanTaskNode.class, new 
HumanTaskNodeVisitor());
-        this.nodesVisitors.put(WorkItemNode.class, new 
WorkItemNodeVisitor<>(contextClassLoader));
-        this.nodesVisitors.put(SubProcessNode.class, new 
LambdaSubProcessNodeVisitor());
-        this.nodesVisitors.put(Split.class, new SplitNodeVisitor());
-        this.nodesVisitors.put(Join.class, new JoinNodeVisitor());
-        this.nodesVisitors.put(FaultNode.class, new FaultNodeVisitor());
-        this.nodesVisitors.put(RuleSetNode.class, new 
RuleSetNodeVisitor(contextClassLoader));
-        this.nodesVisitors.put(BoundaryEventNode.class, new 
BoundaryEventNodeVisitor());
-        this.nodesVisitors.put(EventNode.class, new EventNodeVisitor());
-        this.nodesVisitors.put(ForEachNode.class, new 
ForEachNodeVisitor(nodesVisitors));
-        this.nodesVisitors.put(CompositeContextNode.class, new 
CompositeContextNodeVisitor<>(nodesVisitors));
-        this.nodesVisitors.put(EventSubProcessNode.class, new 
EventSubProcessNodeVisitor(nodesVisitors));
-        this.nodesVisitors.put(TimerNode.class, new TimerNodeVisitor());
-        this.nodesVisitors.put(MilestoneNode.class, new 
MilestoneNodeVisitor());
-        this.nodesVisitors.put(DynamicNode.class, new 
DynamicNodeVisitor(nodesVisitors));
-        this.nodesVisitors.put(StateNode.class, new 
StateNodeVisitor(nodesVisitors));
-        this.nodesVisitors.put(CatchLinkNode.class, new 
CatchLinkNodeVisitor());
-        this.nodesVisitors.put(ThrowLinkNode.class, new 
ThrowLinkNodeVisitor());
+        nodeVisitorService = new NodeVisitorBuilderService(contextClassLoader);
     }
 
     public void visitProcess(WorkflowProcess process, MethodDeclaration 
processMethod, ProcessMetaData metadata) {
@@ -221,7 +181,8 @@ public class ProcessVisitor extends AbstractVisitor {
 
     private <U extends org.kie.api.definition.process.Node> void 
visitNodes(List<U> nodes, BlockStmt body, VariableScope variableScope, 
ProcessMetaData metadata) {
         for (U node : nodes) {
-            AbstractNodeVisitor<U> visitor = (AbstractNodeVisitor<U>) 
nodesVisitors.get(node.getClass());
+            @SuppressWarnings("unchecked")
+            AbstractNodeVisitor<U> visitor = (AbstractNodeVisitor<U>) 
this.nodeVisitorService.findNodeVisitor(node.getClass());
             if (visitor == null) {
                 throw new IllegalStateException("No visitor found for node " + 
node.getClass().getName());
             }
@@ -229,6 +190,15 @@ public class ProcessVisitor extends AbstractVisitor {
         }
     }
 
+    @SuppressWarnings("unchecked")
+    private String getFieldName(ContextContainer contextContainer) {
+        AbstractNodeVisitor visitor = null;
+        if (contextContainer instanceof CompositeNode) {
+            visitor = 
this.nodeVisitorService.findNodeVisitor(contextContainer.getClass());
+        }
+        return visitor != null ? visitor.getNodeId(((Node) contextContainer)) 
: FACTORY_FIELD_NAME;
+    }
+
     private void visitConnections(org.kie.api.definition.process.Node[] nodes, 
BlockStmt body) {
 
         List<Connection> connections = new ArrayList<>();
@@ -302,14 +272,6 @@ public class ProcessVisitor extends AbstractVisitor {
         }
     }
 
-    private String getFieldName(ContextContainer contextContainer) {
-        AbstractNodeVisitor visitor = null;
-        if (contextContainer instanceof CompositeNode) {
-            visitor = this.nodesVisitors.get(contextContainer.getClass());
-        }
-        return visitor != null ? visitor.getNodeId(((Node) contextContainer)) 
: FACTORY_FIELD_NAME;
-    }
-
     private void visitSubExceptionScope(org.kie.api.definition.process.Node[] 
nodes, BlockStmt body) {
         Stream.of(nodes)
                 .peek(node -> {
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/StateNodeVisitor.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/StateNodeVisitor.java
index 8c4d95aa9f..c800c3d65f 100644
--- 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/StateNodeVisitor.java
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/StateNodeVisitor.java
@@ -23,12 +23,12 @@ import java.util.Collection;
 import java.util.Map;
 import java.util.stream.Stream;
 
+import org.jbpm.compiler.canonical.node.NodeVisitorBuilderService;
 import org.jbpm.process.core.context.variable.VariableScope;
 import org.jbpm.ruleflow.core.factory.StateNodeFactory;
 import org.jbpm.workflow.core.Constraint;
 import org.jbpm.workflow.core.impl.ConnectionRef;
 import org.jbpm.workflow.core.node.StateNode;
-import org.kie.api.definition.process.Node;
 
 import com.github.javaparser.ast.expr.IntegerLiteralExpr;
 import com.github.javaparser.ast.expr.MethodCallExpr;
@@ -39,8 +39,8 @@ import static 
org.jbpm.ruleflow.core.factory.StateNodeFactory.METHOD_CONSTRAINT;
 
 public class StateNodeVisitor extends CompositeContextNodeVisitor<StateNode> {
 
-    public StateNodeVisitor(Map<Class<?>, AbstractNodeVisitor<? extends Node>> 
nodesVisitors) {
-        super(nodesVisitors);
+    public StateNodeVisitor(NodeVisitorBuilderService nodeVisitorService) {
+        super(nodeVisitorService);
     }
 
     @Override
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ActionNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ActionNodeVisitorBuilder.java
new file mode 100644
index 0000000000..9349e5bc61
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ActionNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.ActionNodeVisitor;
+import org.jbpm.workflow.core.node.ActionNode;
+import org.kie.api.definition.process.Node;
+
+public class ActionNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return ActionNode.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new ActionNodeVisitor();
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/BoundaryEventNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/BoundaryEventNodeVisitorBuilder.java
new file mode 100644
index 0000000000..7380e2194b
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/BoundaryEventNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.BoundaryEventNodeVisitor;
+import org.jbpm.workflow.core.node.BoundaryEventNode;
+import org.kie.api.definition.process.Node;
+
+public class BoundaryEventNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return BoundaryEventNode.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new BoundaryEventNodeVisitor();
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CatchLinkNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CatchLinkNodeVisitorBuilder.java
new file mode 100644
index 0000000000..aa5484ceab
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CatchLinkNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.CatchLinkNodeVisitor;
+import org.jbpm.workflow.core.node.CatchLinkNode;
+import org.kie.api.definition.process.Node;
+
+public class CatchLinkNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return CatchLinkNode.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new CatchLinkNodeVisitor();
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CompositeContextNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CompositeContextNodeVisitorBuilder.java
new file mode 100644
index 0000000000..c30cbc9898
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/CompositeContextNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.CompositeContextNodeVisitor;
+import org.jbpm.workflow.core.node.CompositeContextNode;
+import org.kie.api.definition.process.Node;
+
+public class CompositeContextNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return CompositeContextNode.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new CompositeContextNodeVisitor(nodeVisitorService);
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/DynamicNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/DynamicNodeVisitorBuilder.java
new file mode 100644
index 0000000000..f463651f74
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/DynamicNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.DynamicNodeVisitor;
+import org.jbpm.workflow.core.node.DynamicNode;
+import org.kie.api.definition.process.Node;
+
+public class DynamicNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return DynamicNode.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new DynamicNodeVisitor(nodeVisitorService);
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EndNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EndNodeVisitorBuilder.java
new file mode 100644
index 0000000000..75c54c4214
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EndNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.EndNodeVisitor;
+import org.jbpm.workflow.core.node.EndNode;
+import org.kie.api.definition.process.Node;
+
+public class EndNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return EndNode.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new EndNodeVisitor();
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventNodeVisitorBuilder.java
new file mode 100644
index 0000000000..030ef55675
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.EventNodeVisitor;
+import org.jbpm.workflow.core.node.EventNode;
+import org.kie.api.definition.process.Node;
+
+public class EventNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return EventNode.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new EventNodeVisitor();
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventSubProcessNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventSubProcessNodeVisitorBuilder.java
new file mode 100644
index 0000000000..afae970aa5
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/EventSubProcessNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.EventSubProcessNodeVisitor;
+import org.jbpm.workflow.core.node.EventSubProcessNode;
+import org.kie.api.definition.process.Node;
+
+public class EventSubProcessNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return EventSubProcessNode.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new EventSubProcessNodeVisitor(nodeVisitorService);
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/FaultNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/FaultNodeVisitorBuilder.java
new file mode 100644
index 0000000000..9c6dfe5f2d
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/FaultNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.FaultNodeVisitor;
+import org.jbpm.workflow.core.node.FaultNode;
+import org.kie.api.definition.process.Node;
+
+public class FaultNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return FaultNode.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new FaultNodeVisitor();
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ForEachNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ForEachNodeVisitorBuilder.java
new file mode 100644
index 0000000000..0ddb803c05
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ForEachNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.ForEachNodeVisitor;
+import org.jbpm.workflow.core.node.ForEachNode;
+import org.kie.api.definition.process.Node;
+
+public class ForEachNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return ForEachNode.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new ForEachNodeVisitor(nodeVisitorService);
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/HumanTaskNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/HumanTaskNodeVisitorBuilder.java
new file mode 100644
index 0000000000..475ed0824e
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/HumanTaskNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.HumanTaskNodeVisitor;
+import org.jbpm.workflow.core.node.HumanTaskNode;
+import org.kie.api.definition.process.Node;
+
+public class HumanTaskNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return HumanTaskNode.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new HumanTaskNodeVisitor(classLoader);
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/JoinNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/JoinNodeVisitorBuilder.java
new file mode 100644
index 0000000000..6a14cbdb40
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/JoinNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.JoinNodeVisitor;
+import org.jbpm.workflow.core.node.Join;
+import org.kie.api.definition.process.Node;
+
+public class JoinNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return Join.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new JoinNodeVisitor();
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/MilestoneNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/MilestoneNodeVisitorBuilder.java
new file mode 100644
index 0000000000..7d50d9d859
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/MilestoneNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.MilestoneNodeVisitor;
+import org.jbpm.workflow.core.node.MilestoneNode;
+import org.kie.api.definition.process.Node;
+
+public class MilestoneNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return MilestoneNode.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new MilestoneNodeVisitor();
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/NodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/NodeVisitorBuilder.java
new file mode 100644
index 0000000000..5aab0f3eba
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/NodeVisitorBuilder.java
@@ -0,0 +1,28 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+
+public interface NodeVisitorBuilder {
+
+    Class<?> type();
+
+    AbstractNodeVisitor<? extends org.kie.api.definition.process.Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader 
contextClassLoader);
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/NodeVisitorBuilderService.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/NodeVisitorBuilderService.java
new file mode 100644
index 0000000000..8363aab004
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/NodeVisitorBuilderService.java
@@ -0,0 +1,51 @@
+/*
+ * 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.node;
+
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.util.JbpmClassLoaderUtil;
+
+public class NodeVisitorBuilderService {
+
+    private Map<Class<?>, NodeVisitorBuilder> nodesVisitors;
+    private ClassLoader contextClassLoader;
+
+    public NodeVisitorBuilderService() {
+        this(JbpmClassLoaderUtil.findClassLoader());
+    }
+
+    public NodeVisitorBuilderService(ClassLoader contextClassLoader) {
+        this.nodesVisitors = 
ServiceLoader.load(NodeVisitorBuilder.class).stream().map(ServiceLoader.Provider::get).collect(Collectors.toMap(NodeVisitorBuilder::type,
 Function.identity()));
+        this.contextClassLoader = contextClassLoader;
+    }
+
+    public AbstractNodeVisitor<? extends org.kie.api.definition.process.Node> 
findNodeVisitor(Class<?> clazz) {
+        NodeVisitorBuilder nodeVisitor = nodesVisitors.get(clazz);
+        if (nodeVisitor != null) {
+            return nodeVisitor.visitor(this, contextClassLoader);
+        }
+        throw new IllegalArgumentException(clazz + " visitor not supported");
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/RuleSetNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/RuleSetNodeVisitorBuilder.java
new file mode 100644
index 0000000000..a1df78d234
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/RuleSetNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.RuleSetNodeVisitor;
+import org.jbpm.workflow.core.node.RuleSetNode;
+import org.kie.api.definition.process.Node;
+
+public class RuleSetNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return RuleSetNode.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new RuleSetNodeVisitor(classLoader);
+    }
+
+}
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
new file mode 100644
index 0000000000..3d29c31d31
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SplitNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.SplitNodeVisitor;
+import org.jbpm.workflow.core.node.Split;
+import org.kie.api.definition.process.Node;
+
+public class SplitNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return Split.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new SplitNodeVisitor();
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StartNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StartNodeVisitorBuilder.java
new file mode 100644
index 0000000000..76feb9af44
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StartNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.StartNodeVisitor;
+import org.jbpm.workflow.core.node.StartNode;
+import org.kie.api.definition.process.Node;
+
+public class StartNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return StartNode.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new StartNodeVisitor();
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StateNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StateNodeVisitorBuilder.java
new file mode 100644
index 0000000000..50a50b9b06
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/StateNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.StateNodeVisitor;
+import org.jbpm.workflow.core.node.StateNode;
+import org.kie.api.definition.process.Node;
+
+public class StateNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return StateNode.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new StateNodeVisitor(nodeVisitorService);
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SubProcessNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SubProcessNodeVisitorBuilder.java
new file mode 100644
index 0000000000..671aff96b4
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/SubProcessNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.LambdaSubProcessNodeVisitor;
+import org.jbpm.workflow.core.node.SubProcessNode;
+import org.kie.api.definition.process.Node;
+
+public class SubProcessNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return SubProcessNode.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new LambdaSubProcessNodeVisitor();
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ThrowLinkNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ThrowLinkNodeVisitorBuilder.java
new file mode 100644
index 0000000000..df851519b7
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/ThrowLinkNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.ThrowLinkNodeVisitor;
+import org.jbpm.workflow.core.node.ThrowLinkNode;
+import org.kie.api.definition.process.Node;
+
+public class ThrowLinkNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return ThrowLinkNode.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new ThrowLinkNodeVisitor();
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/TimerNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/TimerNodeVisitorBuilder.java
new file mode 100644
index 0000000000..658e31c68f
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/TimerNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.TimerNodeVisitor;
+import org.jbpm.workflow.core.node.TimerNode;
+import org.kie.api.definition.process.Node;
+
+public class TimerNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return TimerNode.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new TimerNodeVisitor();
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/WorkItemNodeVisitorBuilder.java
 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/WorkItemNodeVisitorBuilder.java
new file mode 100644
index 0000000000..a8142bac2b
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/java/org/jbpm/compiler/canonical/node/WorkItemNodeVisitorBuilder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.node;
+
+import org.jbpm.compiler.canonical.AbstractNodeVisitor;
+import org.jbpm.compiler.canonical.WorkItemNodeVisitor;
+import org.jbpm.workflow.core.node.WorkItemNode;
+import org.kie.api.definition.process.Node;
+
+public class WorkItemNodeVisitorBuilder implements NodeVisitorBuilder {
+
+    @Override
+    public Class<?> type() {
+        return WorkItemNode.class;
+    }
+
+    @Override
+    public AbstractNodeVisitor<? extends Node> 
visitor(NodeVisitorBuilderService nodeVisitorService, ClassLoader classLoader) {
+        return new WorkItemNodeVisitor(classLoader);
+    }
+
+}
diff --git 
a/jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.node.NodeVisitorBuilder
 
b/jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.node.NodeVisitorBuilder
new file mode 100644
index 0000000000..1cd1159948
--- /dev/null
+++ 
b/jbpm/jbpm-flow-builder/src/main/resources/META-INF/services/org.jbpm.compiler.canonical.node.NodeVisitorBuilder
@@ -0,0 +1,21 @@
+org.jbpm.compiler.canonical.node.ActionNodeVisitorBuilder
+org.jbpm.compiler.canonical.node.BoundaryEventNodeVisitorBuilder
+org.jbpm.compiler.canonical.node.CatchLinkNodeVisitorBuilder
+org.jbpm.compiler.canonical.node.CompositeContextNodeVisitorBuilder
+org.jbpm.compiler.canonical.node.DynamicNodeVisitorBuilder
+org.jbpm.compiler.canonical.node.EndNodeVisitorBuilder
+org.jbpm.compiler.canonical.node.EventNodeVisitorBuilder
+org.jbpm.compiler.canonical.node.EventSubProcessNodeVisitorBuilder
+org.jbpm.compiler.canonical.node.FaultNodeVisitorBuilder
+org.jbpm.compiler.canonical.node.ForEachNodeVisitorBuilder
+org.jbpm.compiler.canonical.node.HumanTaskNodeVisitorBuilder
+org.jbpm.compiler.canonical.node.JoinNodeVisitorBuilder
+org.jbpm.compiler.canonical.node.MilestoneNodeVisitorBuilder
+org.jbpm.compiler.canonical.node.RuleSetNodeVisitorBuilder
+org.jbpm.compiler.canonical.node.SplitNodeVisitorBuilder
+org.jbpm.compiler.canonical.node.StartNodeVisitorBuilder
+org.jbpm.compiler.canonical.node.StateNodeVisitorBuilder
+org.jbpm.compiler.canonical.node.SubProcessNodeVisitorBuilder
+org.jbpm.compiler.canonical.node.ThrowLinkNodeVisitorBuilder
+org.jbpm.compiler.canonical.node.TimerNodeVisitorBuilder
+org.jbpm.compiler.canonical.node.WorkItemNodeVisitorBuilder
\ No newline at end of file


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

Reply via email to