Return-Path: Delivered-To: apmail-geronimo-dev-archive@www.apache.org Received: (qmail 89687 invoked from network); 2 Feb 2005 21:08:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 2 Feb 2005 21:08:14 -0000 Received: (qmail 94122 invoked by uid 500); 2 Feb 2005 21:08:10 -0000 Delivered-To: apmail-geronimo-dev-archive@geronimo.apache.org Received: (qmail 94090 invoked by uid 500); 2 Feb 2005 21:08:09 -0000 Mailing-List: contact dev-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: dev@geronimo.apache.org Delivered-To: mailing list dev@geronimo.apache.org Received: (qmail 94077 invoked by uid 99); 2 Feb 2005 21:08:09 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from jetty3.inetu.net (HELO jetty3.inetu.net) (209.235.255.182) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 02 Feb 2005 13:08:08 -0800 Received: (qmail 4802 invoked from network); 2 Feb 2005 21:08:04 -0000 Received: from host217-42-73-28.range217-42.btcentralplus.com (HELO ?192.168.0.4?) (jules@217.42.73.28) by jetty3.inetu.net with AES256-SHA encrypted SMTP; 2 Feb 2005 21:08:04 -0000 Message-ID: <4201405D.30601@coredevelopers.net> Date: Wed, 02 Feb 2005 21:04:29 +0000 From: Jules Gosnell User-Agent: Mozilla Thunderbird 0.9 (X11/20041127) X-Accept-Language: en-us, en MIME-Version: 1.0 To: dev@geronimo.apache.org Subject: Re: Geronimo/Spring integration - Moving forward... (Dain, David, Jeremy,... - Please read) References: <41F985BC.2060303@coredevelopers.net> <41FA0EE3.70402@cakesolutions.net> <41FA17C2.2080705@cakesolutions.net> <41FA27C6.2040005@coredevelopers.net> <41FA60AF.9010909@coredevelopers.net> <41FA6E6A.3050006@apache.org> <41FA708C.3050007@cakesolutions.net> <488CDCAD-716F-11D9-9297-000D93C5B79C@gluecode.com> <41FAB054.5070603@coredevelopers.net> <41FAB467.5070201@cakesolutions.net> <420039B0.3080009@coredevelopers.net> <4200AEB2.2090905@cakesolutions.net> <4200B4A1.1040208@coredevelopers.net> <4200BA4A.1050001@cakesolutions.net> <4200BFFE.3030807@coredevelopers.net> <4200F7A4.90103@coredevelopers.net> <4200FC88.3020706@coredevelopers.net> <42010D45.5020501@coredevelopers.net> <420113CB.10501@apache.org> <42012E01.5030707@coredevelopers.net> In-Reply-To: <42012E01.5030707@coredevelopers.net> Content-Type: multipart/mixed; boundary="------------080803010209090702000800" X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. --------------080803010209090702000800 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Jules Gosnell wrote: > Jeremy Boynes wrote: > >> Jules Gosnell wrote: >> >>> >>> I would like to change the kernel - I don't think there is much >>> value in Spring support if the first thing we do is to start eroding >>> its feature set. >>> >> >> Please not at this time - IMHO changes to the kernel now would pose >> too much risk to the rest of the project with the progress to J2EE >> certification. >> >> Let's explore this in detail first (cough, design work, cough) and >> fire off a branch specifically for Spring if necessary. >> > OK - I will explore it in my local filespace and see how invasive the > change that I need is - then I will come back with my findings and you > guys can comment. > > Jules I enclose a minimal (15 lines changed/added) patch to the kernel which allows a POJO to be passed via Kernel.loadGBeanProxy(). This POJO is subsequently used as the target of the ensuing GBeanInstance. If the target is already initialise, the GBeanInstance does not bother to construct a fresh instance of its target's class, it just uses the one it has been given. Pros: It allows existing POJOs to take advantage of management and monitoring services provided by the kernel. Cons: person providing this POJO needs to be careful about managing its lifecycle - it must be loaded into the kernel after construction and unloaded before destruction. If it implements GBeanLifecycle the relevant methods will be called at the relevant time. Thoughts: This is really a minimal patch, designed to demonstrate exactly what I am talking about in the simplest manner. It should be immediately obvious that if no target is supplied the codepath will be completely unchanged. The path, if you do supply the target is suboptimal, many lines are still executed finding constructors and arranging parameters for them when they will never be called. Making the current requirement for target classes to provide accessible constructors conditional on whether a preconstructed target is not supplied will take a little more effort, but I don't see any real issue with this. So, Guys, what I am proposing is not really that scary is it ? What do you think ? Jules > >> -- >> Jeremy > > > > -- "Open Source is a self-assembling organism. You dangle a piece of string into a super-saturated solution and a whole operating-system crystallises out around it." /********************************** * Jules Gosnell * Partner * Core Developers Network (Europe) * * www.coredevelopers.net * * Open Source Training & Support. **********************************/ --------------080803010209090702000800 Content-Type: text/x-patch; name="kernel.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="kernel.patch" Index: src/java/org/apache/geronimo/kernel/Kernel.java =================================================================== --- src/java/org/apache/geronimo/kernel/Kernel.java (revision 149508) +++ src/java/org/apache/geronimo/kernel/Kernel.java (working copy) @@ -328,6 +328,12 @@ gbeanRegistry.register(gbeanInstance); } + public void loadGBeanProxy(Object target, GBeanData gbeanData, ClassLoader classLoader) throws GBeanAlreadyExistsException, InternalKernelException { + ObjectName objectName = gbeanData.getName(); + GBeanInstance gbeanInstance = new GBeanInstance(target, gbeanData, this, dependencyManager, lifecycleMonitor.createLifecycleBroadcaster(objectName), classLoader); + gbeanRegistry.register(gbeanInstance); + } + /** * @deprecated use loadGBean(GBeanData gbeanData, ClassLoader classLoader) */ Index: src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java =================================================================== --- src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java (revision 149508) +++ src/java/org/apache/geronimo/gbean/runtime/GBeanInstance.java (working copy) @@ -186,6 +186,11 @@ * mismatched attribute types or the intial data cannot be set */ public GBeanInstance(GBeanData gbeanData, Kernel kernel, DependencyManager dependencyManager, LifecycleBroadcaster lifecycleBroadcaster, ClassLoader classLoader) throws InvalidConfigurationException { + this(null, gbeanData, kernel, dependencyManager, lifecycleBroadcaster, classLoader); + } + + public GBeanInstance(Object target, GBeanData gbeanData, Kernel kernel, DependencyManager dependencyManager, LifecycleBroadcaster lifecycleBroadcaster, ClassLoader classLoader) throws InvalidConfigurationException { + this.target=target; this.objectName = gbeanData.getName(); this.kernel = kernel; this.lifecycleBroadcaster = lifecycleBroadcaster; @@ -759,6 +764,8 @@ } // create instance + if (target==null) + { try { target = constructor.newInstance(parameters); } catch (InvocationTargetException e) { @@ -773,7 +780,8 @@ log.warn("Constructor mismatch for " + objectName, e); throw e; } - + } + // inject the persistent attribute value into the new instance for (int i = 0; i < attributes.length; i++) { attributes[i].inject(); --------------080803010209090702000800--