Get annotated parameters inside a pointcut

后端 未结 2 1041
抹茶落季
抹茶落季 2020-12-13 20:10

I have two annotation @LookAtThisMethod and @LookAtThisParameter, if I have a pointcut around the methods with @LookAtThisMethod how c

2条回答
  •  北海茫月
    2020-12-13 20:40

    final String methodName = joinPoint.getSignature().getName();
        final MethodSignature methodSignature = (MethodSignature) joinPoint
                .getSignature();
        Method method = methodSignature.getMethod();
        GuiAudit annotation = null;
        if (method.getDeclaringClass().isInterface()) {
            method = joinPoint.getTarget().getClass()
                    .getDeclaredMethod(methodName, method.getParameterTypes());
            annotation = method.getAnnotation(GuiAudit.class);
        }
    

    This code covers the case where the Method belongs to the interface

提交回复
热议问题