Spring transaction management is that it allows you to declaratively or programmatically define transactions around methods, without the need for a container (it uses AOP to insert the transactional code around the service methods at runtime). One can therefore test transactional methods in a service layer in plain old Junit, without having any app server running. Thus the applicaion is transactionally aware, without the need for CMTs and (hurrah) - no EJBs.

So getting back to the original question, which basically asked about dynamically creating datasources, which for the sake of argument were used by data access code that in turn was used by service methods I would  recommend doing the following:

buy the book, "Spring in action" and get up to speed on Spring. Chapter 4 shows you how to wire datasources to data access objects, chapter 5 shows you how to introduce transactions. Once you've got to that stage you'll know how Spring works and how do what you want in a static, non-dynamic way. Then pop over to the Spring forums and read these threads:

http://forum.springframework.org/showthread.php?t=21925&highlight=dynamic+datasource
http://forum.springframework.org/showthread.php?t=19887&highlight=dynamic+datasource


which tells you all you need to know about doing it dynamically

I can't recommend Spring enough for any Java programmer who hasn't used it, it creates cleaner, more decoupled, easier to test code and gives you loads of help for jdbc, hibernate, transactions, security, JSPs and so on.

I apologise for veering away from Geronimo, but on the application I am working on at the moment, we are doing something very similar to the above, and need the application to run in both Geronimo and Websphere (full version, not CE), so we have to make our code app server independent.




David Jencks <[EMAIL PROTECTED]>

27/06/2006 16:55
Please respond to user

       
        To:        [email protected]
        cc:        
        Subject:        Re: Dynamically creating datasources




On Jun 27, 2006, at 3:05 AM, [EMAIL PROTECTED] wrote:


"That would be app server independent, but it would also preclude any container managed transaction features such as use of UserTransaction or CMT ejbs.  If you don't need any features like these this might well be your simplest solution."

I neglected to point out that I am using Spring's AOP techniques to wrap my services in transactions anyway, so I have transactional support without the need for containers or EJBs. I know this is possibly sidestepping the issue, but that is exactly what I wanted to do ;-)


I'm not really familiar with dbcp, but my impression is that it is not jta-aware.  I'm also not that familiar with spring tx management but again I think that without a jta-aware pooling implementation hooked up to a jta (or jts) tm no container managed transactions will work.  In other words, I greatly doubt that what you are doing will work.  I'm happy to be proved wrong.

thanks
david jencks

Target
www.targetgroup.net
**********************************************************************
DISCLAIMER.
This message is intended only for the use of the Addressee and may
contain information that is PRIVILEGED and CONFIDENTIAL.
If you are not the intended recipient you must not copy,
distribute or take any action or reliance upon it.
The content of this message may also contain personal
views of an employee of this company and does
not necessarily represent the view of the company.
**********************************************************************
This message has been scanned by Norton Anti-Virus.
It has also been scanned by MAILsweeper to enforce our e-mail
policy. If you have any concerns or comments about the content
of this message, please e-mail [EMAIL PROTECTED].
**********************************************************************

_____________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit

http://www.messagelabs.com


_____________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System.


_____________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com

Reply via email to