I am new to Struts, Struts2, and Spring. (And maybe know too much about jdbc.)
I have written my application with Struts2 and am only using Spring
to manage my database connections. I have defined my oracle database
as a JNDI resource in my Tomcat server.xml file.
I have defined a dataSource bean in my applicationContext.xml for my
database JNDI resource.
I have written some DAO classes which are spring beans defined in my
applicationContext.xml. These all have a dataSource property
pointing to my database. These DAO classes have methods which
execute various db stored procedures or select statements.
Now, I have some strut2 ActionSupport subclasses which do something
like this in my execute() method
ThingDao thingDao= (ThingDao )getBean("ThingDao");
All is well, all is working.
However, what I want to know is something about how Spring
works. Does it manage these beans as singletons? Or every time the
execute() method is called, and I get my dao bean, does it
instantiate a new instance of the dao bean object? Should I save
this dao bean object in a private member of my ActionSupport class
and reuse it everytime execute() is called?
Right now, I have my ActionSupport class execute method make the
getBean everytime execute is called.
At what point does Spring get a database connection...when the dao
bean is instantiated, or when the dao bean executes() some jdbc
call. (I assume this is when it makes a jdbc call, but I just want
to confirm).
If anyone can enlighten me or point me to some good documentation on
this subject, I would appreciate it.
Thanks,
Cecilia
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]