Spring Aop织入点语法
Aspectj织入点语法:
1、execution(public * *(..)) 任何类的任何返回值的任何方法
2、execution(* set*(..)) 任何类的set开头的方法
3、execution(* com.xyz.service.AccountService.*(..)) 任何返回值的规定类里面的方法
4、execution(* com.xyz.service..*.*(..)) 任何返回值的,规定包或者规定包子包的任何类任何方法
Advise总结。举例说明:
1、举例:直接指定要织入的位置和逻辑
|
1
2
3
4
5
6
7
8
9
10
11
|
//指定织入的方法。 @Before("execution(public * com.spring.service..*.*(..))") public void BeforeMethod(){ System.out.println("method start!"); } @AfterReturning("execution(public * com.spring.service..*.*(..))") public void AfterMethod(){ System.out.println("After returnning"); } |
2、通过定义pointcut来指定:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
//定义pointcut织入点集合 @Pointcut("execution(public * com.spring.service..*.*(..))") public void MyMethod(){} @Before("MyMethod()") public void BeforeMethod(){ System.out.println("method start!"); } @AfterReturning("MyMethod()") public void AfterMethod(){ System.out.println("After returnning"); } //执行前后都拦截。以pjp.proceed的方法分割开来 @Around("MyMethod()") public void aroundProcced(ProceedingJoinPoint pjp) throws Throwable{ System.out.println("around start"); pjp.proceed(); System.out.println("around end"); } |
输出结果:
method start!
around start
helloworld
After returnning
around end
Spring Aop织入点语法的更多相关文章
- Spring AOP: 织入的顺序
spring AOP 采用和 AspectJ 一样的优先顺序来织入增强处理:在进入连接点时,高优先级的增强处理将先被织入:在退出连接点时,高优先级的增强处理会后被织入. 当不同的切面里的两个增强处理需 ...
- Spring AOP配置与应用
1. 两种方式: a) 使用Annotation b) 使用xml 2. Annotation a) 加上对应的xsd文件spring-aop.xsd b) ...
- Spring Aop的理解和简单实现
1.AOP概念 所说的面向切面编程其实就是在处理一系列业务逻辑的时候这一系列动作看成一个动作集合.比如连接数据库来说: 加载驱动-----获取class--------获取连接对象-------访问数 ...
- Spring AOP 整理
在 xml中加 xmlns:aop="http://www.springframework.org/schema/aop" http://www.springframework.o ...
- SPRING AOP ....0 can't find referenced pointcut
下载最新的aspectjweaver就可以了,因为JDK的版本的问题不兼容. //织入点语法 @Pointcut("execution(public * com.frank.dao..*.* ...
- Spring Aop之Cglib实现原理详解
Spring Aop实现对目标对象的代理,AOP的两种实现方式:Jdk代理和Cglib代理.这两种代理的区别在于,Jdk代理与目标类都会实现同一个接口,并且在代理类中会调用目标类中被代理的方法,调用者 ...
- Spring Aop基于注解的实现
一.AspectOriented Programing,面向切面编程. AOP主要用于日志记录,性能统计,安全控制(权限控制),事务处理,异常处理等.将日志记录,性能统计,安全控制,事务处理,异常 ...
- Spring AOP全面详解(超级详细)
如果说 IOC 是 Spring 的核心,那么面向切面编程AOP就是 Spring 另外一个最为重要的核心@mikechen AOP的定义 AOP (Aspect Orient Programming ...
- 框架源码系列三:手写Spring AOP(AOP分析、AOP概念学习、切面实现、织入实现)
一.AOP分析 问题1:AOP是什么? Aspect Oriented Programming 面向切面编程,在不改变类的代码的情况下,对类方法进行功能增强. 问题2:我们需要做什么? 在我们的框架中 ...
随机推荐
- vue项目开发优化
1 按需引入ui组件 比如elementUI,不要直接在main.js中全局引入所有的组件,可以根据elementui的说明文件,按需引入 项目中的组件 2 异步引入路由组件 使用 { path:'/ ...
- docker 下mysql 和postgresql 数据库的搭建以及数据文件的迁移和备份
service docker start - docker 启动 service docker stop - docker 关闭 1.docker 镜像创建—使用的默认镜像有数据卷 docker pu ...
- 创建 LVM
1.将物理磁盘设备条带化为物理卷 # pvcreate /dev/sdb 查看物理卷: # pvs# pvdisplay 2.创建卷组,并添加 PV 到卷组 # vgcreate vg1 /dev/s ...
- [BJOI2019] 奥术神杖 [取log+AC自动机+dp]
题面 传送门 思路 首先,看到这个乘起来开根号的形式,应该能想到用取$\log$的方式做一个转化: $\sqrt[n]{\prod_i a_i}=\frac{1}{n}\sum_i \log_b a_ ...
- PHP mbstring通过多字节字符串扩展处理中文查找、计算问题
最近有个需求有到了mbstring相关的函数进行中文处理,如下: mb_strpos mb_strlen 过程中遇到一点比较奇怪的问题,及在本地环境运行没有问题 但我们生产环境是2台服务器,其中一台正 ...
- java后台面试之计算机网络问题集锦
1.http和https的区别 2.对称加密和非对称加密 3.三次握手与四次挥手的流程 4.为什么TCP需要三次握手?两次不可以吗?为什么 5.为什么TCP挥手需要四次?三次不行吗? 6.TCP协议如 ...
- Arm-Linux 移植 FFMPEG库 + x264
背景: ffmpeg 中带有264的解码,没有编码,需要添加x264.libx264是一个自由的H.264编码库,是x264项目的一部分,使用广泛,ffmpeg的H.264实现就是用的libx26 ...
- oracle-3-Linux-11g安装-静默安装
oracle下载地址:https://www.oracle.com/database/technologies/112010-linx8664soft.html 系统是最小化安装的Centos7.2 ...
- js中__proto__和prototype的区别和关系?(转)
转自知乎:https://www.zhihu.com/question/34183746
- vue+axios通过formdata提交参数和上传文件
demo.vue 文件 <template> <div class="demo"> <input v-model="importForm.m ...