Issue
In the book "spring in action",there is an aspectj expresssion:
execution(* concert.Performance.perform(..)) && within(concert.*)
execution() Matches join points that are method execution.
You use the execution() designator to select Performance’s perform() method.
execution(* concert.Performance.perform(..))
within() Limits matching to join points within certain type.
you want to confine the reach of that pointcut to only the concert package.
within(concert.*)
But I think,left part and right part of the expression both matches join points,"* concert.Performance.perform(..)" indicates join points must be in one class "Performance",it is already in package "concert",so what is the use of "within(concert.*)"?
If it is an "or",maybe useful,but it is an "and".
Solution
in this case within(concert.*)
is important and result will not be the same as just with execution(* concert.Performance.perform(..))
execution it's matching for methods.
within it's matching for types.
in this example you already has poincut execution -- for any parameter for method
perform with any access modifier and you add 'specific type' - within(concert.*)
so your poincut it's --
execution(* concert.Performance.perform(..)) && within(concert.*)
for any return type , for method perform from class Performance from package concert
that consume any type from package and sub - package concert
in case if you have just execution(* concert.Performance.perform(..))
it almost the same as for previous except that type can by ANY
Answered By - xyz
Answer Checked By - Mary Flores (JavaFixing Volunteer)