From torque-dev-return-7591-apmail-db-torque-dev-archive=db.apache.org@db.apache.org Sat Dec 02 11:51:28 2006 Return-Path: Delivered-To: apmail-db-torque-dev-archive@www.apache.org Received: (qmail 86227 invoked from network); 2 Dec 2006 11:51:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Dec 2006 11:51:28 -0000 Received: (qmail 89918 invoked by uid 500); 2 Dec 2006 11:51:36 -0000 Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 89908 invoked by uid 500); 2 Dec 2006 11:51:36 -0000 Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Apache Torque Developers List" Reply-To: "Apache Torque Developers List" Delivered-To: mailing list torque-dev@db.apache.org Received: (qmail 89897 invoked by uid 99); 2 Dec 2006 11:51:36 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Dec 2006 03:51:36 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [140.211.11.9] (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with SMTP; Sat, 02 Dec 2006 03:51:27 -0800 Received: (qmail 86110 invoked by uid 1977); 2 Dec 2006 11:51:07 -0000 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 2 Dec 2006 11:51:07 -0000 Date: Sat, 2 Dec 2006 03:51:07 -0800 (PST) From: Thomas Fischer To: Apache Torque Developers List cc: hps@intermeta.de Subject: Non-static Peers (was: Torque 4.0 plan) In-Reply-To: <21ca91ec0612010111kdf77dbeg8b9474ffc0c6e02e@mail.gmail.com> Message-ID: <20061202033525.A42556@minotaur.apache.org> References: <21ca91ec0611300258k545f984awa428c5d1229a1c95@mail.gmail.com> <21ca91ec0611301514y683b9867p7b590f4c78d31705@mail.gmail.com> <21ca91ec0612010111kdf77dbeg8b9474ffc0c6e02e@mail.gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Checked: Checked by ClamAV on apache.org Oops, I used the swear word "singleton" ... Fortunately, I probably misused it. I did not mean to enforce singleton behaviour, i.e. to forbid the existence of more than one instance. The static wrapper would be for ease of usage, the Backend class for those which do not want to use static method at all, and for the people in between, a setter to exchange the backend of the static class. I have appended some sample code. Would this be ok ? Any better suggestions ? Thomas The code would look as follows: public class SomePeer { private static SomePeerBackend backend; static { backend = new SomePeerBackend(); } public static void setBackend(SomePeerBackend backend) { if (backend == null) { throw new NullPointerException(); } this.backend = backend; } public static List doSelect(Criteria criteria) { return backend.doSelect(criteria); } .... } public class SomePeerBackend { /** Public constructor */ public SomePeerBackend() { } public List doSelect(Criteria criteria) { // do select, return results ... } ... } On Fri, 1 Dec 2006, Joe Carter wrote: > On 30/11/06, Henning P. Schmiedehausen wrote: >> >> "Joe Carter" writes: >> >> >Personally I'd just have the singleton (snip...) >> >> If you think about a singleton, please separate the singleton class >> and the implementation class (don't have the static getInstance() >> method and a possible private C'tor in the implementation). If you >> separate these, it is possible for projects using e.g. Spring to >> manage the classes through the framework. >> >> Even better, google for 'evil singleton' and read the first few links... >> >> Best regards >> Henning >> >> I completely agree. Allowing plug-in frameworks to work would be the > ideal. > Giving me _any_ way to extend was my main concern. > I was just a bit wary of asking for too much :-) > > Cheers > > Joe > --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org For additional commands, e-mail: torque-dev-help@db.apache.org