Well, finally employed it in my project.
pico (as expected) simplified configuration to triviality.
Assuming I like to have DAO which does cool things for me.
DAO needs "session provider" - where it can obtain session, give it back and
flush/ rollback...
1. I subclass configuration, and in constructor I set properties,
(or read xml configuration ) and add my classes there.
2. I develop "session factory provider" component - it gets configuration in constructor,
and creates session factory
3. I develop session factory, which creates and manages session ( for example in thread local
variable )
4. I develop my DAO accepts session factory as constructor parameter.
2 & 3 are pretty generic, and could be easily reused. And "thread local" behaviour can be
easily done by picocontainer ( through not yet implemented component adapter, which would be also thrivial ).
Split between 1 & 2 is necessary because session factory is not subclassing-friendly.
Of course session factory could be placed in container like every other componen,
but since there is no constructor, it has to be done in java code ( or scripting ) - and I prefer
xml configuration....
_________________ Got new hibernate xdoclet plugin? http://www.sourceforge.net/projects/xdoclet-plugins/
... Momentan auf der Suche nach neuen Projekt ode Festanstellung....
|