Return-Path: Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: (qmail 81622 invoked from network); 13 Oct 2005 15:23:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 Oct 2005 15:23:34 -0000 Received: (qmail 20195 invoked by uid 500); 13 Oct 2005 15:23:16 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 20092 invoked by uid 500); 13 Oct 2005 15:23:15 -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 20052 invoked by uid 99); 13 Oct 2005 15:23:15 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Oct 2005 08:23:15 -0700 Received-SPF: pass (asf.osuosl.org: local policy) Received: from [212.85.125.162] (HELO v07274.home.net.pl) (212.85.125.162) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 13 Oct 2005 08:23:16 -0700 Received: from sj162.internetdsl.tpnet.pl (HELO ?192.168.1.62?) (lgawron.mobilebox@home@80.55.87.162) by matrix15.home.net.pl with SMTP; Thu, 13 Oct 2005 15:22:52 -0000 Message-ID: <434E7BCB.4090206@mobilebox.pl> Date: Thu, 13 Oct 2005 17:22:51 +0200 From: Leszek Gawron User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: dev@cocoon.apache.org Subject: ApplesProcessor - a little crazy idea Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N I'd like to: 1. make ApplesProcessor.instantiateController protected 2. introduce SpringAwareApplesProcessor that would not create an apples controller like the current one: private AppleController instantiateController(String className) throws Exception { Class clazz = Thread.currentThread() .getContextClassLoader().loadClass(className); Object o = clazz.newInstance(); return (AppleController) o; } but like this: private AppleController instantiateController( String beanName ) throws Exception { Object o = getSpringContext().getBean( beanName ); if ( !( o instanceof AppleController ) ) throw new SomeException( "cannot fetch an apple controller " + "by name: " + beanName ); } Most of my apples look like this: public class RouteDefinitionsApple extends AbstractSpringApple { public void process( AppleRequest request, AppleResponse response ){ ApplicationContext springContext = fetchContextFromSomewhere(); FooService foo = (FooService) springContext. getBean( "fooService" ); String bar = foo.bar(); response.sendPage( "view/foo.jx", bar ); } My change would allow to have automatic spring dependencies injected because the apple itself would be spring managed. We could make instantiateController either with bean name or bean class. WDYT? If you don't like it I will do 2). only in my codebase. -- Leszek Gawron lgawron@mobilebox.pl IT Manager MobileBox sp. z o.o. +48 (61) 855 06 67 http://www.mobilebox.pl mobile: +48 (501) 720 812 fax: +48 (61) 853 29 65