Skip to content

GH-1118 - Detect @DomainEvent in the type hierarchy of published events - #1875

Closed
hunseonglee wants to merge 1 commit into
spring-projects:mainfrom
hunseonglee:GH-1118
Closed

hunseonglee wants to merge 1 commit into
spring-projects:mainfrom
hunseonglee:GH-1118

Conversation

@hunseonglee

Copy link
Copy Markdown
Contributor

Follows up on my comment on the issue: since @Inherited only propagates along superclasses (never implemented interfaces), the arrangement reported in GH-1118 — an annotated root interface — cannot be fixed by adding @Inherited to the jMolecules annotations, so a Modulith-side hierarchy-aware lookup seems needed either way. If you'd still rather solve this differently, happy to adapt or close.

Published event detection only considered @DomainEvent declared directly on the event type. This change makes ApplicationModule#findPublishedEvents() traverse the type hierarchy (superclasses and implemented interfaces) and also consider meta-annotations, so custom annotations composed with @DomainEvent are detected as well.

The added fixtures cover both shapes: a class implementing an @DomainEvent-annotated interface (the reported case) and a class extending an annotated superclass. discoversPublishedEvents fails on main for both and passes with the change; the full spring-modulith-core suite passes.

The @DomainEventHandler and meta-annotated @NamedInterface cases from the follow-up comments are not covered here — happy to address those as separate PRs if you'd like.

Closes GH-1118

… published events.

Published event detection only considered @domainevent annotations
declared directly on the event type. Events inheriting the annotation
from an implemented interface or a superclass were not listed in
ApplicationModule#getPublishedEvents(). @inherited on the jMolecules
side would not cover the reported arrangement either, as it only
propagates along superclasses, not implemented interfaces.

Event detection now traverses the type hierarchy (superclasses and
implemented interfaces) and also considers meta-annotations, so that
custom annotations composed with @domainevent are detected as well.

Signed-off-by: seonghun lee <harrisleesh@gmail.com>
odrotbohm pushed a commit that referenced this pull request Sep 17, 2026
Published event detection only considered @domainevent annotations declared directly on the event type. Events inheriting the annotation from an implemented interface or a superclass were not listed in ApplicationModule#getPublishedEvents(). @inherited on the jMolecules side would not cover the reported arrangement either, as it only propagates along superclasses, not implemented interfaces.

Event detection now traverses the type hierarchy (superclasses and implemented interfaces) and also considers meta-annotations, so that custom annotations composed with @domainevent are detected as well.

Original pull request: GH-1875
Signed-off-by: seonghun lee <harrisleesh@gmail.com>
odrotbohm pushed a commit that referenced this pull request Sep 17, 2026
Published event detection only considered @domainevent annotations declared directly on the event type. Events inheriting the annotation from an implemented interface or a superclass were not listed in ApplicationModule#getPublishedEvents(). @inherited on the jMolecules side would not cover the reported arrangement either, as it only propagates along superclasses, not implemented interfaces.

Event detection now traverses the type hierarchy (superclasses and implemented interfaces) and also considers meta-annotations, so that custom annotations composed with @domainevent are detected as well.

Original pull request: GH-1875
Signed-off-by: seonghun lee <harrisleesh@gmail.com>
odrotbohm pushed a commit that referenced this pull request Sep 17, 2026
Published event detection only considered @domainevent annotations declared directly on the event type. Events inheriting the annotation from an implemented interface or a superclass were not listed in ApplicationModule#getPublishedEvents(). @inherited on the jMolecules side would not cover the reported arrangement either, as it only propagates along superclasses, not implemented interfaces.

Event detection now traverses the type hierarchy (superclasses and implemented interfaces) and also considers meta-annotations, so that custom annotations composed with @domainevent are detected as well.

Original pull request: GH-1875
Signed-off-by: seonghun lee <harrisleesh@gmail.com>
@odrotbohm

Copy link
Copy Markdown
Member

That's polished, merged, and back-ported.

@odrotbohm odrotbohm closed this Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@DomainEvent not detected on parent types

2 participants