commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Carman" <>
Subject RE: [proxy] vs proxytoys
Date Wed, 24 Aug 2005 21:32:25 GMT
To be quite honest, nobody has fully provided the JavassistProxyFactory
implementation to commons-proxy yet, either. :-)  I started on it but
couldn't get the intercepted proxies working.  

One key difference, it seems, between proxytoys and commons-proxy is that
commons-proxy somewhat assumes that there will be a "target" object (some
actual object that implements the core functionality) to the invocation.
ProxyToys doesn't seem to make that assumption (correct me if I'm wrong).
One problem that I see with ProxyToys is in the implementation of the
DelegatingInvoker and SimpleInvoker (what I would have to use if I did have
a target object) class.  No matter what ProxyFactory you're using,
DelegatingInvoker and SimpleInvoker ultimately use JDK reflection to invoke
the method on the delegate/target.  Commons-proxy doesn't do that.
Commons-proxy doesn't do that.  ProxyToys, ultimately, should be much
slower, which is illustrated by the following code:

public class CompareToProxyToys
    private static final int N = 100000000;

    public static void main( String[] args )
        final EchoImpl impl = new EchoImpl();
        final Echo proxyToys = ( Echo )new
com.thoughtworks.proxy.factory.CglibProxyFactory().createProxy( new Class[]
{ Echo.class }, new SimpleInvoker( impl ) );
        final Echo commonsProxy = ( Echo )new
CglibProxyFactory().createProxy( new ConstantProvider<Echo>( impl ),
Echo.class );
        System.out.println( MessageFormat.format( "Average duration of
ProxyToys is approximately {0,number,0.00#} times slower than
commons-proxy.", new Double( averageDuration( proxyToys ) /
averageDuration(commonsProxy ) ) ) );

    private static double averageDuration( Echo echo )
        final long before = System.nanoTime();
        for( int i= 0; i < N; ++i )
            echo.echoBack( "Hello, World!" );
        final long after = System.nanoTime();
        return ( ( after - before ) * 1.0 / N );

ProxyToys' average duration was approximately 7x slower than commons-proxy
using this crude test (I'm not saying these are the best metrics in the
world).  Again, I allowed both implementations to use a CGLIB-based proxy.
-----Original Message-----
From: news [] On Behalf Of Jörg Schaible
Sent: Wednesday, August 24, 2005 1:29 PM
Subject: Re: [proxy] vs proxytoys

Joerg Hohwiller wrote:

> Hash: SHA1
> Jörg Schaible wrote:
>> Hi James,
> Hi there,
>> can you tell me, what you are missing with proxytoys? You announced to
>> have a closer look , but did not write anything further.
> It seems to be true that proxytoys and "commons-proxy" are quite similar
> animals. The API seems to differ slightly (esp. according to the
> Invoker/MethodIntercepter)
> The important things are:
> "commons-proxy" works on a javassist implementation

Nobody provided a ProxyFactory impl based on JavaAssist for ProxyToys yet :)

> and has interesting 
> goodies for various provider stategies:
> proxytoys has interesting goodies called "toys"

Decoration is the toy for interceptors, but they don't follow AOP Alliance
(at least yet). Personally I have no experiance with AOP though.

> (btw: why do you call the methods "object" there?):

Can't say, I did not invent this ... so it's historical :)

> Maybe it would be possible to bring both together, but it may start and
> fall by the political classpath thingy. I personally would always trust
> a classpath "org.apache.commons.proxy" more thant "com.*" (even
> thoughtworks produced a lot of great stuff such as XStream).

This is not my decision, but I might address this.

> On the other hand proxytoys might already be in use so changing the
> classpath might not be an option.

but it's not 1.0 yet :)

> However this one is not up to me.

.. and not only to me, I am also not a ThoughtWorker.

- Jörg

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message