You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cayenne.apache.org by Mike Kienenberger <mk...@gmail.com> on 2006/05/05 15:59:23 UTC

JNDI deferred DataSourceFactory lookup

One of my ongoing maintenance reducers for my current set of projects
has been to share the same configuration file in all my projects,
letting JNDI point to the right things at the right times.

However, it'd be cool if my application didn't attempt to access a
data source definition until it actually needed it.   Right now, I
have to define JNDI definitions for all databases even if the
underlying application will never use the node.

I do note that the actual connection to the database is deferred until
it's first used.   What's the feasability of also deferring the JNDI
request until it's also needed?

I admit I haven't tried to look into the source yet -- being lazy
today -- in case that someone can give me a quick "don't bother"
before spending any time on it ;)

And if it is feasable, how do others feel about this change?  I
suppose I could make a subclass of JNDIDataSourceFactory in the worse
case, make it a config option in the second case, and make it the only
behavior in the best case :)

Re: JNDI deferred DataSourceFactory lookup

Posted by Andrus Adamchik <an...@objectstyle.org>.
+1 for the improvement.

Let's defer putting this in Cayenne core till after 1.2, but it  
should be fairly easy to implement - just return a lazy DataSource  
decorator from JNDIDataSourceFactory.getDataSource(..) that calls  
back on some non-public factory method when the first connection is  
requested.

Andrus


On May 5, 2006, at 9:59 AM, Mike Kienenberger wrote:

> One of my ongoing maintenance reducers for my current set of projects
> has been to share the same configuration file in all my projects,
> letting JNDI point to the right things at the right times.
>
> However, it'd be cool if my application didn't attempt to access a
> data source definition until it actually needed it.   Right now, I
> have to define JNDI definitions for all databases even if the
> underlying application will never use the node.
>
> I do note that the actual connection to the database is deferred until
> it's first used.   What's the feasability of also deferring the JNDI
> request until it's also needed?
>
> I admit I haven't tried to look into the source yet -- being lazy
> today -- in case that someone can give me a quick "don't bother"
> before spending any time on it ;)
>
> And if it is feasable, how do others feel about this change?  I
> suppose I could make a subclass of JNDIDataSourceFactory in the worse
> case, make it a config option in the second case, and make it the only
> behavior in the best case :)
>