Monday, April 16, 2007

Aspect Groovy: Per class and Per instance

From last post, I'm going to the next step by re-implementing my AOPSupportMetaClass again in Java to have some precise controls. Now the AOP metaclass got updated and support weaving both per class and per instance. However, the pointcut expression style is still based on John McClean's implementation.

This is for per instance weaving

def t = new TestObject()
t.around['save'] = { inv ->
inv.args[0] = inv.args[0] + '.'

And you can guess, this is per class weaving

TestObject.around['save'] = { inv ->
inv.args[0] = inv.args[0] + '.'
def t = new TestObject()'test')

Last test code can be obtained from here.

1 comment:

Bertrand said...

Trying to get the Java source code, I get a HTTP 403 error code (access denied) ;-)