Return-Path: Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: (qmail 30955 invoked from network); 31 Dec 2005 13:58:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 31 Dec 2005 13:58:32 -0000 Received: (qmail 7361 invoked by uid 500); 31 Dec 2005 13:58:31 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 6823 invoked by uid 500); 31 Dec 2005 13:58:29 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@cocoon.apache.org List-Id: Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 6812 invoked by uid 99); 31 Dec 2005 13:58:29 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 31 Dec 2005 05:58:29 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of joerg.heinicke@gmx.de designates 213.165.64.21 as permitted sender) Received: from [213.165.64.21] (HELO mail.gmx.net) (213.165.64.21) by apache.org (qpsmtpd/0.29) with SMTP; Sat, 31 Dec 2005 05:58:28 -0800 Received: (qmail invoked by alias); 31 Dec 2005 13:58:07 -0000 Received: from p54B78262.dip0.t-ipconnect.de (EHLO [192.168.122.254]) [84.183.130.98] by mail.gmx.net (mp033) with SMTP; 31 Dec 2005 14:58:07 +0100 X-Authenticated: #3483660 Message-ID: <43B68E06.3090209@gmx.de> Date: Sat, 31 Dec 2005 14:56:22 +0100 From: Joerg Heinicke User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 X-Accept-Language: de-de, de, en-us, en-gb, en MIME-Version: 1.0 To: dev@cocoon.apache.org Subject: Re: [RT] Simplifying component handling References: <43B577E9.6000306@apache.org> In-Reply-To: <43B577E9.6000306@apache.org> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8bit X-Y-GMX-Trusted: 0 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N On 30.12.2005 19:09, Carsten Ziegeler wrote: > class MyComponent implements SOMETHING, ThreadSafe, Disposable, > Serviceable { > protected ClassA compA; > protected ClassB compB; > protected ServiceManager m; > > public void service(ServiceManager m) { > this.m = m; > compA = (ClassA)m.lookup(ClassA.ROLE); > compB = (ClassB)m.lookup(ClassB.ROLE); > } > public void dispose() { > if ( m != null ) { > m.release(compA); > m.release(compB); > } > } > > Way too much code me thinks. So what about: > > class MyComponent implements SOMETHING, ThreadSafe { > protected final ClassA compA; > protected final ClassB compB; > > public MyComponent(ClassA a, ClassB b) { > compA = a; > compB = b; > } > } > > We could simply add constructor injection: if the implementation does > not provide a default constructor, the available constructor is called > using reflection and the components are injected on construction of the > object - no need to configure something in any xml configuration file. > Implementing this is easy - I did this already years ago for Fortress. What's the contract for the auto-wiring? Just assuming ClassA and ClassB have public static fields called ROLE? Sounds somewhat "strange". J�rg