|
From: Rod J. <rod...@in...> - 2003-11-30 17:32:27
|
All, I've made some further AOP changes, partly to allow for further CGLIB optimization, but principally to allow for a cleaner approach to pooling etc. The InvokerInterceptor is now gone. The old approach of the terminal interceptor invoking the target object has been replaced by this behaviour in the MethodInvocation itself. Of course other "terminal" invokers such as the EJB invokers will continue to work just fine as they don't call proceed. Other MethodInvocation implementations--CGLIB etc.--can have their own invocation behavior, for greater efficiency. (We don't want to end up calling Method.invoke with CGLIB.) Instead, there's a new interface: org.springframework.aop.TargetSource will identifies the "this" part of the joinpoint. (Of course this kind of thing isn't "classic" AOP and I don't think it can be done with AspectJ. But it's useful.) Normally the implementation is SingletonTargetSource, which caches a target. However, PrototypeInvokerInterceptor etc. are now in the aop.target package as PrototypeTargetSource, ThreadLocalTargetSource etc. A TargetSource or target can be used as the final name in an interceptor chain, as a target could formerly, so there shouldn't be that much impact on code. The only effect on your code should be: - if you use the PrototypeInvokerInterceptor, PoolingInvokerInterceptor or ThreadLocalInvokerInterceptor, in which case you need to move that bean definition to the corresponding TargetSource, which will be configured similarly. - if you created AOP proxies programmatically using an InvokerInterceptor. This is no longer necessary. - if you've subclassed or otherwise depended on the internals of some of the AOP classes. Note that it's no longer necessary to add an InvokerInterceptor as the last advisor when creating a proxy programmatically: a nice feature. So for: ProxyFactory p = new ProxyFactory(target); p.addInterceptor(0, new DebugInterceptor()); Can omit the index (0) in the second line. In the second line now we can add interceptors in order without bothering about the index (although this version will still work). Because there's no InvokerInterceptor, there are no longer any special requirements for the last interceptor. Regards, Rod |