Actually, I just checked in the completed JavassistProxyFactory class. It works for my simple test cases that I have, but I'm sure it'll mess something up when I get into duplicate methods in interfaces and stuff. I'll beef up the test cases soon and fix the logic.
-----Original Message----- From: James Carman [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 24, 2005 5:32 PM To: 'Jakarta Commons Developers List'; [EMAIL PROTECTED] Subject: RE: [proxy] vs proxytoys 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 [mailto:[EMAIL PROTECTED] On Behalf Of Jörg Schaible Sent: Wednesday, August 24, 2005 1:29 PM To: [email protected] Subject: Re: [proxy] vs proxytoys Joerg Hohwiller wrote: > -----BEGIN PGP SIGNED MESSAGE----- > 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) > > http://svn.apache.org/repos/asf/jakarta/commons/sandbox/proxy/trunk/src/java /org/apache/commons/proxy/ProxyFactory.java > > http://proxytoys.codehaus.org/javadoc/com/thoughtworks/proxy/ProxyFactory.ht ml > > 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: > http://svn.apache.org/repos/asf/jakarta/commons/sandbox/proxy/trunk/src/java /org/apache/commons/proxy/provider/ > > 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 :) > http://proxytoys.codehaus.org/javadoc/com/thoughtworks/proxy/toys/ > > 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
