Return-Path: Delivered-To: apmail-geronimo-dev-archive@www.apache.org Received: (qmail 52232 invoked from network); 17 Nov 2005 22:17:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 17 Nov 2005 22:17:37 -0000 Received: (qmail 68916 invoked by uid 500); 17 Nov 2005 22:17:33 -0000 Delivered-To: apmail-geronimo-dev-archive@geronimo.apache.org Received: (qmail 68870 invoked by uid 500); 17 Nov 2005 22:17:33 -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 List-Id: Delivered-To: mailing list dev@geronimo.apache.org Received: (qmail 68859 invoked by uid 99); 17 Nov 2005 22:17:33 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Nov 2005 14:17:33 -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 ammulder@gmail.com designates 64.233.162.205 as permitted sender) Received: from [64.233.162.205] (HELO zproxy.gmail.com) (64.233.162.205) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Nov 2005 14:19:06 -0800 Received: by zproxy.gmail.com with SMTP id r28so41312nza for ; Thu, 17 Nov 2005 14:17:11 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=IrU8dbQ3xzLINAfW7qU6xb5fKiq+pxSsBTVC4wkLBbDk8RSrAOcXGEWtKaNKa8BTdiOa+BPVH7v6EqIm6lcHqO6Pl1JPk4YWeMShFERO8e/v5qmhTFiTH5JgXwUiPXLlmJYwhP2HLRm3NTXXgajFfNn39aUiy8ZvmT+KU+AAsdc= Received: by 10.37.18.7 with SMTP id v7mr7873175nzi; Thu, 17 Nov 2005 14:17:11 -0800 (PST) Received: by 10.37.13.69 with HTTP; Thu, 17 Nov 2005 14:17:11 -0800 (PST) Message-ID: <74e15baa0511171417h2c950cf7x26a56c9104e0b73f@mail.gmail.com> Date: Thu, 17 Nov 2005 17:17:11 -0500 From: Aaron Mulder Sender: ammulder@gmail.com To: dev@geronimo.apache.org Subject: Re: BasicProxyManager.java commit r344848 In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <74e15baa0511160854m5cc4874fk28101926c5d2093@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hmm. In the interesting case, we already pass in the CL to the BPM, but then it has some internal method that it just passes the clases to, and that's the one that creates the Enhancer and sets the CL on that. I guess we just need to pass the original CL through. That sure seems obvious now that you mention it. :) Aaron On 11/17/05, Dain Sundstrom wrote: > I'm confused why we are trying guess the parent most class loader.... > > When we are creating a proxy to a service, our goal is to create a > class that the caller can interact with. This mean that no matter > what interfaces we would like the proxy to implement, all of those > interfaces must be loaded from the caller's class loader. Since the > caller knows its own class loader, why not require the the caller > pass in its class loader? > > I think we should always use this form of createProxy: > > public Object createProxy(ObjectName target, ClassLoader loader); > > or a new form like this, which would grab the thread context classloader > > public Object createProxy(ObjectName target); > > and we deprecate the others. This version is much cleaner because it > load all interface class directly from the specified class loader > which eliminates the possibility of having a class from the wrong > class loader. > > The other problem with BasicProxyManager is the method > createProxyFactory does not accept a target class loader. This > should be a mandatory argument to the method. > > -dain > > On Nov 16, 2005, at 8:54 AM, Aaron Mulder wrote: > > > On 11/16/05, Kevan Miller wrote: > >> Aaron, > >> Nice work getting to the bottom of this issue. However, I'm not > >> sure that > >> I'm happy with your fix. I'm confident that your fix will find a > >> ClassLoaders which can load all of the classes/interfaces. > >> However, there > >> can be multiple of these and there's no guarantee that you're > >> finding the > >> most appropriate ClassLoader. For example imagine an application > >> classloader > >> with inverseClassLoading set to true. You're technique might find > >> a parent > >> ClassLoader, when the desired ClassLoader is the application > >> classloader. > > > > For my part, I don't really care which class loader is "ideal" so long > > as we try to get one that can load all the classes. I'm not too > > concerned that parent and child may be using different definitions of > > the same class such that a different "master" CL might result in using > > a different definition. We're only talking about GBean interfaces > > here, and I think unlikely to have different versions in use by > > different CLs (at present). Can you think of a specific use case in > > Geronimo where we might run into a problem? I know David J is working > > on fully versioned configurations, which might make a difference. > > > >> I have an alternate fix which calculates a child ClassLoader from > >> the > >> potential list of ClassLoaders (my fix assumes that there is one > >> ClassLoader > >> to which all other ClassLoaders are ancestors). I've tested > >> against Joe's > >> test case. It too fixes the problem... > >> > >> As I'm typing this, I'm wondering if we have an even larger > >> problem. Is > >> there a guarantee that the list of ClassLoaders available to the > >> BasicProxyManager constructor contains a single ClassLoader which > >> is capable > >> of loading of the given classes? Seems pretty easy to > >> construct a > >> scenario in which this is not true. I'd be interested in hearing > >> what you or > >> others might think... > > > > Right, there's no guarantee this will solve all possible problems. > > Right now it just falls through if it can't identify a "master" CL. I > > suppose we could create a new multi-parent CL on the spot if we needed > > to. > > > > Aaron > > > >> A problematic scenario would look like this: > >> > >> System ClassLoader > >> / | \ > >> A B C > >> \ | / > >> My ClassLoader > >> > >> Assume that ClassLoader A is the loader for class a, etc. If the > >> classes a, > >> b, and c are passed to the BasicProxyManager constructor, it will > >> not be > >> able to determine a ClassLoader capable of loading a, b, c. > >> Is this an > >> invalid use case? Neither of our fixes will work in this case... > >> > >> --kevan > >> > >> > >> On 11/15/05, ammulder@apache.org wrote: > >>> Author: ammulder > >>> Date: Tue Nov 15 18:32:31 2005 > >>> New Revision: 344848 > >>> > >>> URL: http://svn.apache.org/viewcvs?rev=3D344848&view=3Drev > >>> Log: > >>> Pick the best ClassLoader for the provided set of interfaces > >>> (Fixes GERONIMO-1064) > >>> > >>> Modified: > >>> > >> geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ > >> basic/BasicProxyManager.java > >>> > >>> Modified: > >> geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ > >> basic/BasicProxyManager.java > >>> URL: > >> http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/ > >> java/org/apache/geronimo/kernel/basic/BasicProxyManager.java? > >> rev=3D344848&r1=3D344847&r2=3D344848&view=3Ddiff > >>> > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >> =3D=3D=3D=3D=3D=3D=3D=3D=3D > >>> --- > >> geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ > >> basic/BasicProxyManager.java > >> (original) > >>> +++ > >> geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/ > >> basic/BasicProxyManager.java > >> Tue Nov 15 18:32:31 2005 > >>> @@ -207,6 +207,24 @@ > >>> } else if(type.length =3D=3D 1) { // Unlikely (as a > >>> result of > >> GeronimoManagedBean) > >>> enhancer.setSuperclass(type[0]); > >>> } else { > >>> + ClassLoader best =3D null; > >>> + outer: > >>> + for (int i =3D 0; i < type.length; i++) { > >>> + ClassLoader test =3D > >> type[i].getClassLoader(); > >>> + for (int j =3D 0; j < type.length; j++) { > >>> + String className =3D type[j].getName(); > >>> + try { > >>> + test.loadClass(className); > >>> + } catch (ClassNotFoundException e) { > >>> + continue outer; > >>> + } > >>> + } > >>> + best =3D test; > >>> + break; > >>> + } > >>> + if(best !=3D null) { > >>> + enhancer.setClassLoader(best); > >>> + } > >>> if(type[0].isInterface()) { > >>> enhancer.setSuperclass(Object.class); > >>> enhancer.setInterfaces(type); > >>> > >>> > >>> > >> > >> > >