spring-5-注解AOP-1
来源:互联网 发布:软件项目招标评分标准 编辑:程序博客网 时间:2024/06/06 13:58
import org.aspectj.lang.annotation.AfterReturning;import org.aspectj.lang.annotation.Aspect;import org.aspectj.lang.annotation.Before;@Aspectpublic class DaoAspectJ {//execution(<修饰符模式>?<返回值模式><方法名模式>(<参数模式>)<异常模式>?)//@Before在执行某个方法直线执行下面方法中的代码:System.out.println("我要提交事务了");//* save*(..)) 分别代表 返回值类型(*:表示任意) 方法名(save*:这是一个通配符写法,以save开头的方法都拦截) .. 表示方法参数个数任意//所以* save之间需要有空格 类似 void saveget()//@Before相当于前置 @AfterReturning相当于后置//1:方法切点函数,通过描述目标类方法信息定义连接点。execution(),@annotation()////2:方法入参切点函数,通过描述目标类方法入参的信息定义连接点。args() @args()////3:目标代理类切点函数:通过描述目标类型信息定义连接点。 within() @within() target()////4:代理类切点函数通过描述目标类的代理类的信息定义连接点。@target() this()//大致了解//@AspectJ支持三种通配符://* :匹配任意字符,但它只能匹配上下文中的一个元素。//.. :匹配任意字符,可以匹配上下文中的多个元素,参数的代表//+ : 匹配指定类的所有类,必须跟在类后面,如:com.tz.aspectj.IUserService+//代表继承和扩展指定类的所有类,同时包括指定类本身。//@AspectJ函数按其是否支持通配符及支持的程度可分为以下3类://1:支持所有通配符的有:execution(),within(),如:within(com.tz.user.*)//2:仅支持+通配符的有:args(),this(),target(),如args(com.tz.User+)//3:不支持通配符的有:@args,@within(),@target(),@annotation()//逻辑运算符就用and or not@Before("execution(* save*(..))")public void bj(){System.out.println("我要提交事务了");}@AfterReturning("execution(* com.aop.spring.handerAnnotation.UserDao.save(..)) or execution(* com.aop.spring.handerAnnotation.CourseDao.save(..))")public void aj(){System.out.println("++事务提交完毕++");}}
阅读全文
0 0
- spring-5-注解AOP-1
- spring(AOP) 注解实现aop
- spring注解实现AOP
- Spring Aop 注解
- spring aop 注解
- spring aop注解Demo
- spring中 aop注解
- Spring AOP 完全注解
- Spring AOP注解配置
- Spring-AOP注解
- spring aop 注解方式
- Spring AOP 注解配置
- Spring中AOP注解
- Spring注解实现AOP
- spring aop 基于注解
- Spring aop基于注解
- spring aop 注解入门
- Spring---AOP(注解配置)
- spring-2-xml配置各种数据类型
- python练习(三)
- spring-3-xml配置AOP
- 教你Windows平台安装配置Hadoop2.5.2(不借助cygwin)
- spring-4-注解实体
- spring-5-注解AOP-1
- Python-字典
- Myeclipse入门
- [31]XPath
- spring-6-aop-3-cglib
- spring-7-aop-4-jdk
- Java Web 之 Cookie session
- POJ_MOOC_8459特殊密码锁
- Java桌面应用程序开发——iKB知识管理系统的第一次功能增强