Mutability of EventListenerGroup should be restricted to the bootstrap phase #5956
Sanne
started this conversation in
Design Proposals
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The
EventListenerGroup
SPI is designed to allow changes to the event listeners, which is very handy as it's the core integration point for Hibernate Envers, Search, and other powerful tools such as Micrometer integration.However this same SPI is also accessible after the
SessionFactory
has completed bootstrap, and we're allowing to mutate the set of listeners at any point in time; there are several issues with this:Furthermore, the current SPI is defining both the integration contract with external libraries and also defining the internal contract to actually activate such listeners; I'm suggesting to maintain the current SPI for external integrations (it seems adequate for such purposes) but disallow changes after
SessionFactory
has been created.We would then introduce a separate contract for internal iteration; this keeps the public SPI cleaner from internal needs and would also allow us more flexibility with future changes. I do intend such internal contract to require the set of listeners be "cast in stone" for the life of the SessionFactory though as that would keep things simpler, prevent tricky issues and allow for much higher efficiency (my POC shows there's dozens of simplifications we could do in such case).
Unfortunately such a change can't be done right now at short notice, as several such libraries would need to ensure they register their custom listeners during an earlier phase.
Beta Was this translation helpful? Give feedback.
All reactions