SpringAOP aspectJ ProceedingJoinPoint 获取当前方法
aspectJ切面通过ProceedingJoinPoint想要获取当前执行的方法:
错误方法:
Signature s = pjp.getSignature();
MethodSignature ms = (MethodSignature)s;
Method m = ms.getMethod();
这种方式获取到的方法是接口的方法而不是具体的实现类的方法,因此是错误的。
正确方法:
Signature sig = pjp.getSignature();
MethodSignature msig = null;
if (!(sig instanceof MethodSignature)) {
throw new IllegalArgumentException("该注解只能用于方法");
}
msig = (MethodSignature) sig;
Object target = pjp.getTarget();
Method currentMethod = target.getClass().getMethod(msig.getName(), msig.getParameterTypes());
Spring 之AOP AspectJ切入点语法详解
https://blog.csdn.net/zhengchao1991/article/details/53391244
使用AspectJ编程
https://blog.csdn.net/zl3450341/article/details/7673938
转载于:https://www.cnblogs.com/leilong/p/9043372.html
SpringAOP aspectJ ProceedingJoinPoint 获取当前方法相关推荐
- java获取方法上的注解_Spring:使用Spring AOP时,如何获取目标方法上的注解
当使用spring AOP时,判断目标方法上的注解进行相关操作,如缓存,认证权限等 自定义注解 packagecom.agent.annotation;importjava.lang.annotati ...
- Spring-AOP @AspectJ进阶之访问连接点信息
文章目录 概述 JoinPoint ProceedingJoinPoint 实例 概述 AspectJ使用org.aspectj.lang.JoinPoint接口表示目标类连接点对象,如果是环绕增强时 ...
- Spring中的AOP在Advice方法中获取目标方法的参
参考:http://my.oschina.net/itblog/blog/211693 http://christang.iteye.com/blog/2037919 http://blog.csdn ...
- Spring中的AOP——在Advice方法中获取目标方法的参数(转)
获取目标方法的信息 访问目标方法最简单的做法是定义增强处理方法时,将第一个参数定义为JoinPoint类型,当该增强处理方法被调用时,该JoinPoint参数就代表了织入增强处理的连接点.JoinPo ...
- AspectJ中的JoinPoint方法概要
AspectJ中的切入点匹配的执行点称作连接的(Join Point),在通知方法中可以声明一个JoinPoint类型的参数.通过JoinPoint可以访问连接点的细节.下面简要介绍JponPoint ...
- springboot获取getBean方法以及ApplicationContext空指针问题解决
springboot获取getBean方法以及ApplicationContext空指针问题解决 参考文章: (1)springboot获取getBean方法以及ApplicationContext空 ...
- 如何从代码中获取当前方法的名称[复制]
本文翻译自:How to get the name of the current method from code [duplicate] This question already has an a ...
- java获取当前方法
1.获取当前方法堆栈,我们一般用 StackTraceElement[] stes = Thread.currentThread().getStackTrace(); 想要获取当前方法,切记不够灵活, ...
- Spring-AOP @AspectJ切点函数导读
概述 annotation execution args和args within within和target target和this 概述 切点函数是AspectJ表达式语言的核心,也是使用@Aspe ...
最新文章
- 混合云关键技术能力和发展趋势
- OC-CoreData的使用
- 在CheckBox中,仅仅允许选择一项
- 表的插入、更新、删除、合并操作_16_ 删除表中所有记录
- 浅谈游戏自动寻路A*算法
- ng-content的一个实际例子
- python2x 安装 psutil
- python接口测试实战_Python接口测试实战01:七种武器
- (14)Verilog数据类型-基本语法(二)(第3天)
- php可输入的下拉框,JavaScript_可编辑下拉框的2种实现方式,可编辑下拉框-HTML 复制代码 代 - phpStudy...
- SPSS学习入门 简介安装
- 【日语学习】动词、形容词、名词的敬体形、简体形
- 0xFFFF中的0x是什么意思
- 重温张柏芝08年博客_开发人员和运营人员将在2017年继续重温其在企业中的角色...
- 苹果电脑ping 不通本地网络
- hexo之icarus主题的美化修改以及简单的SEO配置
- IOI2022 D2T1 数字电路(计数概率/组合数学+线段树区间翻转)
- 组装服务器要固态硬盘,服务器选择时,为什么要选择固态硬盘
- c语言中反比例函数定义,初三数学反比例函数的定义知识点
- C/C++之内存调试工具GDB与Valgrind
热门文章
- 如何远程访问服务器的 Jupyter notebook
- linux环境安装tomcat8,启动时,报not touch:/user/tomcat/tomcat8/logs/catalina.out:not a file or directory...
- STM32位带操作实现过程解析
- 你的鼠标有多快-小游戏
- 我的物联网项目(十二) 单体应用架构不行?
- Python3 字典
- 【转】WEB前端调优
- Java2实用教程(第二版)程序代码——第十四章 Component类的常用方法
- Android 起调系统功能,打开系统浏览器,拨打电话,发送短信,手机震动,跳转到设置通知开关页面
- 常见Eclipse SVN插件报错解决方法