Brian's Waste of Time

Sat, 14 Feb 2004

DynAOP Impressions

I have been playing with dynaop by Bob Lee (crazybob) for a bit now and am quite impressed. It pretty much does what my goals with intercepts were, plus a bit more (mixin support), and with a friendlier client API. Bob knows how to write a clean client API, that is for sure, and the BeanShell configuration is brilliant (though I have been using the Java config API instead -- which is also quite clean!).

Its interesting to see how he gets around this in mixins. DynAOP's solution is to use a type 1 style ioc container setup where the proxy can be provided to the mixin. It certainly works fine (is pragmatic ;-) but this support allows for more idiomatic Java. The way I did it in YAIL was to intercept all internal calls against anything not explicity declared in the mixin, or classes it extends, and return the call against the proxy from the interceptor, instead of against the mixin. This worked fairly nicely, and allowed for partial-class type things (implement an interface and only implement parts while trusting that the rest of the mixed in stuff will fill out the rest).

The proxy system is great (Bob certainly gets clean design) -- the cglib proxy for classes acts just like the interface proxy version, so the majority of the tool doesn't care if it is an interface proxy of cglib proxy.

It is just a hair slower than unbaked Yail interception in my tests, which is pretty impressive as Yail blows the other AOP's away even without baking in yet. I have figured some ways to speed up the unbaked Yail interception but haven't yet implemented them -- and to be honest, am considering not bothering to now! DynAOP gives me everything I was looking for when I started writing YAIL. It has some drawbacks though, which make me sit on the fence about dropping YAIL. First, it is built against CGLIB 1.0 and doesn't run against CGLIB 2.0 (which is due for release any-day-now). This is a significant drawback, but can probably be overcome with a couple patches. Second is the LGPL license, which can be inconvenient in infrastructure type tools in Java (which this definately is). Finally, there is no mechanism for proxying specific instances of a class instead of interface, but I don't think it would be difficult to add in (particularly if the switch to CGLIB 2 is being made).

All said -- the license thing may knock it out as my preferred tool as I do too much with BSD and Apache licensed projects, and I really want a good interceptor tool against them. Nanning is quite nice, but is pure Java DynamicProxy based with no support for class extension directly. From a technical standpoint, I would probably switch right over as modifying it for cglib2 and adding proxies to existing instances shouldn't be hard if the internals are as clean as the client API's!

2 writebacks [/src/java/aop] permanent link