Recap of recent weeks (Spring framework).
Let's see... When I was laying down with severe stomach flu last week I had a bunch of ideas of what to write about here... Where did it all go?
Had first encounter with Spring. Amazing technology, really. I started looking for some container that will have contextual support for persistent operations, basically. Mostly because I got sick of seeing code passing, from one method into another, some custom construct tying together database connection and current statement and/or result set (Did I mention how twisted are some designs I encounter at my workplace? I'm sure I did :) ). I wanted something akin to how it's done in EJB, but without an EJB container (it's unthinkable to expect us to deploy a full-blown J2EE stack in any foreseeable perspective). Very glad Spring allows for this. It took me two partial weekend days overall to figure out a working XML config file. After I figured it out, it all makes sense:
Had first encounter with Spring. Amazing technology, really. I started looking for some container that will have contextual support for persistent operations, basically. Mostly because I got sick of seeing code passing, from one method into another, some custom construct tying together database connection and current statement and/or result set (Did I mention how twisted are some designs I encounter at my workplace? I'm sure I did :) ). I wanted something akin to how it's done in EJB, but without an EJB container (it's unthinkable to expect us to deploy a full-blown J2EE stack in any foreseeable perspective). Very glad Spring allows for this. It took me two partial weekend days overall to figure out a working XML config file. After I figured it out, it all makes sense:
- configure a DataSource (I'm using embedded Derby; this has a nasty effect that shutting down Derby cleanly is not possible without writing a wrapper DisposableBean, as Derby will not take a single no-arg method call to go down....)
- using this DataSource, create a Hibernate SessionFactory
- using same DataSource, build transaction manager
- take that transaction manager and stuff it into a DAO alongside SessionFactory (make sure DAO implements an interface, and when casting the object acquired from application context aka bean factory, cast the object to that interface; again, result being not unlike EJB or RMI stub compiler would produce)
0 Comments:
Post a Comment
<< Home