首页 > 编程语言 > 详细

SpringAOP里JoinPoint常用方法总结

时间:2021-06-08 17:28:30      阅读:24      评论:0      收藏:0      [点我收藏+]
@Before("customerJoinPointerExpression()")
public void beforeMethod(JoinPoint joinPoint){
    joinPoint.getSignature().getName(); // 获取目标方法名
    joinPoint.getSignature().getDeclaringType().getSimpleName(); // 获取目标方法所属类的简单类名
    joinPoint.getSignature().getDeclaringTypeName(); // 获取目标方法所属类的类名
    joinPoint.getSignature().getModifiers(); // 获取目标方法声明类型(public、private、protected)
    Object[] args = joinPoint.getArgs(); // 获取传入目标方法的参数,返回一个数组
    joinPoint.getTarget(); // 获取被代理的对象
    joinPoint.getThis(); // 获取代理对象自己
}
// 获取目标方法上的注解
private <T extends Annotation> T getMethodAnnotation(ProceedingJoinPoint joinPoint, Class<T> clazz) {
    MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
    Method method = methodSignature.getMethod();
    return method.getAnnotation(clazz);
}

 

SpringAOP里JoinPoint常用方法总结

原文:https://www.cnblogs.com/zhf123/p/14862414.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!