[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [aspectj-users] target(object and al extending objects)
|
Ron Bodkin wrote:
You're close:
pointcut findConstructors(SomeSuperClass superclass):
call(SomeSuperClass+.new(..)) && target(superclass);
This doesn't seem to work. It compiles, bit this pointcut finds nothing.
I have one superclass "SuperClass" and a few classes extending from that
superclass "ClassA", "ClassB", and so on.
In my application I never construct a SuperClass, I only have
ClassA a = new ClassA ();
ClassB b = new ClassB ();
...
so I never have (for example)
SuperClass something = new ClassA ();
If I write this:
pointcut findConstructors () : call (SuperClass+.new(..));
after () : findConstructors () {
//do something
}
Everything works fine (the after advices is executed for every new
instance of ClassA, ClassB ...). But in that after advice I want to do
something with the object just constructed (of type ClassA, ClassB, ...).
Your suggestion is:
pointcut findConstructors(SuperClass superclass):
call(SuperClass+.new(..)) && target(superclass);
with this advice:
after (SuperClass obj) : findConstructors (obj) {
//do something with obj (type SuperClass, but I will cast it)
}
That does compile, but it doesn't do anything. The after advice never gets
executed. My IDE (eclipse) also indicates that that is the case.
Am I missing something?
Jan