File tree Expand file tree Collapse file tree 3 files changed +29
-2
lines changed
src/main/java/com/uber/cadence Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -94,12 +94,17 @@ void setWorkflowImplementationTypes(
94
94
}
95
95
96
96
<R > void addWorkflowImplementationFactory (Class <R > clazz , Functions .Func <R > factory ) {
97
- workflowImplementationFactories .put (clazz , factory );
98
97
WorkflowImplementationOptions unitTestingOptions =
99
98
new WorkflowImplementationOptions .Builder ()
100
99
.setNonDeterministicWorkflowPolicy (FailWorkflow )
101
100
.build ();
102
- addWorkflowImplementationType (unitTestingOptions , clazz );
101
+ addWorkflowImplementationFactory (unitTestingOptions , clazz , factory );
102
+ }
103
+
104
+ <R > void addWorkflowImplementationFactory (
105
+ WorkflowImplementationOptions options , Class <R > clazz , Functions .Func <R > factory ) {
106
+ workflowImplementationFactories .put (clazz , factory );
107
+ addWorkflowImplementationType (options , clazz );
103
108
}
104
109
105
110
private void addWorkflowImplementationType (
Original file line number Diff line number Diff line change @@ -98,6 +98,11 @@ public void setWorkflowImplementationTypes(
98
98
factory .setWorkflowImplementationTypes (options , workflowImplementationTypes );
99
99
}
100
100
101
+ public <R > void addWorkflowImplementationFactory (
102
+ WorkflowImplementationOptions options , Class <R > clazz , Func <R > factory ) {
103
+ this .factory .addWorkflowImplementationFactory (options , clazz , factory );
104
+ }
105
+
101
106
public <R > void addWorkflowImplementationFactory (Class <R > clazz , Func <R > factory ) {
102
107
this .factory .addWorkflowImplementationFactory (clazz , factory );
103
108
}
Original file line number Diff line number Diff line change @@ -235,6 +235,23 @@ public void registerWorkflowImplementationTypes(
235
235
workflowWorker .setWorkflowImplementationTypes (options , workflowImplementationClasses );
236
236
}
237
237
238
+ /**
239
+ * Configures a factory to use when an instance of a workflow implementation is created.
240
+ * !IMPORTANT to provide newly created instances, each time factory is applied.
241
+ *
242
+ * <p>Unless mocking a workflow execution use {@link
243
+ * #registerWorkflowImplementationTypes(Class[])}.
244
+ *
245
+ * @param workflowInterface Workflow interface that this factory implements
246
+ * @param factory factory that when called creates a new instance of the workflow implementation
247
+ * object.
248
+ * @param <R> type of the workflow object to create.
249
+ */
250
+ public <R > void addWorkflowImplementationFactory (
251
+ WorkflowImplementationOptions options , Class <R > workflowInterface , Func <R > factory ) {
252
+ workflowWorker .addWorkflowImplementationFactory (options , workflowInterface , factory );
253
+ }
254
+
238
255
/**
239
256
* Configures a factory to use when an instance of a workflow implementation is created. The only
240
257
* valid use for this method is unit testing, specifically to instantiate mocks that implement
You can’t perform that action at this time.
0 commit comments