|
16 | 16 | package io.serverlessworkflow.impl; |
17 | 17 |
|
18 | 18 | import com.github.f4b6a3.ulid.UlidCreator; |
19 | | -import io.serverlessworkflow.api.types.Document; |
20 | 19 | import io.serverlessworkflow.api.types.SchemaInline; |
21 | 20 | import io.serverlessworkflow.api.types.Workflow; |
22 | 21 | import io.serverlessworkflow.impl.events.EventConsumer; |
@@ -52,9 +51,9 @@ public class WorkflowApplication implements AutoCloseable { |
52 | 51 | private final ExpressionFactory exprFactory; |
53 | 52 | private final ResourceLoaderFactory resourceLoaderFactory; |
54 | 53 | private final SchemaValidatorFactory schemaValidatorFactory; |
55 | | - private final WorkflowIdFactory idFactory; |
| 54 | + private final WorkflowInstanceIdFactory idFactory; |
56 | 55 | private final Collection<WorkflowExecutionListener> listeners; |
57 | | - private final Map<WorkflowId, WorkflowDefinition> definitions; |
| 56 | + private final Map<WorkflowDefinitionId, WorkflowDefinition> definitions; |
58 | 57 | private final WorkflowPositionFactory positionFactory; |
59 | 58 | private final ExecutorServiceFactory executorFactory; |
60 | 59 | private final RuntimeDescriptorFactory runtimeDescriptorFactory; |
@@ -106,7 +105,7 @@ public Collection<EventPublisher> eventPublishers() { |
106 | 105 | return eventPublishers; |
107 | 106 | } |
108 | 107 |
|
109 | | - public WorkflowIdFactory idFactory() { |
| 108 | + public WorkflowInstanceIdFactory idFactory() { |
110 | 109 | return idFactory; |
111 | 110 | } |
112 | 111 |
|
@@ -142,7 +141,7 @@ public SchemaValidator getValidator(SchemaInline inline) { |
142 | 141 | private ResourceLoaderFactory resourceLoaderFactory = DefaultResourceLoaderFactory.get(); |
143 | 142 | private SchemaValidatorFactory schemaValidatorFactory; |
144 | 143 | private WorkflowPositionFactory positionFactory = () -> new QueueWorkflowPosition(); |
145 | | - private WorkflowIdFactory idFactory = () -> UlidCreator.getMonotonicUlid().toString(); |
| 144 | + private WorkflowInstanceIdFactory idFactory = () -> UlidCreator.getMonotonicUlid().toString(); |
146 | 145 | private ExecutorServiceFactory executorFactory = new DefaultExecutorServiceFactory(); |
147 | 146 | private EventConsumer<?, ?> eventConsumer; |
148 | 147 | private Collection<EventPublisher> eventPublishers = new ArrayList<>(); |
@@ -192,7 +191,7 @@ public Builder withSchemaValidatorFactory(SchemaValidatorFactory factory) { |
192 | 191 | return this; |
193 | 192 | } |
194 | 193 |
|
195 | | - public Builder withIdFactory(WorkflowIdFactory factory) { |
| 194 | + public Builder withIdFactory(WorkflowInstanceIdFactory factory) { |
196 | 195 | this.idFactory = factory; |
197 | 196 | return this; |
198 | 197 | } |
@@ -249,15 +248,13 @@ public WorkflowApplication build() { |
249 | 248 | } |
250 | 249 | } |
251 | 250 |
|
252 | | - private static record WorkflowId(String namespace, String name, String version) { |
253 | | - static WorkflowId of(Document document) { |
254 | | - return new WorkflowId(document.getNamespace(), document.getName(), document.getVersion()); |
255 | | - } |
| 251 | + public Map<WorkflowDefinitionId, WorkflowDefinition> workflowDefinitions() { |
| 252 | + return Collections.unmodifiableMap(definitions); |
256 | 253 | } |
257 | 254 |
|
258 | 255 | public WorkflowDefinition workflowDefinition(Workflow workflow) { |
259 | 256 | return definitions.computeIfAbsent( |
260 | | - WorkflowId.of(workflow.getDocument()), k -> WorkflowDefinition.of(this, workflow)); |
| 257 | + WorkflowDefinitionId.of(workflow), k -> WorkflowDefinition.of(this, workflow)); |
261 | 258 | } |
262 | 259 |
|
263 | 260 | @Override |
|
0 commit comments