aspectj 获取 连接点 方法!


public static Method getMethod(JoinPoint joinPoint) {
        Method method = null;
        String name = joinPoint.getSignature().getName();

        try {
        // 这才是 正统! MethodSignature signature = (MethodSignature) joinPoint.getSignature();
            Class[] types = signature.getParameterTypes();

            joinPoint.getSignature();
            method = joinPoint.getTarget(). getClass().getMethod(name,types);
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
        return method;
    }

 多个连接点--

@Before("@annotation(cloud.cjy.travel.module.common.annotation.CjyAspect) || within(@cloud.cjy.travel.module.common.annotation.CjyAspect *)")

或者:
 
 
private static MethodSignature getMethodSignature(JoinPoint joinPoint) {
Signature signature = joinPoint.getSignature();
return (MethodSignature) signature;
}



public
static Method getMethod(JoinPoint joinPoint) { MethodSignature methodSignature = getMethodSignature(joinPoint); return methodSignature.getMethod(); }


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM