Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Question about advising an advice

Hi

 

I have being trying to advice an advice in one aspect using it as the join point, with another advice in another aspect.

 

The syntax is something like:

 

Aspect advisor

{

            before(): adviceexecution() && within(advised)

{

            Do something…

}

}

 

Aspect advised

{

            Public pointcut firstpc() :call(* coreClass.fun(..))

before():firstpc()

 {

            System.out.println(“Hi”);

            myFun();

}

Public void myFun()

{

            System.out.println(“Hi Inner fun”);

}

 

}

 

coreClass

{

Definition…

Public void fun()

{

Do something

}

 

}

 

--------------

 

When I run this code it works, however, I am not being able to go into more detail, I want to specify an advice in the advisor aspect which advices a specific function,

For example, in the advised aspect in the advice we have two function calls, one to System.out….. and the other one to myFun, I want to be able to differentiate (create a different join point) for the System… and for myFun so that the advisor aspect performs different activities for calls to the different functions. Something like:

 

Aspect advisor

{

            before(): adviceexecution() && within(advised) && call (void myFun())

{

            Do something…

}

 

before(): adviceexecution() && within(advised) && call (void System.*(..))

{

            Do something else…

}

 

}

 

I have tried to run the latter and similar approaches but have not being successful. I know it can be done as it is mentioned in page 50 of the book (AspectJ in action) but have not figured it out, do you have an idea of how can I solve this problem?

 

Thank you

 

Herbey

 

 

 


Back to the top