Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 88372 invoked from network); 24 Aug 2005 22:49:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 Aug 2005 22:49:34 -0000 Received: (qmail 42645 invoked by uid 500); 24 Aug 2005 22:49:31 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 42615 invoked by uid 500); 24 Aug 2005 22:49:31 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: 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 42602 invoked by uid 99); 24 Aug 2005 22:49:31 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 24 Aug 2005 15:49:31 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of joerg.schaible@gmx.de designates 213.165.64.20 as permitted sender) Received: from [213.165.64.20] (HELO mail.gmx.net) (213.165.64.20) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 24 Aug 2005 15:49:48 -0700 Received: (qmail invoked by alias); 24 Aug 2005 22:49:28 -0000 Received: from p549A9EAC.dip0.t-ipconnect.de (EHLO paddy.schaible.local) [84.154.158.172] by mail.gmx.net (mp028) with SMTP; 25 Aug 2005 00:49:28 +0200 X-Authenticated: #348333 From: =?iso-8859-1?q?J=F6rg_Schaible?= Organization: N/A To: "James Carman" Subject: Re: [proxy] vs proxytoys Date: Thu, 25 Aug 2005 00:49:26 +0200 User-Agent: KMail/1.8.1 Cc: "'Jakarta Commons Developers List'" References: <200508242132.j7OLWJSn023632@carmanconsulting.com> In-Reply-To: <200508242132.j7OLWJSn023632@carmanconsulting.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200508250049.26863.joerg.schaible@gmx.de> 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 Wednesday 24 August 2005 23:32, James Carman wrote: JC> To be quite honest, nobody has fully provided the JavassistProxyFactory JC> implementation to commons-proxy yet, either. :-) I started on it but JC> couldn't get the intercepted proxies working. =20 :)) JC> One key difference, it seems, between proxytoys and commons-proxy is th= at JC> commons-proxy somewhat assumes that there will be a "target" object (so= me JC> actual object that implements the core functionality) to the invocation. JC> ProxyToys doesn't seem to make that assumption (correct me if I'm wrong= ). Right. Some view toy proxies can act without a target. JC> One problem that I see with ProxyToys is in the implementation of the JC> DelegatingInvoker and SimpleInvoker (what I would have to use if I did= =20 have JC> a target object) class. No matter what ProxyFactory you're using, JC> DelegatingInvoker and SimpleInvoker ultimately use JDK reflection to=20 invoke JC> the method on the delegate/target. Yes. In the end it the proxy uses always InvocationHandler.invoke() as=20 callback. JC> Commons-proxy doesn't do that. =20 Must have a look at the code :) JC> ProxyToys, ultimately, should be much JC> slower, which is illustrated by the following code: JC>=20 JC> public class CompareToProxyToys JC> { JC> private static final int N =3D 100000000; JC>=20 JC> public static void main( String[] args ) JC> { JC> final EchoImpl impl =3D new EchoImpl(); JC> final Echo proxyToys =3D ( Echo )new JC> com.thoughtworks.proxy.factory.CglibProxyFactory().createProxy( new=20 Class[] JC> { Echo.class }, new SimpleInvoker( impl ) ); JC> final Echo commonsProxy =3D ( Echo )new JC> CglibProxyFactory().createProxy( new ConstantProvider( impl ), JC> Echo.class ); JC> System.out.println( MessageFormat.format( "Average duration of JC> ProxyToys is approximately {0,number,0.00#} times slower than JC> commons-proxy.", new Double( averageDuration( proxyToys ) / JC> averageDuration(commonsProxy ) ) ) ); JC> } JC>=20 JC> private static double averageDuration( Echo echo ) JC> { JC> final long before =3D System.nanoTime(); JC> for( int i=3D 0; i < N; ++i ) JC> { JC> echo.echoBack( "Hello, World!" ); JC> } JC> final long after =3D System.nanoTime(); JC> return ( ( after - before ) * 1.0 / N ); JC> } JC> } JC>=20 JC> ProxyToys' average duration was approximately 7x slower than commons-pr= oxy JC> using this crude test (I'm not saying these are the best metrics in the JC> world). I'll investigate. JC> Again, I allowed both implementations to use a CGLIB-based proxy. Well, no The CglibProxyFactory of ProxyToys will use internally a JDK proxy if the=20 proxy implements exactly one interface. Don't ask me why, that is not my=20 code. But I'll try this without that "optimization". =2D J=F6rg --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org