I've been doing some digging and this is what I've found.
Here's some rough pseudo code from the Spring class AspectJAdviceParameterNameDiscoverer.maybeBindThis OrTargetOrArgsFromPointcutExpression() when it parses the Aspect I pasted above :
Code:
AspectJAdviceParameterNameDiscoverer.maybeBindThisOrTargetOrArgsFromPointcutExpression() {
String pointcutExpression = "privilegedPersonnel(privs)";
if(pointcutExpression matches "this" or "target") {
parse variable name & add to varNames
} else if(pointcutExpression matches "args") {
extract and set variable arguments from pointcut body
}
}
The issue is that I'm defining the pointcut with the following :
Code:
@Pointcut("execution(* getPrivilegedPersonnel(java.util.List, ..)) && args(privs, ..)")
public void privilegedPersonnel(List privs) {}
and then I'm defining the advice like this :
Code:
@Around("privilegedPersonnel(privs)")
public Object protectPersonnelBodUsage(ProceedingJoinPoint thisJoinPoint, List privs) throws Throwable { ..... }
Notice that the AspectJAdviceParameterNameDiscoverer class is expecting the args(...) declaration to be in the actual @Around declaration vs. the @Pointcut declaration. As far as I know the way I've defined my @Pointcut is valid in AspectJ.
The question then becomes, Does Spring require the args(...) declaration to be in the "Advice" declaration (e.g. @Around("privilegedPersonnel(privs) && args(...)")?
If not then the code in AspectJAdviceParameterNameDiscoverer needs to be enhanced so it can account for the args(...) declaration in @Pointcut.