I would like Aspectj to bind my method arguments using args.
Something like this:
@Before("@annotation(authorized) && args(java.util.String)")
public void authorize(JoinPoint joinPoint, Authorized authorized, String str)
However, I can not count on the String argument being present. I want the advice to be applied to all methods using that annotation, not only the methods with a String argument.
If the advised method does not have a String argument, I'd like to have str
filled with a null value.
Is this possible? Or is the only option to use joinPoint.getArgs()
?
I have an answer to the question you asked in the comment to Andy's answer:
Console output:
As you can see, the two methods
baz
andbar
not ending with a certain type -Integer
in this example - are excluded from matching.