You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "Waldhoff, Rodney" <rw...@us.britannica.com> on 2001/01/16 21:17:48 UTC

[PATCH] Connection Pool Enhancements and More

I've put together a bundle of new code, leading up to (and driven by)
enhancements to the JDBC connection pooling library.  

The archive, at 76K, is too large to send to the list ("Sorry, I don't
accept messages larger than 100000 bytes (#5.2.3)") so I've placed it at
http://amandaalysa.tripod.com/rwald/dbpool.jar.  If you have trouble
downloading it directly, go to http://amandaalysa.tripod.com/rwald/ and
right- or shift-click to grab it.  If you're still having a trouble, drop me
a note and I'll send it off-list.

Included in this bundle is:

 * org.apache.struts.util.CursorableLinkedList

A doubly linked list implementation, similar to java.util.LinkedList, but
supporting a ListIterator that isn't bothered by concurrent modifications (a
"cursor").  This may also be more efficient that the JDK equivalent, since
it takes advantage
of the linked list structure when working with sublists, etc.

 * org.apache.struts.util.pool.*

A set of interfaces and classes supporting the pooling (of instances) of
objects.  The design separates the way in which instances of objects are
created, destroyed and validated from the mechanism by which instances are
pooled.  A fairly robust pool implementation (Generic[Keyed]ObjectPool) is
provided, supporting, among other features, the validation of objects before
they are obtained from or returned to the pool, and the eviction of objects
as they sit idle in the pool (due to idle time or validation).

 * org.apache.struts.sql.*

A set of classes supporting database connection and statement pooling.  This
adds several features that have been discussed/requested on this list, as
well as some that haven't been.  These include:
  + the validation of Connections
  + support for "keep alive" queries while the Connections sit idle in the
pool
  + support for evicting Connections that sit too long in the pool, or that
become invalid while idle
  + support for pooling PreparedStatements
  + support for a custom JDBC Driver that makes it easy to retrofit legacy
code with connection and statement pooling functionality

Generate the JavaDoc documentation for more details on the use of these
libraries.

Some additional comments:

 a) I added a org.apache.struts.util.pool and org.apache.struts.sql package,
because I thought that the namespace in *.util was becoming too polluted
otherwise.

 b) Although the org.apache.struts.sql.PoolingDataSource class could be seen
as a modification of org.apache.struts.util.GenericDataSource, I went ahead
and renamed/repackaged it because I thought the changes were substantial
enough that we should try to avoid confusion.  I left Craig's and Ted's
names on PoolingDataSource, I hope they don't mind.  (Guys, feel free to
remove them if you want.  I did use part of the GenericDataSource
implementation and interface, so it's technically accurate, but there's a
lot of changes also, so you may not want to be associated with my crufty
code.)

 c) This is derived from a database pooling implementation we've been using
in production for a while and found to be rather effective, but I did
introduce some changes when repackaging it for struts, so there may be few
problems here or there.

 d) This might go without saying, but I guess this targets a post-1.0
release.

 e) I've got some test code I was using to validate this library, but it
isn't very clean and it uses Junit in parts.  Should I send that along as
well?

Hoping you find it useful,

 - Rod Waldhoff
   <rw...@us.britannica.com>

PS: Sorry about the HTML version of the message.  It happens automatically,
and I've been trying to get the local Exchange administrator to disable
that. (That's probably what pushed my last mail over 100K :( )