Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] How to create nested aspects

Hi, 


Assuming I have a method:

public void sayHello(){

System.out.println("Hello world")

}


I'd like to have a nested round advice interception like:


System.out.println("Begin doA()")

System.out.println("Begin doB()")

sayHello()

System.out.println("End doB()")

System.out.println("End doA()")


If possible, I'd like the aspect definition for doA and doB are separated.

So, I can config the weaving behavior optionally with aop.xml if applicable, like:

case 1: only use doB

System.out.println("Begin doB()")

sayHello()

System.out.println("End doB()")


case 2: only use doA

System.out.println("Begin doA()")

sayHello()

System.out.println("End doA()")


case 3: switch the sequence

System.out.println("Begin doB()")

System.out.println("Begin doA()")

sayHello()

System.out.println("End doA()")

System.out.println("End doB()")



Any code samples are welcome.


Thanks

Leon




 

Back to the top