SpringAOP所支持的AspectJ切点指示器

项目类型描述
arg()限定连接点方法参数
@args()通过连接点方法参数上的注解进行限定
execution()用于匹配是连接点的执行方法
this()限制连接点匹配AOP代理Bean引用为指定的类型
target目标对象(即被代理对象)
@target()限制目标对象的配置了指定的注解
within限制连接点匹配执行的类型
@windin()限定连接点带有匹配注解类型
@annotation限定带有指定注解的连接点

Poincut()
1.execution()举例

@Pointcut("execution(* com.sample.common.model.a..*.*(..))")
public void pointCut(){
}
@Before("pointCut()")
public void before(){
}
@After("pointCut()")
public void after(){
}

2.@annotation举例

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@Documented
public @interface testAnnotation {
	String module() default "单元内容";
	String action() default "查询方法";
} 

@Pointcut("@annotation(com.sample.common.test.annotation.testAnnotation)")
public void pointCut(){
		
}
@AfterThrowing(throwing ="ex",pointcut="pointCut()")
public void afterThrowing(JoinPoint joinPoint,Throwable ex){

}
@AfterReturning(returning="rvt", pointcut="pointCut()")
public Object AfterExec(JoinPoint joinPoint,Object rvt) {

}

PS:Spring提供了一个注解@Order 可以在多个切片时,调整切片顺序,@Before 是从小到大运行,@After 是从大到小运行

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值