It can be done either:
as an event/eventListener
as a method that eventlisteners implement (symmetric of initialize())
The former being more flexible
Copied this from Documentation on Events comment, as i thought it'd be more appropriate.
Hibernate Event System lacks documentation as well as some of the parts ( or i think so, correct me if i go wrong somewhere ).
In the Event System ( for example OnSaveOrUpdateEvent )
It would be appropriate to move all the Event delegation based code to an Event Delegate which has all the listeners registered to it and then use a Broadcast agent to do broadcast ( or Fire an event in Hibernate Terminology ) the events and loop through listeners to check.
something like :
// fire the event
SessionImpl.broadcastSaveEvent( SaveEvent( Phase.SAVE, Source etc etc ) , BaseEventDelegate );
// use a BroadCast interface and implement a DefaultBroadcastAgent and do something like
DefaultBroadcastAgent.processBroadcast( BaseEventDelegate )
// broadcaster above uses event delegate passed to it to loop through listeners.
// same as in SessionImpl.
we could also check if listeners passed to this was an appropriate listener or not.
Let me know in case you need more clarifications.
Bulk closing stale resolved issues