commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Lear <r...@zopyra.com>
Subject Re: [HiveMind] Question about DAO creation
Date Fri, 03 Oct 2003 15:19:09 GMT
On Friday, October 3, 2003 at 16:33:58 (+0200) Christian Essl writes:
>...
>Than I would give out the DOA directly as a service. Than as you also said 
>(for your second question) I would implement a ConnectionPool service 
>interface and a (or more) implementation(s) (one which just holds one 
>connection - for your testing). Than I would change the DAO-implementation 
>to take a ConnectionPool service as parameter and get the connection from 
>there.
>
>interface ConnectionPool {
>  public Connection getConnection();
>  public void returnConnection(Connection connection);
>}

Hmm, I'm starting to like this.

><module...>
>
><service-point id="DAO"
>...
></service>
>
><service-point id="ConnectionPool"
>...
></service>

Ok, I think I'm getting the point...

>Now you saved the factory and you have access to the single connection in 
>your test-code. In running code you can still change to a real connection 
>pool. With this suggestion you still have to change both the DAO service- 
>definition and the ConnectionPool definition if you want to change the DAO 
>implementation. However this can be cleaned up, see the Overriding-Services 
>tutorial at the hivemind page.
>
>Finally: I think (like you) you should if you are going to use a 'real' 
>connection-pool take the connection out of the commands. I would give the 
>commands the connection as a parameter each time they are called. The 
>caller would get it from the ConnectionPool call the command with it and 
>return it straight to the pool.

This is something I've been considering, and I think I'm convinced that
this is a better way to do things.

Thanks for the feedback.


Bill

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


Mime
View raw message