Skip to content

Commit 229f5d2

Browse files
committed
Delegate IntermediateThrowEvent dispatch to EventDefinition parse handlers
Replace IntermediateThrowEventParseHandler's instanceof cascade with a parseElement(eventDefinition) delegation. Signal and Escalation parse handlers gain a ThrowEvent branch (Compensate already had one); the None-throw path stays inline.
1 parent 8704f3f commit 229f5d2

3 files changed

Lines changed: 24 additions & 24 deletions

File tree

modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/EscalationEventDefinitionParseHandler.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.flowable.bpmn.model.EscalationEventDefinition;
1919
import org.flowable.bpmn.model.EventSubProcess;
2020
import org.flowable.bpmn.model.StartEvent;
21+
import org.flowable.bpmn.model.ThrowEvent;
2122
import org.flowable.engine.impl.bpmn.parser.BpmnParse;
2223

2324
/**
@@ -42,6 +43,11 @@ protected void executeParse(BpmnParse bpmnParse, EscalationEventDefinition event
4243
boundaryEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createBoundaryEscalationEventActivityBehavior(boundaryEvent,
4344
eventDefinition, escalation, boundaryEvent.isCancelActivity()));
4445

46+
} else if (bpmnParse.getCurrentFlowElement() instanceof ThrowEvent throwEvent) {
47+
Escalation escalation = bpmnParse.getBpmnModel().getEscalation(eventDefinition.getEscalationCode());
48+
throwEvent.setBehavior(bpmnParse.getActivityBehaviorFactory()
49+
.createIntermediateThrowEscalationEventActivityBehavior(throwEvent, eventDefinition, escalation));
50+
4551
} else if (bpmnParse.getCurrentFlowElement() instanceof StartEvent startEvent
4652
&& startEvent.getSubProcess() instanceof EventSubProcess) {
4753
startEvent.setBehavior(bpmnParse.getActivityBehaviorFactory()
Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/* Licensed under the Apache License, Version 2.0 (the "License");
22
* you may not use this file except in compliance with the License.
33
* You may obtain a copy of the License at
4-
*
4+
*
55
* http://www.apache.org/licenses/LICENSE-2.0
6-
*
6+
*
77
* Unless required by applicable law or agreed to in writing, software
88
* distributed under the License is distributed on an "AS IS" BASIS,
99
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -13,10 +13,8 @@
1313
package org.flowable.engine.impl.bpmn.parser.handler;
1414

1515
import org.flowable.bpmn.model.BaseElement;
16-
import org.flowable.bpmn.model.CompensateEventDefinition;
17-
import org.flowable.bpmn.model.EscalationEventDefinition;
1816
import org.flowable.bpmn.model.EventDefinition;
19-
import org.flowable.bpmn.model.SignalEventDefinition;
17+
import org.flowable.bpmn.model.EventDefinitionLocation;
2018
import org.flowable.bpmn.model.ThrowEvent;
2119
import org.flowable.engine.impl.bpmn.parser.BpmnParse;
2220
import org.slf4j.Logger;
@@ -36,27 +34,18 @@ public Class<? extends BaseElement> getHandledType() {
3634

3735
@Override
3836
protected void executeParse(BpmnParse bpmnParse, ThrowEvent intermediateEvent) {
39-
40-
EventDefinition eventDefinition = null;
41-
if (!intermediateEvent.getEventDefinitions().isEmpty()) {
42-
eventDefinition = intermediateEvent.getEventDefinitions().get(0);
37+
if (intermediateEvent.getEventDefinitions().isEmpty()) {
38+
intermediateEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowNoneEventActivityBehavior(intermediateEvent));
39+
return;
4340
}
4441

45-
if (eventDefinition instanceof SignalEventDefinition signalEventDefinition) {
46-
intermediateEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowSignalEventActivityBehavior(intermediateEvent, signalEventDefinition,
47-
bpmnParse.getBpmnModel().getSignal(signalEventDefinition.getSignalRef())));
48-
49-
} else if (eventDefinition instanceof EscalationEventDefinition escalationEventDefinition) {
50-
intermediateEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowEscalationEventActivityBehavior(intermediateEvent, escalationEventDefinition,
51-
bpmnParse.getBpmnModel().getEscalation(escalationEventDefinition.getEscalationCode())));
52-
53-
} else if (eventDefinition instanceof CompensateEventDefinition compensateEventDefinition) {
54-
intermediateEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowCompensationEventActivityBehavior(intermediateEvent, compensateEventDefinition));
55-
56-
} else if (eventDefinition == null) {
57-
intermediateEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateThrowNoneEventActivityBehavior(intermediateEvent));
58-
} else {
59-
LOGGER.warn("Unsupported intermediate throw event type for throw event {}", intermediateEvent.getId());
42+
EventDefinition eventDefinition = intermediateEvent.getEventDefinitions().get(0);
43+
if (!eventDefinition.getSupportedLocations().contains(EventDefinitionLocation.INTERMEDIATE_THROW_EVENT)) {
44+
LOGGER.warn("EventDefinition {} is not supported on intermediate throw event {}",
45+
eventDefinition.getClass().getSimpleName(), intermediateEvent.getId());
46+
return;
6047
}
48+
49+
bpmnParse.getBpmnParserHandlers().parseElement(bpmnParse, eventDefinition);
6150
}
6251
}

modules/flowable-engine/src/main/java/org/flowable/engine/impl/bpmn/parser/handler/SignalEventDefinitionParseHandler.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.flowable.bpmn.model.Signal;
2020
import org.flowable.bpmn.model.SignalEventDefinition;
2121
import org.flowable.bpmn.model.StartEvent;
22+
import org.flowable.bpmn.model.ThrowEvent;
2223
import org.flowable.engine.impl.bpmn.parser.BpmnParse;
2324

2425
/**
@@ -43,6 +44,10 @@ protected void executeParse(BpmnParse bpmnParse, SignalEventDefinition signalDef
4344
} else if (bpmnParse.getCurrentFlowElement() instanceof BoundaryEvent boundaryEvent) {
4445
boundaryEvent.setBehavior(bpmnParse.getActivityBehaviorFactory().createBoundarySignalEventActivityBehavior(boundaryEvent, signalDefinition, signal, boundaryEvent.isCancelActivity()));
4546

47+
} else if (bpmnParse.getCurrentFlowElement() instanceof ThrowEvent throwEvent) {
48+
throwEvent.setBehavior(bpmnParse.getActivityBehaviorFactory()
49+
.createIntermediateThrowSignalEventActivityBehavior(throwEvent, signalDefinition, signal));
50+
4651
} else if (bpmnParse.getCurrentFlowElement() instanceof StartEvent startEvent) {
4752
if (startEvent.getSubProcess() instanceof EventSubProcess) {
4853
startEvent.setBehavior(bpmnParse.getActivityBehaviorFactory()

0 commit comments

Comments
 (0)