I've been using ITDs as a big time saver in defining common actions that can be performed on objects. This is great in that the default code defined in the aspect applies a majority of the time. The problem is that in the cases where it doesn't apply, almost every time what I want to do is extend the code defined in the ITD and do something before and/or after the default rather than completely replace it, like a typical object hierarchy would do with a call to super.method(), and I can't find a good way to do that with ITDs. The best way I've come up with to handle this is to create an abstract superclass from which the interfaces are implemented so the abstract class inherits the default functionality and then in the concrete subclass I can call super.method().

I had posted a similar message a few months ago and someone suggested placing a second method in each ITD interface that would just be used to inherit the default functionality, ie:

public void method();

public void _method();

and then in the ITD _method would define the code and method() would just delegate to _method(), but that just seems like an awful lot of ugly code to perform a simple pattern, which is very anti AspectJ.

So I guess my question is.... is there a better way to do this? If not, shouldn't their be? I'd be satisfied with a way to call the method on the aspect, but since it's written out as something like public static void ajc$interMethod$... even if I knew the naming pattern and it wasn't subject to change those calls wouldn't lead to very readable code. I realize I could also use before/after/around advise on the method but that adds a whole new issue of what order the advice will fire in if the object structure becomes complex. So has this been an issue for anyone else? If there isn't a good solution, is there interest from any one else in a new feature to make this type of thing easier?

_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to