Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] "AspectJ question"

Simply textually reorder the advice in your aspect. If you have two
before-advice in the same aspects, applying to the same joinpoint,
they will be executed in the textual order of their appearance.

Eric

On 31/08/2007, Henrique Mostaert <henrique.mr@xxxxxxxxx> wrote:
> Hi All,
>
> I´m working with AspectJ and recently get a Problem:
>
> In order to ilustrate, consider the simple example:
>
>
>
> public class C{
>
>    public void m(int a, int b){ }
>
> }
>
>
>
> And an aspect like:
>
> public aspect AspectoC {
>
>      // Advice to run at beginning of every execution of method m()
>
>       before(C current) :
>
>             execution(void C.m(int ,int)) &&
>
>             within(teste.C) &&
>
>             this(current){
>
>
>
>             System.out.println("Code executed (I want to run in SECOND, but
> it runs in FIRST!!) before any code of method m() in Class C executes");
>
>       }             // Advice to run a specific code at beginning of all
> methods non-static!
>
>       before(C current) :
>
>             execution(!static * C.*(..)) &&
>
>             within(teste.C) &&
>
>             this(current){
>
>
>
>             System.out.println("This (I want to run in FIRST before
> everything) must execute before anything in methdo m() in Class C");
>
>       }
>
> }
>
>
>
>
> The question is: Is there a possibility to execute the second advice always
> in FIRST?
>
>
>
>  - The second advice is applicable to all methods in Class C, but a method
> m() is affected by the first advice. Thus, the first advice executes first
> than the second. I want a way to apply to all methods non-static to execute
> the second advice at FIRST. And if there is a method that has an advice that
> affected it, I would like that this advice executes after that the advice
> that affect all methods non-static.
>
>
>
> IF I execute this code it returns this result:
>
> Code executed (I want to run in SECOND, but it runs in FIRST!!) before any
> code of method m() in Class C executes
>
> This (I want to run in FIRST before everything) must execute before anything
> in methdo m() in Class C
> (So , I want a way to bring me a inverse result!!!)
>
> Thanks to ALL!
>
> --
> --------------------------------------------
> Henrique Mostaert
> EIG 2005 - Eclipse Innovation Grant - Awards Program
> Sun Certified Programmer for Java2 platform 1.4
> _______________________________________________
> 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