Это сработало для меня с одной небольшой модификацией. Мне нужно было использовать getMethod вместо getDeclaredMethod, так как мой метод был в суперклассе.
я есть две аннотации@LookAtThisMethod
а также@LookAtThisParameter
, если у меня есть pointcut вокруг методов с@LookAtThisMethod
как я могу извлечь параметры указанного метода, которые отмечены@LookAtThisParameter
?
Например:
@Aspect
public class LookAdvisor {
@Pointcut("@annotation(lookAtThisMethod)")
public void lookAtThisMethodPointcut(LookAtThisMethod lookAtThisMethod){}
@Around("lookAtThisMethodPointcut(lookAtThisMethod)")
public void lookAtThisMethod(ProceedingJoinPoint joinPoint, LookAtThisMethod lookAtThisMethod) throws Throwable {
for(Object argument : joinPoint.getArgs()) {
//I can get the parameter values here
}
//I can get the method signature with:
joinPoint.getSignature.toString();
//How do I get which parameters are annotated with @LookAtThisParameter?
}
}