Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 45612 invoked from network); 5 Mar 2004 18:57:53 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 5 Mar 2004 18:57:53 -0000 Received: (qmail 1929 invoked by uid 500); 5 Mar 2004 18:57:40 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 1859 invoked by uid 500); 5 Mar 2004 18:57:40 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 1846 invoked from network); 5 Mar 2004 18:57:40 -0000 Received: from unknown (HELO rwcrmhc12.comcast.net) (216.148.227.85) by daedalus.apache.org with SMTP; 5 Mar 2004 18:57:40 -0000 Received: from almightybeast (h0010b50ed00a.ne.client2.attbi.com[24.128.112.68]) by comcast.net (rwcrmhc12) with SMTP id <2004030518574401400fb2i3e>; Fri, 5 Mar 2004 18:57:44 +0000 From: "Howard M. Lewis Ship" To: "'Jakarta Commons Developers List'" Subject: RE: [HiveMind] Interceptors - CGLIB / Javassist comparison Date: Fri, 5 Mar 2004 13:57:38 -0500 Message-ID: <035201c402e3$badaf500$6401a8c0@ALMIGHTYBEAST> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4510 In-Reply-To: <4048CABC.7040504@comcast.net> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N A valuable discussion. I think Javassist will have a slight edge based on lack of object instantiation in the long run. I may be wrong. Doesn't really matter ... that why ServiceInterceptorFactory is a service ... we may ultimately have all kinds of different implementations based on whatever bytecode enhancement framework is handy ... or even JDK proxies. -- Howard M. Lewis Ship Independent J2EE / Open-Source Java Consultant Creator, Tapestry: Java Web Components http://howardlewisship.com > -----Original Message----- > From: Harish Krishnaswamy [mailto:hkrishnaswamy@comcast.net] > Sent: Friday, March 05, 2004 1:45 PM > To: Jakarta Commons Developers List > Subject: Re: [HiveMind] Interceptors - CGLIB / Javassist comparison > > > Seems that's what you said before ;) But nevermind this is a > more-than-enough-pointer! > > -Harish > > Christian Essl wrote: > > > Sorry I made a mistake I meant ProxyFactory.extend() not create(). > > > > On Fri, 05 Mar 2004 13:37:06 -0500, Harish Krishnaswamy > > wrote: > > > >> Absolutely! Thanks for the tips. So that's what I'll do. > >> > >> -Harish > >> > >> Christian Essl wrote: > >> > >>> Hi Harish, > >>> > >>> I agree with you that HiveMind should provide a simpler (second) > >>> form to write interceptors. > >>> > >>> But before you waste your weekend looking at my code I > have to tell > >>> you that I did not use CGLIB but rather used Javassist to call > >>> MethodInterceptors. And this was a mistake CGLIB is > certainly better > >>> for that. > >>> > >>> If you want to see how CGLIB is used take a look at one of the > >>> aop-frameworks dynaop, spring or nanning. > >>> > >>> I persanlly like dynaop (while they use CGLIB 1) > according to there > >>> website dynaop is faster than the others (even than JBoss aop - > >>> which uses Javassist). Dynaop is also well documented and not too > >>> complex - while you can learn a lot. To start look at the > >>> ProxyFactory.extend() method - as I see cglib is used > only from in > >>> there - and take a look at the > ClassProxyInvocationHandler and its > >>> super-class. > >>> > >>> I hope this helps a bit (certainly more than my code). > >>> > >>> Thanks, > >>> Chris > >>> > >>> > >>> > >>> On Fri, 05 Mar 2004 13:06:05 -0500, Harish Krishnaswamy > >>> wrote: > >>> > >>>> Oops, sent to the wrong list! > >>>> > >>>> Harish Krishnaswamy wrote: > >>>> > >>>>> Hi, > >>>>> > >>>>> I decided to do some work on interceptors and wanted to find a > >>>>> suitable solution and so tried out CGLIB and Javassist and here > >>>>> are my initial findings. > >>>>> > >>>>> 1. Ease-of-use / clarity / maintainability - Obviously here, > >>>>> anybody that has done a little bit of Javassist will > agree that it > >>>>> is in no way comparable to CGLIB when it comes to ease-of-use. > >>>>> CGLIB is all plain Java and very straight forward and > Javassist is > >>>>> on the other end of the spectrum - pieces of string literals > >>>>> patched together to form Java statements. > >>>>> > >>>>> 2. Performance - This is interesting. CGLIB has a disadvantage > >>>>> here due to the number of parameters passed to the intercept > >>>>> method. It turns out, all of the overhead is because of these > >>>>> parameters that cannot be overcome (atleast AFAIK). > With a single > >>>>> counter interceptor I could make Javassist as much as > ~4 times as > >>>>> fast as CGLIB (~300% faster). And with more > interceptors obviously > >>>>> Javassist is more faster. Now, if I insert a method call in the > >>>>> Javassist interceptor with 4 parameters, to my surprise the > >>>>> performance is identical to the CGLIB interceptor. > Would be really > >>>>> nice if CGLIB can be designed around this problem. > >>>>> > >>>>> 3. Limitations - There are quite a few limitations with > Javassist > >>>>> that can be found on their website primary one for me being not > >>>>> able to debug instrumented classes. I have not come across any > >>>>> such limitations with CGLIB. > >>>>> > >>>>> From this intial study, it looks to me that we certainly need a > >>>>> way to provide CGLIB interceptors to services. And that's what > >>>>> I'll be doing this weekend. I know Christian has > already done some > >>>>> work on this, I'll see if I can reuse it. > >>>>> > >>>>> -Harish > >>>>> > >>>>> PS. I can post the code if anybody is interested. > >>>>> > >>>>> > >>>> > >>>> > --------------------------------------------------------------------- > >>>> To unsubscribe, e-mail: > commons-dev-unsubscribe@jakarta.apache.org > >>>> For additional commands, e-mail: > commons-dev-help@jakarta.apache.org > >>> > >>> > >>> > >>> > >>> > >> > >> > --------------------------------------------------------------------- > >> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org > >> For additional commands, e-mail: > commons-dev-help@jakarta.apache.org > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org > For additional commands, e-mail: commons-dev-help@jakarta.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org