【Spring】AOP中JoinPoint和ProceedingJoinPoint相关方法使用

JoinPoint和ProceedingJoinPoint对象
1.JoinPoint对象封装了SpringAop中切面方法的信息,在切面方法中添加JoinPoint参数,就可以获取到封装了该方法信息的JoinPoint对象
2.ProceedingJoinPoint对象是JoinPoint的子接口,该对象只用在@Around的切面方法中

https://zhuanlan.zhihu.com/p/395735251
SpringBoot AOP中JoinPoint的用法和通知切点表达式

在这里插入图片描述

3.打印输出
getString是测试类的方法名,TestController是类名,一起来看看:

joinPoint.getSignature().toString():String com.fast.web.controller.TestController.getString()
joinPoint.getSignature().toShortString():TestController.getString()
joinPoint.getSignature().toLongString():public java.lang.String com.fast.web.controller.TestController.getString()
joinPoint.getSignature().getName():getString
joinPoint.getSignature().getModifiers():1
joinPoint.getSignature().getDeclaringType():class com.fast.web.controller.TestController
joinPoint.getSignature().getDeclaringTypeName():com.fast.web.controller.TestController
附带说明:
getModifiers()方法返回int类型值表示该字段的修饰符。
其中,该修饰符是java.lang.reflect.Modifier的静态属性。
对应表如下:
PUBLIC: 1
PRIVATE: 2
PROTECTED: 4
STATIC: 8
FINAL: 16
SYNCHRONIZED: 32
VOLATILE: 64
TRANSIENT: 128
NATIVE: 256
INTERFACE: 512
ABSTRACT: 1024
STRICT: 2048

4.getTarget()与getThis()
getTarget() 被代理对象,即连接点所在的目标对象
getThis() 代理对象

被代理对象的类名:com.example.worktest.aop.controller.AopController
代理对象的类名:com.example.worktest.aop.controller.AopController$$EnhancerBySpringCGLIB$$877afd82

5.参考

CSDN文档
https://blog.csdn.net/weixin_38446891/article/details/108981465?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-108981465-blog-103344406.235%5Ev43%5Epc_blog_bottom_relevance_base6&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-108981465-blog-103344406.235%5Ev43%5Epc_blog_bottom_relevance_base6&utm_relevant_index=2
  • 9
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值