Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Constructor calls of classes that implement a given interface

Hi.

I've read a bunch of the docs and I still can't figure this one out. Is it possible to advise the successful return of the top-most constructor for any type that implements a given interface, and get access to the object being constructed? Seems like it should be possible.

I want something like:

interface X {
}
class T implements X {
}

@Aspect
class A {
@AfterReturning(pointcut="initialization(X.new(..)) && this(a)", returning="a")
void advice(X a) {
}

for any type T that implements interface X. Based on the FAQ entry it seems like that should work, but it doesn't appear to. Perhaps it's just a matter of my incorrectly translating to annotation style.

One final hitch: the class I'm trying to catch via this joinpoint is itself an aspect. Are there ordering issues?

Thanks a bunch for your help!

-c


Back to the top