Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Using an after on a function called within an aspect

I think you problem is just the "call(Foo.new()) && target(f)". There
is no target on constructor call joinpoints. You can capture the
constructed object with after-returning.

This might help:
http://pointcutdoctor.sourceforge.net/

Eric

2008/5/12  <kmerriman+aspects@xxxxxxxxx>:
> I seem to be having difficulty with this attempt to use after advice.
>  Basically, in one aspect, I am declaring a function on a
>  class....Actually, code might help this.
>
>  class HappyClass {
>  }
>
>  aspect HappyAspect {
>   Foo HappyClass.foo = null;
>
>   public void HappyClass.doFoo() {
>    foo = new Foo();
>   }
>  }
>
>  aspect OtherAspect {
>   after(Foo f) : call(Foo.new()) && target(f) && within(HappyClass) {
>    // Do something cool here
>   }
>   after(Foo f) : call(Foo.new()) && target(f) &&
>  withincode(HappyClass.doFoo()) {
>    // Do something cool here
>   }
>   after(Foo f) : call(Foo.new()) && target(f) && within(HappyAspect) {
>    // Do something cool here
>   }
>   after(Foo f) : call(Foo.new()) && target(f) {
>    // Do something cool here
>   }
>  }
>
>  Note that this does not apply, it says the advice did not match.  None
>  of the above advice applies.  Is there some trick I need to use to
>  aspect on function calls within injected methods?  Is this even
>  possible?  How would I do it if it is possible?
>
>  Thanks in advance,
>  Kendall
>  _______________________________________________
>  aspectj-users mailing list
>  aspectj-users@xxxxxxxxxxx
>  https://dev.eclipse.org/mailman/listinfo/aspectj-users
>



-- 
Eric Bodden
Sable Research Group
McGill University, Montréal, Canada


Back to the top