Return-Path: Delivered-To: apmail-db-torque-user-archive@www.apache.org Received: (qmail 99555 invoked from network); 6 Jan 2004 07:55:17 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 6 Jan 2004 07:55:17 -0000 Received: (qmail 30428 invoked by uid 500); 6 Jan 2004 07:54:51 -0000 Delivered-To: apmail-db-torque-user-archive@db.apache.org Received: (qmail 30414 invoked by uid 500); 6 Jan 2004 07:54:51 -0000 Mailing-List: contact torque-user-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Apache Torque Users List" Reply-To: "Apache Torque Users List" Delivered-To: mailing list torque-user@db.apache.org Received: (qmail 30401 invoked from network); 6 Jan 2004 07:54:51 -0000 Received: from unknown (HELO teamware-gmbh.de) (212.29.0.11) by daedalus.apache.org with SMTP; 6 Jan 2004 07:54:51 -0000 Received: from [217.80.249.234] (account ekraemer@camelot.de HELO frodo) by teamware-gmbh.de (CommuniGate Pro SMTP 4.1.8) with ESMTP id 13012503 for torque-user@db.apache.org; Tue, 06 Jan 2004 08:55:01 +0100 Date: Tue, 06 Jan 2004 08:55:00 +0100 To: Apache Torque Users List Subject: Re: Torque with more dynamic DB connections... References: <3FF9F355.6540A96C@mwt.net> From: Ekkehard Kraemer Content-Type: text/plain; format=flowed; charset=iso-8859-15 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: In-Reply-To: <3FF9F355.6540A96C@mwt.net> User-Agent: Opera7.20/Win32 M2 build 3144 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N On Mon, 05 Jan 2004 17:29:25 -0600, Rob Gordon wrote: > I have been following thread regarding using a TorqueInstance with > multiple > databases, etc. > > I have a similar wish and a proposed solution, if I can get the > eyes/ears of a developer. > > I want to be able to use the same tables (ie Peers) across multiple > databases. [...] > > Hence, I want my peers to have their DATABASE_NAME set at runtime, not > in a static final as is currently done. > > My proposal/question/wish is that the templates/om/Peer.vm be changed to > include setDatabaseName()/getDatabaseName() and all the references to > DATABASE_NAME be changed to invoke the appropriate method. While digging around a bit, I found that *Criteria* has a "String dbName" parameter in some of its constructors; you can use that to some effect. At least for simple things, the default DB is not touched at all if you always specify your own dbName in all Criterias. I verified it by removing the default DB snippet from my properties, and running all my tests - works. Sniffing around the code turns up that not everything is fine though... there is the odd method which uses DATABASE_NAME in any case (for example utility methods of the peers/BasePeer which create temporary Criterias). The offending methods could be easily changed (without breaking previous behaviour), I guess. I have no idea how well this works with other components that use Torque (Turbine...) - no idea if they always use the default DB, or if it can be specified. Apart from that, I started to change a current CVS checkout so that the "Torque" singleton goes away. I.e., you can create a "TorqueInstance" in your application and pass it into everything. It's not difficult, nor are the changes looking like they could break a lot (didn't verify anything yet though). The point of this would be to be able to run several TorqueInstances at the same time, each with completely different settings. I'll see whether the Criteria/dbName approach solves all my problems before I continue working on the singleton approach though. If someone of you wants to pick up the work, I'll be happy to put a patch together, or just send the source tree. Again, I have no idea how hard it would be to adapt Turbine, for example, to use these alternative methods... Btw, if you simply want to specify the DB to use during startup, and never change it - why don't you simply use Torque.init(Configuration), and build your own "default" DB properties on the fly, by copying the properties from your wanted connection? Like String someDbInstance="theDbIWantToUseInThisVM"; conf = (Configuration)new PropertiesConfiguration(propertyFile); conf.setString("torque.dsfactory.defaultDbName.connection.url", conf.getString("torque.dsfactory."+someDbInstance+".connection.url"); ... Torque.init(conf); Ekkehard --------------------------------------------------------------------- To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org For additional commands, e-mail: torque-user-help@db.apache.org