[hibernate-dev] Hibernate Event System Elaboration & Enhancement
Ricky
ricky.nj at gmail.com
Tue Feb 26 13:25:41 EST 2008
Hi,
As suggested, i am forwarding my idea as to what i think Hibernate should
have.
Hibernate currently lacks proper event Delegation model;
Granted it has a hook for listeners and iterates through them to find out
which is appropriate or not.
But a better way would be to add "Queuing of events" approach; meaning each
event is first queued (for firing) and then Hibernate goes through cycles of
phases (it can be internally thought of as a Phase 1 ---> Phase 2 ---> Phase
3 ). and each phase has a queue of events it has to process. A phase can
have corresponding listener to process phases and clear the queue of events
associated with it ( meaning events set to "fire" in the currently executing
phase). All event creation should be centralized and all events should be
queued through a factory. A flexible approach (ideally) would be to allow
users to create Custom phases to enhance lifecycle of their own Application
using Hibernate's Phase interface. "Phase implementation " could include
usage of Enums, but its not mandatory ( so long as we are worried about
back-wards compatibility).
As it is, Hibernate Event system is poorly documented and not very well
understood.
To visualize what i am proposing ( it is actually similiar to the way JSF
works), you have a Phase queue with Phase Factory and a Phase Listener
associated for execution of a phase. Each phase has a bound Queue of Events
to it. A broadcast Agent will broad cast the event to happen in a particular
phase. Next Broadcast Handler Delegate handles the event broadcast by
cycling through phases and finding out what is the current phase and whether
the event which is being broadcast is registered to fire in this phase or
not; (i.e. is appropriate Phase), based on that a phase listener is called
to handle the current phase Phase Listener calls event delegate (which is
the current hook for all listeners) and it will then cycle through listeners
to transfer control to an appropriate listener.
I'd be happy to contribute.
What do you guys think ?
Regards
Vyas, Anirudh
|| ॐ ||
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-dev/attachments/20080226/bfd9db9b/attachment.html
More information about the hibernate-dev
mailing list