On Jul 12, 2007, at 7:54 AM, Andrus Adamchik wrote:

From my experience DBCP works extremely well as a connection pool, but the API can use some cleanup. My favorite example is PoolableConnectionFactory [1]. So in Cayenne we have code like this:

ObjectPool connectionPool = new GenericObjectPool(null, poolConfig);
new PoolableConnectionFactory(
                factory,
                connectionPool,
                statementPool,
                validationQuery,
                defaultReadOnly ? Boolean.TRUE : Boolean.FALSE,
                defaultAutoCommit,
                defaultTransactionIsolation,
                defaultCatalog,
                null);
return connectionPool;

PoolableConnectionFactory attaches itself to the connection pool inside constructor. Looks weird - an object is created but not assigned to anything. Every time I stumble upon this code, I have to doublecheck that nothing insane is going on. 9-arg constructor is also not good.

Would be cool if new volunteers from Geronimo could refactor things a bit ;-)

I thought about that, but there is a lot of code and extensions to this so I don't think the API can be changed. I just created a new BasicManagedDataSource which uses JavaBeans properties to setup the data source. With the existing xbean-reflect code the data source "Just Works". I'm sure the same can be said for Spring.

-dain

Reply via email to