加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

aop 简单使用

发布时间:2020-12-16 03:50:21 所属栏目:asp.Net 来源:网络整理
导读:配置: aop:aspectj-autoproxy / @Aspect @Component public class AopTest { @Pointcut("execution(* com.xt.service.duocai.campus.impl.CampusService.*(..))") public void handle() { } @Before("handle()") public Object Handle(JoinPoint joinPoint)
配置:

<aop:aspectj-autoproxy />


@Aspect
@Component
public class AopTest {
@Pointcut("execution(* com.xt.service.duocai.campus.impl.CampusService.*(..))")
public void handle() {
}

@Before("handle()")
public Object Handle(JoinPoint joinPoint) {
Object[] args = joinPoint.getArgs();
System.out.println(JSON.toJSONString(args));
return null;
}
}

说明:
  [email?protected] 表示该类是一个切面
  2. @Pointcut("execution(* com.xt.service.duocai.campus.impl.CampusService.*(..))")切入点为CampusService的所有方法。其中号表示切入点为任意的返回类型,(..)表示任意参数。

  3. @Before 通知类型,是切面的具体实现方法。可分为前置通知(Before)、后置通知(AfterReturning)、异常通知(AfterThrowing)、最终通知(After)和环绕通知(Around)五种。实现方法具体属于哪类通知,是在配置文件和注解中指定的

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读