SIGN IN SIGN UP

Make BPMN EventDefinitions and CMMN EventListeners extensible end-to-end (#4206)

Add public hooks for registering custom BPMN `EventDefinition` and CMMN
`EventListener` types, and refactor the dispatch, deploy-lifecycle and
placement-validation paths so the built-ins go through the same code as
the customs.

## Extensibility surface

- **BPMN** — `ActivityBehaviorFactory` gains `create...EventActivityBehavior`
  factory methods, and `addCustomChildElementParser` /
  `addCustomEventDefinitionWriter` register a custom `<flowable:*>`
  `EventDefinition` parser and matching XML writer at engine init. A
  `CustomBpmnEventDefinition` marker routes a subclass through the
  extension-elements serialization path.
- **CMMN** — a `flowable:eventType` discriminator registry on
  `GenericEventListenerXmlConverter` (built-ins: `signal`, `variable`,
  `intent`, `reactivate`) with a `customEventListenerTypeFactories` slot
  on `CmmnEngineConfiguration`; unknown values warn and fall back to a
  generic listener.
- **`EventDefinition#getSupportedLocations()`** — declares the placements
  each subtype is valid at (start / event-sub-process start / intermediate
  catch / boundary / end / intermediate throw); all six placement
  validators consult it instead of hard-coded `instanceof` chains.

## Parse-handler dispatch unification

`StartEventParseHandler`, `IntermediateThrowEventParseHandler` and
`EndEventParseHandler` drop their `instanceof` cascades and delegate via
`parseElement(eventDefinition)`, matching the boundary / catch handlers.
Per-`EventDefinition` handlers gain the missing placement branches; a new
`TerminateEventDefinitionParseHandler` covers terminate-end.

## Behavior owns its deploy lifecycle

- Process-level StartEvents implement `ProcessLevelStartEventActivityBehavior`
  (`deploy` / `undeploy` with typed contexts and an
  `isRestoringPreviousVersion` flag); `BpmnDeploymentHelper` just iterates
  start events, and the `EventSubscriptionManager` / `TimerManager` classes
  are deleted.
- Event-sub-process StartEvents implement
  `EventSubProcessStartEventActivityBehavior`
  (`initializeEventSubProcessStart`); the registering behaviors absorb the
  `handle...` helpers from `ProcessInstanceHelper`, which collapses to one
  delegated call.
- `DeploymentProcessDefinitionDeletionManagerImpl` delegates
  restore-after-delete to `behavior.deploy(...)` with
  `isRestoringPreviousVersion=true`.
- CMMN parity: a `CaseDefinitionStartLifecycleHandler` attached to the
  `Case` at parse time owns deploy / undeploy; the built-in
  `EventRegistryCaseDefinitionStartLifecycleHandler` is installed when
  `case.startEventType` is set.
- New `findEventSubscriptionsByTypesAndProcessDefinitionId` /
  `...AndScopeDefinitionId` finders do deploy-time cleanup in a single
  `EVENT_TYPE_ IN (...)` query.

## XML round-trip

`<flowable:eventType>X</flowable:eventType>` on a start / intermediate-catch
/ boundary event is promoted to a typed `EventRegistryEventDefinition` in
`BpmnXMLConverter.processFlowElements` and retained as an extension element,
so code that reads it directly keeps working; the typed writer dedupes so
the round-trip emits exactly one element.

## No breaking changes

The CMMN event-registry listener path is unchanged —
`<flowable:eventType>X</flowable:eventType>` still maps onto a
`GenericEventListener` with its `eventType` set, and the new discriminator
registry only adds an alternative attribute-driven way to pick a listener
type.
F
Filip Hrisafov committed
3ebb1a7f8edd7057e6a1e0a3086d6b7ed8ca2e53
Parent: 0b6067f
Committed by GitHub <noreply@github.com> on 5/12/2026, 12:36:51 PM