skip to main |
skip to sidebar
Help diagnose diseases
Join an exciting field
===================================================================================================================================== Hi Paolo, It is possible to emulate some AOP concepts with groovy metaprogramming, but not all. There is an idea in AOP called quantification plus obliviousness. This means: 1. Quantification: it must be possible to express some sort of logical expression that provides some flexibility as to when and where advice is applied to base code. 2. Obliviousness: base code that is advised by an aspect should be oblivious to the aspect (ie- there should not be anything in the base code that is specifically coded towards being advised). Groovy does well with #2 because it is possible to obliviously replace code with other code using metaprogramming. However Groovy is not good at #1 because it is only possible to replace a single method at a time, rather than write some sort of pointcut expression that can (conditionally) apply to many different methods. That being said, Groovy's MOP is extremely powerful. --a On Mon, Aug 3, 2009 at 3:34 PM, Paolo DiCanio< domu ... @yahoo.co.uk > wrote: Hi, I know that you can implement invokeMethod() to intercept calls to methods that don't exist, but is it possible to emulate the following concepts from AOP with Groovy MOP: - beforeMethod: do something before a method is called (access to the param values should be available) - afterMethod: do something after a method is called (access to the return value should be available) If so, I'd be grateful for an example or two. Thanks, Paolo -- View this message in context: http://www.nabble.com/emulating-AOP-with-Groovy-MOP-tp24799327p24799327.html Sent from the groovy - user mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email