I cannot extend the AspectJ syntax for you, but I can offer a workaround. But first let me explain why it is impossible to do what you want with the args definition in pointcut: because if you map your EhealthSession parameter EhealthSession in the method signature, how does AspectJ handle the case where the signature contains several parameters of this class? The value of eheSess would be mixed.
Now thereβs a workaround: it can be slower - how much it depends on your environment, just check it out - but you can just bind a pointcut to all potential methods regardless of their parameter list, and then give advice to find the parameter you need to check the parameter list:
pointcut permissionCheckMethods() : execution(public * *(..)); before() throws AuthorizationException : permissionCheckMethods() { for (Object arg : thisJoinPoint.getArgs()) { if (arg instanceof EhealthSession) check(arg, thisJoinPointStaticPart.getSignature()); } }
PS: Perhaps you can narrow the focus through within(SomeBaseClass+) or within(*Postfix) or within(com.company.package..*) , so as not to apply recommendations for the entire universe.
kriegaex
source share