Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 9846 invoked from network); 22 Aug 2002 05:38:32 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 22 Aug 2002 05:38:32 -0000 Received: (qmail 14791 invoked by uid 97); 22 Aug 2002 05:39:08 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 14775 invoked by uid 97); 22 Aug 2002 05:39:08 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 14763 invoked by uid 98); 22 Aug 2002 05:39:07 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Date: Thu, 22 Aug 2002 15:38:30 +1000 (EST) From: Matthew Firth X-X-Sender: matthew@border.matera.net.au To: commons-dev@jakarta.apache.org cc: iarias@yahoo.com Subject: re: [DBCP] NamedDataSourceFactory to share DataSources between Servlet Contexts Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Isaac, My thought would be that an extension of BasicDataSourceFactory is better than creating a paralell implementation. If new resource parameters are supported by BasicDataSource & BasicDataSourceFactory (I have a list of them I plan to add sometime....) then this will work transparantly - i.e. without having to place identical changes into two separate classes. I would have implemented it as below. No idea if this code even compiles, let alone functions properly (and will probably be mangled by MTAs everywhere). My apologies if there something obvious here that I have overlooked & grossly simplified! matthew public class NamedDataSourceFactory extends BasicDataSourceFactory static private Hashtable namedPools = new Hashtable(); public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception { Reference ref = (Reference) obj; RefAddr ra = null; String poolName = "defaultPoolName"; // Get the name of the pool to use ra = ref.get("poolName"); if (ra != null) { poolName = ra.getContent().toString(); } // Check the Map to see if a pool with that name already exists BasicDataSource namedDataSource = (BasicDataSource)namedPools.get(poolName); if (namedDataSource != null) return namedDataSource else { Object dataSource = super.getObjectInstance(obj,name,nameCtx,environment); // Put the DataSource in the namedPools Map namedPools.put(poolName, dataSource); return (dataSource); } } -- To unsubscribe, e-mail: For additional commands, e-mail: