commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Huang <daniel.hu...@military-inc.com>
Subject RE: [Slightly OT] JNDI question
Date Tue, 03 May 2005 17:14:23 GMT
I'd suggest you take a look at the Inversion of Control (IoC) pattern. Any
object that needs a DataSource (typically a DAO) should not acquire it by
calling JNDI directly, instead, the caller should obtain a DS pass it to the
DAO. That way, your unit tests can easily mock up a DS to test the DAOs.

Hope this helps.

Thanks
Daniel

 -----Original Message-----
From: 	WHIRLYCOTT [mailto:phil@whirlycott.com] 
Sent:	Tuesday, May 03, 2005 8:41 AM
To:	Jakarta Commons Users List
Subject:	[Slightly OT] JNDI question

I'm wondering if somone has any creative ideas here.  I'm working on a 
project that gets javax.sql.DataSource instances via Tomcat's JNDI 
provider.  This works fine, except when we are developing code and need 
to run Junit tests.

Because the tests need to run outside Tomcat, getting access to a 
DataSource via JNDI becomes a pain in the neck.

I'm assuming that this is a very common situation and I'm wondering if 
anybody has slick tricks for your dev environments that allow you do get 
DataSource objects via JNDI...?

phil.

-- 
                                   Whirlycott
                                   Philip Jacob
                                   phil@whirlycott.com
                                   http://www.whirlycott.com/phil/

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message